@@ -72,7 +72,7 @@ static stat_t _sync_to_planner(void);
72
72
static stat_t _sync_to_tx_buffer (void );
73
73
static stat_t _dispatch_command (void );
74
74
static stat_t _dispatch_control (void );
75
- static void _dispatch_kernel (void );
75
+ static void _dispatch_kernel (const devflags_t flags );
76
76
static stat_t _controller_state (void ); // manage controller state transitions
77
77
78
78
static Motate::OutputPin<Motate::kOutputSAFE_PinNumber > safe_pin;
@@ -191,7 +191,7 @@ static stat_t _dispatch_control()
191
191
if (cs.controller_state != CONTROLLER_PAUSED) {
192
192
devflags_t flags = DEV_IS_CTRL;
193
193
if ((cs.bufp = xio_readline (flags, cs.linelen )) != NULL ) {
194
- _dispatch_kernel ();
194
+ _dispatch_kernel (flags );
195
195
}
196
196
}
197
197
return (STAT_OK);
@@ -200,17 +200,27 @@ static stat_t _dispatch_control()
200
200
static stat_t _dispatch_command ()
201
201
{
202
202
if (cs.controller_state != CONTROLLER_PAUSED) {
203
- devflags_t flags = DEV_IS_BOTH;
203
+ devflags_t flags = DEV_IS_BOTH | DEV_IS_MUTED; // expressly state we'll handle muted devices
204
204
if ((!mp_planner_is_full ()) && (cs.bufp = xio_readline (flags, cs.linelen )) != NULL ) {
205
- _dispatch_kernel ();
205
+ _dispatch_kernel (flags );
206
206
}
207
207
}
208
208
return (STAT_OK);
209
209
}
210
210
211
- static void _dispatch_kernel ()
211
+ static void _dispatch_kernel (const devflags_t flags )
212
212
{
213
213
stat_t status;
214
+
215
+ if (flags & DEV_IS_MUTED) {
216
+ status = STAT_INPUT_FROM_MUTED_CHANNEL_ERROR;
217
+ nv_reset_nv_list (); // get a fresh nvObj list
218
+ nv_add_string ((const char *)" msg" , " lines from muted devices are ignored" );
219
+ nv_print_list (status, TEXT_NO_PRINT, JSON_RESPONSE_TO_MUTED_FORMAT);
220
+
221
+ // It's possible to let some stuff through, but that's not happening yet.
222
+ return ;
223
+ }
214
224
215
225
while ((*cs.bufp == SPC) || (*cs.bufp == TAB)) { // position past any leading whitespace
216
226
cs.bufp ++;
@@ -299,6 +309,23 @@ void controller_set_connected(bool is_connected) {
299
309
}
300
310
}
301
311
312
+ /*
313
+ * controller_set_muted(bool) - hook for xio to tell the controller that we
314
+ * have/don't have one or more muted devices.
315
+ */
316
+
317
+ void controller_set_muted (bool is_muted) {
318
+ // TODO: care about text mode
319
+ if (is_muted) {
320
+ // one channel just got muted.
321
+ const bool only_to_muted = true ;
322
+ xio_writeline (" {\" muted\" :true}\n " , only_to_muted);
323
+ } else {
324
+ // one channel just got unmuted, announce it (except to the muted)
325
+ xio_writeline (" {\" muted\" :false}\n " );
326
+ }
327
+ }
328
+
302
329
/*
303
330
* controller_parse_control() - return true if command is a control (versus data)
304
331
* Note: parsing for control is somewhat naiive. This will need to get better
@@ -456,4 +483,4 @@ stat_t _test_system_assertions()
456
483
return (STAT_OK);
457
484
}
458
485
459
-
486
+
0 commit comments