]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Allow to specify pulseaudio server instead of using default one. 988/head
authorGuillaume Revaillot <g.revaillot@ppp0.dev>
Thu, 26 Mar 2020 15:13:36 +0000 (16:13 +0100)
committerGuillaume Revaillot <g.revaillot@ppp0.dev>
Fri, 27 Mar 2020 08:39:11 +0000 (09:39 +0100)
Add "server" entry to pa config section, allowing to connect to a remote or a local system
pulseaudio instance instead of letting pulseaudio choose.

audio_pa.c
common.h
scripts/shairport-sync.conf

index e6a5b5767682a695719b681370c2f70f6ec3d499..951860beb8375533840572f2395ed143c824a20d 100644 (file)
@@ -85,6 +85,11 @@ static int init(__attribute__((unused)) int argc, __attribute__((unused)) char *
   if (config.cfg != NULL) {
     const char *str;
 
+    /* Get the PulseAudio server name. */
+    if (config_lookup_string(config.cfg, "pa.server", &str)) {
+      config.pa_server = (char *)str;
+    }
+
     /* Get the Application Name. */
     if (config_lookup_string(config.cfg, "pa.application_name", &str)) {
       config.pa_application_name = (char *)str;
@@ -126,7 +131,8 @@ static int init(__attribute__((unused)) int argc, __attribute__((unused)) char *
   // Start the mainloop
   if (pa_threaded_mainloop_start(mainloop) != 0)
     die("could not start the pulseaudio threaded mainloop");
-  if (pa_context_connect(context, NULL, 0, NULL) != 0)
+
+  if (pa_context_connect(context, config.pa_server, 0, NULL) != 0)
     die("failed to connect to the pulseaudio context -- the error message is \"%s\".",
         pa_strerror(pa_context_errno(context)));
 
index 95f4decce5e3a64435f165c677e89c743c3a2732..d5aad23027466af196162ada6bd68f225a7b9196 100644 (file)
--- a/common.h
+++ b/common.h
@@ -114,6 +114,7 @@ typedef struct {
                       // on host %h"
 
 #ifdef CONFIG_PA
+  char *pa_server; // the pulseaudio server address that Shairport Sync will play on.
   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.
index 170fafc2d4f2f2d6927905b0f3984672fa48db57..992c4b95331180dc83ca15d3eab9c8a33dcea45e 100644 (file)
@@ -118,6 +118,7 @@ sndio =
 // --with-pa
 pa =
 {
+//     server = "host"; // Set this to override the default pulseaudio server that should be used.
 //     application_name = "Shairport Sync"; //Set this to the name that should appear in the Sounds "Applications" tab when Shairport Sync is active.
 };