Skip to content

Commit 3d03ed2

Browse files
committed
add custom jack client names (mod-audio#31)
1 parent 4077a55 commit 3d03ed2

5 files changed

Lines changed: 22 additions & 9 deletions

File tree

src/effects.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5028,7 +5028,7 @@ int effects_finish(int close_client)
50285028
return SUCCESS;
50295029
}
50305030

5031-
int effects_add(const char *uri, int instance, int activate)
5031+
int effects_add(const char *uri, int instance, const char *jack_client_name, int activate)
50325032
{
50335033
unsigned int ports_count;
50345034
char effect_name[32], port_name[MAX_CHAR_BUF_SIZE+1];
@@ -5076,7 +5076,14 @@ int effects_add(const char *uri, int instance, int activate)
50765076
lilv_instance = NULL;
50775077

50785078
/* Create a client to Jack */
5079-
snprintf(effect_name, 31, "effect_%i", instance);
5079+
if (jack_client_name)
5080+
{
5081+
strncpy(effect_name, jack_client_name, 31);
5082+
}
5083+
else
5084+
{
5085+
snprintf(effect_name, 31, "effect_%i", instance);
5086+
}
50805087
jack_client = jack_client_open(effect_name, JackNoStartServer, &jack_status);
50815088

50825089
if (!jack_client)
@@ -5982,10 +5989,10 @@ int effects_add_multi(int activate, int num_effects, int *effects, const char *c
59825989
return ERR_INVALID_OPERATION;
59835990

59845991
if (num_effects == 1)
5985-
return effects_add(*uris, *effects, activate);
5992+
return effects_add(*uris, *effects, 0, activate);
59865993

59875994
for (int i = 0; i < num_effects; ++i)
5988-
effects_add(uris[i], effects[i], activate);
5995+
effects_add(uris[i], effects[i], 0, activate);
59895996

59905997
return SUCCESS;
59915998
}

src/effects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ typedef struct {
142142

143143
int effects_init(void* client);
144144
int effects_finish(int close_client);
145-
int effects_add(const char *uri, int instance, int activate);
145+
int effects_add(const char *uri, int instance, const char *jack_client_name, int activate);
146146
int effects_add_multi(int activate, int num_effects, int *effects, const char *const *uris);
147147
int effects_remove(int effect_id);
148148
int effects_remove_multi(int num_effects, int *effects);

src/mod-host.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,13 @@ static ZixThread intclient_socket_thread;
138138
static void effects_add_cb(proto_t *proto)
139139
{
140140
int resp;
141-
resp = effects_add(proto->list[1], atoi(proto->list[2]), 1);
141+
char *jack_client_name = NULL;
142+
if (proto->list_count == 4)
143+
{
144+
jack_client_name = proto->list[3];
145+
}
146+
resp = effects_add(proto->list[1], atoi(proto->list[2]), jack_client_name, 1);
147+
142148
protocol_response_int(resp, proto);
143149
}
144150

@@ -159,7 +165,7 @@ static void effects_activate_cb(proto_t *proto)
159165
static void effects_preload_cb(proto_t *proto)
160166
{
161167
int resp;
162-
resp = effects_add(proto->list[1], atoi(proto->list[2]), 0);
168+
resp = effects_add(proto->list[1], atoi(proto->list[2]), 0, 0);
163169
protocol_response_int(resp, proto);
164170
}
165171

src/mod-host.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
#define SOCKET_MSG_BUFFER_SIZE 1024
5252

5353
/* Protocol commands definition */
54-
#define EFFECT_ADD "add %s %i"
54+
#define EFFECT_ADD "add %s %i ..."
5555
#define EFFECT_REMOVE "remove %i"
5656
#define EFFECT_ACTIVATE "activate %i %i"
5757
#define EFFECT_PRELOAD "preload %s %i"

tests/effectlib_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ int main (void)
1414
if (effects_init(NULL) == 0)
1515
{
1616
action = "add: http://lv2plug.in/plugins/eg-amp";
17-
ret = effects_add("http://lv2plug.in/plugins/eg-amp", 0);
17+
ret = effects_add("http://lv2plug.in/plugins/eg-amp", 0, NULL);
1818
printf("%s, ret: %i\n", action, ret);
1919

2020
if (ret != 0)

0 commit comments

Comments
 (0)