Skip to content

Commit 1d86a71

Browse files
committed
Allow to turn off monitoring of output control ports
Signed-off-by: falkTX <[email protected]>
1 parent 9d4dc13 commit 1d86a71

File tree

5 files changed

+54
-5
lines changed

5 files changed

+54
-5
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Options
9191
-i, --interactive
9292
interactive shell mode
9393

94-
-n, --nofork
94+
-n, --nofork
9595
run in non-forking mode
9696

9797
-V, --version
@@ -196,6 +196,10 @@ The commands supported by mod-host are:
196196
* request monitoring of an output control port (on the feedback port)
197197
e.g.: monitor_output 0 "meter"
198198

199+
monitor_output_off <instance_number> <param_symbol>
200+
* turn off monitoring of an output control port (on the feedback port)
201+
e.g.: monitor_output_off 0 "meter"
202+
199203
midi_learn <instance_number> <param_symbol> <minimum> <maximum>
200204
* start MIDI learn for a control port
201205
e.g.: midi_learn 0 "gain" 0.0 1.0

src/effects.c

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6838,7 +6838,7 @@ int effects_monitor_parameter(int effect_id, const char *control_symbol, const c
68386838
return SUCCESS;
68396839
}
68406840

6841-
int effects_monitor_output_parameter(int effect_id, const char *control_symbol_or_uri)
6841+
int effects_monitor_output_parameter(int effect_id, const char *control_symbol_or_uri, int enable)
68426842
{
68436843
port_t *port;
68446844

@@ -6850,6 +6850,42 @@ int effects_monitor_output_parameter(int effect_id, const char *control_symbol_o
68506850

68516851
if (port != NULL)
68526852
{
6853+
if (enable == 0)
6854+
{
6855+
// check if not monitored
6856+
if ((port->hints & HINT_MONITORED) == 0)
6857+
return SUCCESS;
6858+
6859+
// remove monitored flag
6860+
port->hints &= ~HINT_MONITORED;
6861+
6862+
// stop postpone events thread
6863+
if (g_postevents_running == 1)
6864+
{
6865+
g_postevents_running = 0;
6866+
sem_post(&g_postevents_semaphore);
6867+
pthread_join(g_postevents_thread, NULL);
6868+
}
6869+
6870+
// flush events for all effects except this one
6871+
RunPostPonedEvents(effect_id);
6872+
6873+
// start thread again
6874+
if (g_postevents_running == 0)
6875+
{
6876+
if (g_verbose_debug)
6877+
{
6878+
puts("DEBUG: effects_monitor_output_parameter restarted RunPostPonedEvents thread");
6879+
fflush(stdout);
6880+
}
6881+
6882+
g_postevents_running = 1;
6883+
pthread_create(&g_postevents_thread, NULL, PostPonedEventsThread, NULL);
6884+
}
6885+
6886+
return SUCCESS;
6887+
}
6888+
68536889
// check if already monitored
68546890
if (port->hints & HINT_MONITORED)
68556891
return SUCCESS;
@@ -6882,7 +6918,7 @@ int effects_monitor_output_parameter(int effect_id, const char *control_symbol_o
68826918
if (property == NULL)
68836919
return ERR_LV2_INVALID_PARAM_SYMBOL;
68846920

6885-
property->monitored = true;
6921+
property->monitored = enable != 0;
68866922
}
68876923

68886924
// activate output monitor

src/effects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ int effects_flush_parameters(int effect_id, int reset, int param_count, const fl
155155
int effects_set_property(int effect_id, const char *uri, const char *value);
156156
int effects_get_property(int effect_id, const char *uri);
157157
int effects_monitor_parameter(int effect_id, const char *control_symbol, const char *op, float value);
158-
int effects_monitor_output_parameter(int effect_id, const char *control_symbol);
158+
int effects_monitor_output_parameter(int effect_id, const char *control_symbol, int enable);
159159
int effects_bypass(int effect_id, int value);
160160
int effects_get_parameter_symbols(int effect_id, int output_ports, const char** symbols);
161161
int effects_get_presets_uris(int effect_id, const char **uris);

src/mod-host.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,14 @@ static void monitor_addr_set_cb(proto_t *proto)
348348
static void monitor_output_cb(proto_t *proto)
349349
{
350350
int resp;
351-
resp = !effects_monitor_output_parameter(atoi(proto->list[1]), proto->list[2]);
351+
resp = !effects_monitor_output_parameter(atoi(proto->list[1]), proto->list[2], 1);
352+
protocol_response_int(resp, proto);
353+
}
354+
355+
static void monitor_output_off_cb(proto_t *proto)
356+
{
357+
int resp;
358+
resp = !effects_monitor_output_parameter(atoi(proto->list[1]), proto->list[2], 0);
352359
protocol_response_int(resp, proto);
353360
}
354361

@@ -768,6 +775,7 @@ static int mod_host_init(jack_client_t* client, int socket_port, int feedback_po
768775
protocol_add_command(EFFECT_SET_BPB, effects_set_beats_per_bar_cb);
769776
protocol_add_command(MONITOR_ADDR_SET, monitor_addr_set_cb);
770777
protocol_add_command(MONITOR_OUTPUT, monitor_output_cb);
778+
protocol_add_command(MONITOR_OUTPUT_OFF, monitor_output_off_cb);
771779
protocol_add_command(MONITOR_AUDIO_LEVELS, monitor_audio_levels_cb);
772780
protocol_add_command(MONITOR_MIDI_PROGRAM, monitor_midi_program_cb);
773781
protocol_add_command(MIDI_LEARN, midi_learn_cb);

src/mod-host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
#define EFFECT_SET_BPB "set_bpb %f"
7474
#define MONITOR_ADDR_SET "monitor %s %i %i"
7575
#define MONITOR_OUTPUT "monitor_output %i %s"
76+
#define MONITOR_OUTPUT_OFF "monitor_output_off %i %s"
7677
#define MONITOR_AUDIO_LEVELS "monitor_audio_levels %i %s"
7778
#define MONITOR_MIDI_PROGRAM "monitor_midi_program %i %i"
7879
#define MIDI_LEARN "midi_learn %i %s %f %f"

0 commit comments

Comments
 (0)