From 540d7716483190502ee21505727cc6f99a2868f5 Mon Sep 17 00:00:00 2001 From: Wolfgang Scherer Date: Sun, 5 Nov 2017 05:59:56 +0100 Subject: [PATCH] [pulseaudio] allow specification of pulseaudio server --- forked-daapd.conf.in | 6 ++++++ src/conffile.c | 1 + src/outputs/pulse.c | 7 +++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/forked-daapd.conf.in b/forked-daapd.conf.in index 95e89a15..4305f68a 100644 --- a/forked-daapd.conf.in +++ b/forked-daapd.conf.in @@ -177,6 +177,12 @@ audio { # Type of the output (alsa, pulseaudio, dummy or disabled) # type = "alsa" + # For pulseaudio output, an optional server can be specified. + # See http://billauer.co.il/blog/2014/01/pa-multiple-users/ + # for an example how to set up access to the daemon started + # by a logged-in user. +# server = "localhost" + # Audio PCM device name for local audio output - ALSA only # card = "default" diff --git a/src/conffile.c b/src/conffile.c index f5bc7885..0db89299 100644 --- a/src/conffile.c +++ b/src/conffile.c @@ -104,6 +104,7 @@ static cfg_opt_t sec_audio[] = { CFG_STR("nickname", "Computer", CFGF_NONE), CFG_STR("type", NULL, CFGF_NONE), + CFG_STR("server", NULL, CFGF_NONE), CFG_STR("card", "default", CFGF_NONE), CFG_STR("mixer", NULL, CFGF_NONE), CFG_STR("mixer_device", NULL, CFGF_NONE), diff --git a/src/outputs/pulse.c b/src/outputs/pulse.c index b41a27ab..86e23cea 100644 --- a/src/outputs/pulse.c +++ b/src/outputs/pulse.c @@ -891,6 +891,7 @@ static int pulse_init(void) { char *type; + char *server; int state; int ret; @@ -898,6 +899,8 @@ pulse_init(void) if (type && (strcasecmp(type, "pulseaudio") != 0)) return -1; + server = cfg_getstr(cfg_getsec(cfg, "audio"), "server"); + ret = 0; if (!(pulse.mainloop = pa_threaded_mainloop_new())) @@ -914,8 +917,8 @@ pulse_init(void) goto fail; pa_context_set_state_callback(pulse.context, context_state_cb, NULL); - - if (pa_context_connect(pulse.context, NULL, 0, NULL) < 0) + + if (pa_context_connect(pulse.context, server, 0, NULL) < 0) { ret = pa_context_errno(pulse.context); goto fail;