From 64b6f47e84fefd595e1972d41fe77ae62939b5d2 Mon Sep 17 00:00:00 2001 From: Paul Lietar Date: Wed, 19 Jun 2013 10:48:04 +0200 Subject: [PATCH] pulseaudio: Make the application name configurable If no name is specified, use the AirPlay access point name. --- audio_pulse.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/audio_pulse.c b/audio_pulse.c index e6e797fd..0fb06248 100644 --- a/audio_pulse.c +++ b/audio_pulse.c @@ -37,14 +37,18 @@ static pa_simple *pa_dev = NULL; static int pa_error; static const char *pa_server = NULL; static const char *pa_sink = NULL; +static const char *pa_appname = NULL; static void help(void) { printf(" -a server set the server name\n" " -s sink set the output sink\n" + " -n name set the application name, as seen by PulseAudio\n" + " defaults to the access point name\n" ); } static int init(int argc, char **argv) { + pa_appname = config.apname; optind = 1; // optind=0 is equivalent to optind=1 plus special behaviour argv--; // so we shift the arguments to satisfy getopt() @@ -53,7 +57,7 @@ static int init(int argc, char **argv) { // some platforms apparently require optreset = 1; - which? int opt; char *mid; - while ((opt = getopt(argc, argv, "a:s:")) > 0) { + while ((opt = getopt(argc, argv, "a:s:n:")) > 0) { switch (opt) { case 'a': pa_server = optarg; @@ -61,6 +65,9 @@ static int init(int argc, char **argv) { case 's': pa_sink = optarg; break; + case 'n': + pa_appname = optarg; + break; default: help(); die("Invalid audio option -%c specified", opt); @@ -84,10 +91,10 @@ static void start(int sample_rate) { }; pa_dev = pa_simple_new(pa_server, - "shairport", + pa_appname, PA_STREAM_PLAYBACK, pa_sink, - "shairport", + "Shairport Stream", &ss, NULL, NULL, &pa_error);