[xiph-commits] r18766 - trunk/ao/src/plugins/pulse

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Tue Jan 15 12:09:04 PST 2013


Author: xiphmont
Date: 2013-01-15 12:09:04 -0800 (Tue, 15 Jan 2013)
New Revision: 18766

Modified:
   trunk/ao/src/plugins/pulse/ao_pulse.c
Log:
Commit slightly modified version of patch submitted for Trac #1924:
pulse plugin add client_name option



Modified: trunk/ao/src/plugins/pulse/ao_pulse.c
===================================================================
--- trunk/ao/src/plugins/pulse/ao_pulse.c	2013-01-15 15:20:14 UTC (rev 18765)
+++ trunk/ao/src/plugins/pulse/ao_pulse.c	2013-01-15 20:09:04 UTC (rev 18766)
@@ -49,7 +49,8 @@
     "verbose",
     "quiet",
     "matrix",
-    "debug"
+    "debug",
+    "client_name"
 };
 
 static ao_info ao_pulse_info = {
@@ -66,7 +67,7 @@
 
 typedef struct ao_pulse_internal {
     struct pa_simple *simple;
-    char *server, *sink;
+    char *server, *sink, *client_name;
 } ao_pulse_internal;
 
 /* Yes, this is very ugly, but required nonetheless... */
@@ -140,6 +141,7 @@
     internal->simple = NULL;
     internal->server = NULL;
     internal->sink = NULL;
+    internal->client_name = NULL;
 
     device->internal = internal;
     device->output_matrix_order = AO_OUTPUT_MATRIX_PERMUTABLE;
@@ -162,6 +164,9 @@
     } else if (!strcmp(key, "sink") || !strcmp(key, "dev") || !strcmp(key, "id")) {
         free(internal->sink);
         internal->sink = strdup(value);
+    } else if (!strcmp(key, "client_name")) {
+        free(internal->client_name);
+        internal->client_name = strdup(value);
     } else
         return 0;
 
@@ -198,25 +203,34 @@
 
     disable_sigpipe();
 
-    while (1) {
+    if (internal->client_name) {
+        snprintf(t, sizeof(t), "libao[%s]", internal->client_name);
+        snprintf(t2, sizeof(t2), "libao[%s] playback stream", internal->client_name);
+    } else {
+      while (1) {
         p = pa_xmalloc(allocated);
 
         if (!(fn = pa_get_binary_name(p, allocated))) {
-            break;
+          break;
         }
 
         if (fn != p || strlen(p) < allocated - 1) {
-            fn = pa_path_get_filename(fn);
-            snprintf(t, sizeof(t), "libao[%s]", fn);
-            snprintf(t2, sizeof(t2), "libao[%s] playback stream", fn);
-            break;
+          fn = pa_path_get_filename(fn);
+          snprintf(t, sizeof(t), "libao[%s]", fn);
+          snprintf(t2, sizeof(t2), "libao[%s] playback stream", fn);
+          break;
         }
 
         pa_xfree(p);
         allocated *= 2;
+      }
+      pa_xfree(p);
+      p = NULL;
+      if (!fn) {
+        strcpy(t, "libao");
+        strcpy(t2, "libao playback stream");
+      }
     }
-    pa_xfree(p);
-    p = NULL;
 
     if(device->input_map){
       int i;
@@ -232,8 +246,10 @@
       }
     }
 
-
-    if (!(internal->simple = pa_simple_new(internal->server, fn ? t : "libao", PA_STREAM_PLAYBACK, internal->sink, fn ? t2 : "libao playback stream", &ss, (device->input_map?&map:NULL), NULL, NULL)))
+    internal->simple = pa_simple_new(internal->server, t, PA_STREAM_PLAYBACK,
+                                     internal->sink, t2, &ss,
+                                     (device->input_map ? &map : NULL), NULL, NULL);
+    if (!internal->simple)
         return 0;
 
     device->driver_byte_format = AO_FMT_NATIVE;
@@ -270,6 +286,8 @@
       free(internal->server);
     if(internal->sink)
       free(internal->sink);
+    if(internal->client_name)
+      free(internal->client_name);
     free(internal);
     device->internal = NULL;
 }



More information about the commits mailing list