Skip to content

Commit c9380e4

Browse files
committed
add custom jack client names (mod-audio#31)
1 parent 8719ba6 commit c9380e4

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

src/effects.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4407,7 +4407,7 @@ int effects_finish(int close_client)
44074407
return SUCCESS;
44084408
}
44094409

4410-
int effects_add(const char *uri, int instance)
4410+
int effects_add(const char *uri, int instance, const char *jack_client_name)
44114411
{
44124412
unsigned int ports_count;
44134413
char effect_name[32], port_name[MAX_CHAR_BUF_SIZE+1];
@@ -4454,7 +4454,14 @@ int effects_add(const char *uri, int instance)
44544454
lilv_instance = NULL;
44554455

44564456
/* Create a client to Jack */
4457-
snprintf(effect_name, 31, "effect_%i", instance);
4457+
if (jack_client_name)
4458+
{
4459+
strncpy(effect_name, jack_client_name, 31);
4460+
}
4461+
else
4462+
{
4463+
snprintf(effect_name, 31, "effect_%i", instance);
4464+
}
44584465
jack_client = jack_client_open(effect_name, JackNoStartServer, &jack_status);
44594466

44604467
if (!jack_client)

src/effects.h

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

135135
int effects_init(void* client);
136136
int effects_finish(int close_client);
137-
int effects_add(const char *uri, int instance);
137+
int effects_add(const char *uri, int instance, const char *jack_client_name);
138138
int effects_remove(int effect_id);
139139
int effects_preset_load(int effect_id, const char *uri);
140140
int effects_preset_save(int effect_id, const char *dir, const char *file_name, const char *label);

src/mod-host.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,13 @@ static pthread_t intclient_socket_thread;
130130
static void effects_add_cb(proto_t *proto)
131131
{
132132
int resp;
133-
resp = effects_add(proto->list[1], atoi(proto->list[2]));
133+
char *jack_client_name = NULL;
134+
if (proto->list_count == 4)
135+
{
136+
jack_client_name = proto->list[3];
137+
}
138+
resp = effects_add(proto->list[1], atoi(proto->list[2]), jack_client_name);
139+
134140
protocol_response_int(resp, proto);
135141
}
136142

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_PRESET_LOAD "preset_load %i %s"
5757
#define EFFECT_PRESET_SAVE "preset_save %i %s %s %s"

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)