]> git.alsa-project.org Git - alsa-plugins.git/commitdiff
pulse: Add DEVICE parameter
authorTakashi Iwai <tiwai@suse.de>
Fri, 18 Oct 2019 06:10:04 +0000 (08:10 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 18 Oct 2019 06:13:59 +0000 (08:13 +0200)
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 <tiwai@suse.de>
pulse/50-pulseaudio.conf
pulse/ctl_pulse.c
pulse/pcm_pulse.c

index 62da207af9ca2b36b2d2ab78a99656f8506edf7c..ce0320a2f3da329476ec75282e5c840716d2cd2f 100644 (file)
@@ -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
 }
index fbb6eae2ec76f6f28c37195039e113cf4adca65b..9b820fd04b158a1ed2e74cb266e6ecf30f833c53 100644 (file)
@@ -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;
                }
index 283174357e8b2aa55076fd784c97aebb8b1b2bde..869c9b674c6b8d51fcc2d26eedc23612bb0aefde 100644 (file)
@@ -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;
                }