From: Takashi Iwai Date: Fri, 18 Oct 2019 06:10:04 +0000 (+0200) Subject: pulse: Add DEVICE parameter X-Git-Tag: v1.2.1~1 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=b0f9c353c7cc9cffb77e7a7b00545ad00f4599fb;p=alsa-plugins.git pulse: Add DEVICE parameter Basically this patch adds the DEVICE parameter to pulse PCM and control plugins, so that users may pass the specific pulse device for multiple opens. Along with the addition of the DEVICE parameter in the config definition, the plugin code is slightly modified for allowing to receive the empty strings that are treated as the "default" mode (= NULL). Signed-off-by: Takashi Iwai --- diff --git a/pulse/50-pulseaudio.conf b/pulse/50-pulseaudio.conf index 62da207..ce0320a 100644 --- a/pulse/50-pulseaudio.conf +++ b/pulse/50-pulseaudio.conf @@ -1,7 +1,13 @@ # Add a specific named PulseAudio pcm and ctl (typically useful for testing) pcm.pulse { + @args [ DEVICE ] + @args.DEVICE { + type string + default "" + } type pulse + device $DEVICE hint { show { @func refer @@ -12,5 +18,11 @@ pcm.pulse { } ctl.pulse { + @args [ DEVICE ] + @args.DEVICE { + type string + default "" + } type pulse + device $DEVICE } diff --git a/pulse/ctl_pulse.c b/pulse/ctl_pulse.c index fbb6eae..9b820fd 100644 --- a/pulse/ctl_pulse.c +++ b/pulse/ctl_pulse.c @@ -664,6 +664,8 @@ SND_CTL_PLUGIN_DEFINE_FUNC(pulse) if (snd_config_get_string(n, &server) < 0) { SNDERR("Invalid type for %s", id); return -EINVAL; + } else if (!*server) { + server = NULL; } continue; } @@ -671,6 +673,8 @@ SND_CTL_PLUGIN_DEFINE_FUNC(pulse) if (snd_config_get_string(n, &device) < 0) { SNDERR("Invalid type for %s", id); return -EINVAL; + } else if (!*device) { + device = NULL; } continue; } @@ -678,6 +682,8 @@ SND_CTL_PLUGIN_DEFINE_FUNC(pulse) if (snd_config_get_string(n, &source) < 0) { SNDERR("Invalid type for %s", id); return -EINVAL; + } else if (!*source) { + source = NULL; } continue; } @@ -685,6 +691,8 @@ SND_CTL_PLUGIN_DEFINE_FUNC(pulse) if (snd_config_get_string(n, &sink) < 0) { SNDERR("Invalid type for %s", id); return -EINVAL; + } else if (!*sink) { + sink = NULL; } continue; } diff --git a/pulse/pcm_pulse.c b/pulse/pcm_pulse.c index 2831743..869c9b6 100644 --- a/pulse/pcm_pulse.c +++ b/pulse/pcm_pulse.c @@ -1069,6 +1069,8 @@ SND_PCM_PLUGIN_DEFINE_FUNC(pulse) if (snd_config_get_string(n, &server) < 0) { SNDERR("Invalid type for %s", id); return -EINVAL; + } else if (!*server) { + server = NULL; } continue; } @@ -1076,6 +1078,8 @@ SND_PCM_PLUGIN_DEFINE_FUNC(pulse) if (snd_config_get_string(n, &device) < 0) { SNDERR("Invalid type for %s", id); return -EINVAL; + } else if (!*device) { + device = NULL; } continue; } @@ -1091,6 +1095,8 @@ SND_PCM_PLUGIN_DEFINE_FUNC(pulse) if (snd_config_get_string(n, &fallback_name) < 0) { SNDERR("Invalid value for %s", id); return -EINVAL; + } else if (!*fallback_name) { + fallback_name = NULL; } continue; }