From: Valentin Corfu Date: Tue, 11 Feb 2014 09:06:36 +0000 (-0500) Subject: jack: Allow to specify a client name as parameters X-Git-Tag: v1.0.28~4 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=14190cd8;p=alsa-plugins.git jack: Allow to specify a client name as parameters The current jack client name contains the process id of the application providing the audio samples. This leads to unpredictable jack client names which makes handling of the connections by a controlling application very hard. This modification now, allows to specify a client name as parameters in the configuration file. The implementation is backward compatible and simply adds a new configuration option to the plugin. [reformatted and small refactoring by tiwai] Signed-off-by: Valentin Corfu Signed-off-by: Takashi Iwai --- diff --git a/jack/pcm_jack.c b/jack/pcm_jack.c index c51fe84..4213708 100644 --- a/jack/pcm_jack.c +++ b/jack/pcm_jack.c @@ -356,9 +356,16 @@ static int snd_pcm_jack_open(snd_pcm_t **pcmp, const char *name, return -EINVAL; } - if (snprintf(jack_client_name, sizeof(jack_client_name), "alsa-jack.%s%s.%d.%d", name, - stream == SND_PCM_STREAM_PLAYBACK ? "P" : "C", getpid(), num++) - >= (int)sizeof(jack_client_name)) { + if (name == NULL) + err = snprintf(jack_client_name, sizeof(jack_client_name), + "alsa-jack.%s%s.%d.%d", name, + stream == SND_PCM_STREAM_PLAYBACK ? "P" : "C", + getpid(), num++); + else + err = snprintf(jack_client_name, sizeof(jack_client_name), + "%s", name); + + if (err >= (int)sizeof(jack_client_name)) { fprintf(stderr, "%s: WARNING: JACK client name '%s' truncated to %d characters, might not be unique\n", __func__, jack_client_name, (int)strlen(jack_client_name)); } @@ -369,7 +376,7 @@ static int snd_pcm_jack_open(snd_pcm_t **pcmp, const char *name, snd_pcm_jack_free(jack); return -ENOENT; } - + jack->areas = calloc(jack->channels, sizeof(snd_pcm_channel_area_t)); if (! jack->areas) { snd_pcm_jack_free(jack); @@ -423,6 +430,10 @@ SND_PCM_PLUGIN_DEFINE_FUNC(jack) continue; if (strcmp(id, "comment") == 0 || strcmp(id, "type") == 0 || strcmp(id, "hint") == 0) continue; + if (strcmp(id, "name") == 0) { + snd_config_get_string(n, &name); + continue; + } if (strcmp(id, "playback_ports") == 0) { if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) { SNDERR("Invalid type for %s", id);