From 4cd3f5c399d7b47ea68418634b5e9d4ccc7ac395 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Wed, 20 May 2015 19:58:40 +0000 Subject: [PATCH] experiment with pipe backend. --- audio_pipe.c | 30 ++++++++++++++++++++++++++---- scripts/shairport-sync.conf | 7 +++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/audio_pipe.c b/audio_pipe.c index 367eb470..df54bbd4 100644 --- a/audio_pipe.c +++ b/audio_pipe.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "common.h" #include "audio.h" @@ -37,11 +38,14 @@ static int fd = -1; char *pipename = NULL; static void start(int sample_rate) { - fd = open(pipename, O_WRONLY); + debug(1,"Pipename to start is \"%s\"",pipename); + fd = open(pipename, O_WRONLY | O_NONBLOCK); + /* if (fd < 0) { perror("open"); die("could not open specified pipe for writing"); } + */ } static void play(short buf[], int samples) { @@ -53,10 +57,28 @@ static void stop(void) { } static int init(int argc, char **argv, config_t *cfgp) { - if (argc != 1) - die("bad argument(s) to pipe"); - pipename = strdup(argv[0]); + if (cfgp!=NULL) { + /* Get the Output Pipename. */ + const char *str; + if(config_lookup_string(cfgp, "pipe.name", &str)) { + pipename = (char*)str; + } + } + + + if ((pipename==NULL) && (argc != 1)) + die("bad or missing argument(s) to pipe"); + + if (argc==1) + pipename = strdup(argv[0]); + + // here, create the pipe + if (mkfifo(pipename, 0644) && errno != EEXIST) + die("Could not create metadata FIFO %s", pipename); + + + debug(1,"Pipename is \"%s\"",pipename); // test open pipe so we error on startup if it's going to fail start(44100); diff --git a/scripts/shairport-sync.conf b/scripts/shairport-sync.conf index 5ad07eb7..e4886b5b 100644 --- a/scripts/shairport-sync.conf +++ b/scripts/shairport-sync.conf @@ -42,6 +42,7 @@ sessioncontrol = // session_timeout = 120; }; +// These are parameters for the alsa back end, the only back end that currently works with shairport-sync alsa = { // output_device = "default"; @@ -50,3 +51,9 @@ alsa = // mixer_control_name = "PCM"; // the name of the mixer to use -- there is no default. }; +// These are parameters for the pipe back end, an experimental back end that directs output to a pipe. +pipe = +{ +// name = "/dev/null"; +}; +