Skip to content

Commit

Permalink
add custom jack client names (mod-audio#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
fps committed Sep 19, 2022
1 parent 8719ba6 commit c9380e4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
11 changes: 9 additions & 2 deletions src/effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -4407,7 +4407,7 @@ int effects_finish(int close_client)
return SUCCESS;
}

int effects_add(const char *uri, int instance)
int effects_add(const char *uri, int instance, const char *jack_client_name)
{
unsigned int ports_count;
char effect_name[32], port_name[MAX_CHAR_BUF_SIZE+1];
Expand Down Expand Up @@ -4454,7 +4454,14 @@ int effects_add(const char *uri, int instance)
lilv_instance = NULL;

/* Create a client to Jack */
snprintf(effect_name, 31, "effect_%i", instance);
if (jack_client_name)
{
strncpy(effect_name, jack_client_name, 31);
}
else
{
snprintf(effect_name, 31, "effect_%i", instance);
}
jack_client = jack_client_open(effect_name, JackNoStartServer, &jack_status);

if (!jack_client)
Expand Down
2 changes: 1 addition & 1 deletion src/effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ typedef struct {

int effects_init(void* client);
int effects_finish(int close_client);
int effects_add(const char *uri, int instance);
int effects_add(const char *uri, int instance, const char *jack_client_name);
int effects_remove(int effect_id);
int effects_preset_load(int effect_id, const char *uri);
int effects_preset_save(int effect_id, const char *dir, const char *file_name, const char *label);
Expand Down
8 changes: 7 additions & 1 deletion src/mod-host.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,13 @@ static pthread_t intclient_socket_thread;
static void effects_add_cb(proto_t *proto)
{
int resp;
resp = effects_add(proto->list[1], atoi(proto->list[2]));
char *jack_client_name = NULL;
if (proto->list_count == 4)
{
jack_client_name = proto->list[3];
}
resp = effects_add(proto->list[1], atoi(proto->list[2]), jack_client_name);

protocol_response_int(resp, proto);
}

Expand Down
2 changes: 1 addition & 1 deletion src/mod-host.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#define SOCKET_MSG_BUFFER_SIZE 1024

/* Protocol commands definition */
#define EFFECT_ADD "add %s %i"
#define EFFECT_ADD "add %s %i ..."
#define EFFECT_REMOVE "remove %i"
#define EFFECT_PRESET_LOAD "preset_load %i %s"
#define EFFECT_PRESET_SAVE "preset_save %i %s %s %s"
Expand Down
2 changes: 1 addition & 1 deletion tests/effectlib_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main (void)
if (effects_init(NULL) == 0)
{
action = "add: http://lv2plug.in/plugins/eg-amp";
ret = effects_add("http://lv2plug.in/plugins/eg-amp", 0);
ret = effects_add("http://lv2plug.in/plugins/eg-amp", 0, NULL);
printf("%s, ret: %i\n", action, ret);

if (ret != 0)
Expand Down

0 comments on commit c9380e4

Please sign in to comment.