changeset 24921:148ca265fcb6

Change parsing to allow host == NULL and sink != NULL
author reimar
date Sat, 03 Nov 2007 10:42:23 +0000
parents 12dc34b2e41c
children 7050d3a8e46c
files libao2/ao_pulse.c
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libao2/ao_pulse.c	Sat Nov 03 10:37:22 2007 +0000
+++ b/libao2/ao_pulse.c	Sat Nov 03 10:42:23 2007 +0000
@@ -122,13 +122,15 @@
     struct pa_sample_spec ss;
     struct pa_channel_map map;
     const struct format_map_s *fmt_map;
+    char *devarg = NULL;
     char *host = NULL;
     char *sink = NULL;
 
     if (ao_subdevice) {
-        host = strdup(ao_subdevice);
-        sink = strchr(host, ':');
+        devarg = strdup(ao_subdevice);
+        sink = strchr(devarg, ':');
         if (sink) *sink++ = 0;
+        if (devarg[0]) host = devarg;
     }
 
     ss.channels = channels;
@@ -202,7 +204,7 @@
 
     pa_threaded_mainloop_unlock(mainloop);
 
-    free(host);
+    free(devarg);
     return 1;
 
 unlock_and_fail:
@@ -213,7 +215,7 @@
 fail:
     if (context)
         GENERIC_ERR_MSG(context, "Init failed");
-    free(host);
+    free(devarg);
     uninit(1);
     return 0;
 }