Add PA sink configuration option

This commit is contained in:
Maciej Wilczynski
2018-09-15 20:49:11 +02:00
parent fa3b50419a
commit 947a0ca291
2 changed files with 19 additions and 3 deletions
+16 -2
View 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)));