Skip to content

Commit

Permalink
Implement disconnect_all command
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed Oct 12, 2024
1 parent fae0c49 commit 09264f9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ The commands supported by mod-host are:
* disconnect two jack ports
e.g.: disconnect "system:capture_1" "effect_0:in"

disconnect_all <origin_port>
* disconnect all connections of a jack port
e.g.: disconnect_all "effect_0:in"

bypass <instance_number> <bypass_value>
* toggle effect processing
e.g.: bypass 0 1
Expand Down
10 changes: 10 additions & 0 deletions src/effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -6130,6 +6130,16 @@ int effects_disconnect(const char *portA, const char *portB)
return ret;
}

int effects_disconnect_all(const char *port)
{
int ret;

ret = jack_port_disconnect(g_jack_global_client, jack_port_by_name(g_jack_global_client, port));
if (ret != 0) return ERR_JACK_PORT_DISCONNECTION;

return ret;
}

int effects_set_parameter(int effect_id, const char *control_symbol, float value)
{
port_t *port;
Expand Down
1 change: 1 addition & 0 deletions src/effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ int effects_preset_save(int effect_id, const char *dir, const char *file_name, c
int effects_preset_show(const char *uri, char **state_str);
int effects_connect(const char *portA, const char *portB);
int effects_disconnect(const char *portA, const char *portB);
int effects_disconnect_all(const char *port);
int effects_set_parameter(int effect_id, const char *control_symbol, float value);
int effects_get_parameter(int effect_id, const char *control_symbol, float *value);
int effects_set_property(int effect_id, const char *uri, const char *value);
Expand Down
8 changes: 8 additions & 0 deletions src/mod-host.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ static void effects_disconnect_cb(proto_t *proto)
protocol_response_int(resp, proto);
}

static void effects_disconnect_all_cb(proto_t *proto)
{
int resp;
resp = effects_disconnect_all(proto->list[1]);
protocol_response_int(resp, proto);
}

static void effects_bypass_cb(proto_t *proto)
{
int resp;
Expand Down Expand Up @@ -695,6 +702,7 @@ static int mod_host_init(jack_client_t* client, int socket_port, int feedback_po
protocol_add_command(EFFECT_PRESET_SHOW, effects_preset_show_cb);
protocol_add_command(EFFECT_CONNECT, effects_connect_cb);
protocol_add_command(EFFECT_DISCONNECT, effects_disconnect_cb);
protocol_add_command(EFFECT_DISCONNECT_ALL, effects_disconnect_all_cb);
protocol_add_command(EFFECT_BYPASS, effects_bypass_cb);
protocol_add_command(EFFECT_PARAM_SET, effects_set_param_cb);
protocol_add_command(EFFECT_PARAM_GET, effects_get_param_cb);
Expand Down
1 change: 1 addition & 0 deletions src/mod-host.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#define EFFECT_PRESET_SHOW "preset_show %s"
#define EFFECT_CONNECT "connect %s %s"
#define EFFECT_DISCONNECT "disconnect %s %s"
#define EFFECT_DISCONNECT_ALL "disconnect_all %s"
#define EFFECT_BYPASS "bypass %i %i"
#define EFFECT_PARAM_SET "param_set %i %s %s"
#define EFFECT_PARAM_GET "param_get %i %s"
Expand Down

0 comments on commit 09264f9

Please sign in to comment.