]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Add PA sink configuration option
authorMaciej Wilczynski <maciej@lupine.cc>
Sat, 15 Sep 2018 18:05:31 +0000 (20:05 +0200)
committerMaciej Wilczynski <maciej@lupine.cc>
Sat, 15 Sep 2018 18:49:11 +0000 (20:49 +0200)
audio_pa.c
common.h

index d8f8a9d323143a3073fdc060734bcf78ec1f371f..aec4d9922d029297c56c8e1bfece0b5b25043dfe 100644 (file)
@@ -85,6 +85,11 @@ static int init(__attribute__((unused)) int argc, __attribute__((unused)) char *
     if (config_lookup_string(config.cfg, "pa.application_name", &str)) {
       config.pa_application_name = (char *)str;
     }
+
+    /* Get the PulseAudio sink name. */
+    if (config_lookup_string(config.cfg, "pa.sink", &str)) {
+      config.pa_sink = (char *)str;
+    }
   }
 
   // finish collecting settings
@@ -178,8 +183,17 @@ static void start(__attribute__((unused)) int sample_rate,
                  //        PA_STREAM_AUTO_TIMING_UPDATE;
                  PA_STREAM_AUTO_TIMING_UPDATE | PA_STREAM_ADJUST_LATENCY;
 
-  // Connect stream to the default audio output sink
-  if (pa_stream_connect_playback(stream, NULL, &buffer_attr, stream_flags, NULL, NULL) != 0)
+  int connect_result;
+
+  if (config.pa_sink) {
+    // Connect stream to the sink specified in the config
+    connect_result = pa_stream_connect_playback(stream, config.pa_sink, &buffer_attr, stream_flags, NULL, NULL);
+  } else {
+    // Connect stream to the default audio output sink
+    connect_result = pa_stream_connect_playback(stream, NULL, &buffer_attr, stream_flags, NULL, NULL);
+  }
+  
+  if (connect_result != 0)
     die("could not connect to the pulseaudio playback stream -- the error message is \"%s\".",
         pa_strerror(pa_context_errno(context)));
 
index c25b166a077db073b5ba4975c4c5c719ebef6020..c5d03aa3ddf21c91b82de144d94f22b2109206e7 100644 (file)
--- a/common.h
+++ b/common.h
@@ -84,7 +84,9 @@ typedef struct {
 #ifdef CONFIG_PA
   char *pa_application_name; // the name under which Shairport Sync shows up as an "Application" in
                              // the Sound Preferences in most desktop Linuxes.
-// Defaults to "Shairport Sync". Shairport Sync must be playing to see it.
+                             // Defaults to "Shairport Sync". Shairport Sync must be playing to see it.
+
+  char *pa_sink;    // the name (or id) of the sink that Shairport Sync will play on.
 #endif
 #ifdef CONFIG_METADATA
   int metadata_enabled;