Skip to content

Commit

Permalink
experiment with pipe backend.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebrady committed May 20, 2015
1 parent 744214d commit 4cd3f5c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
30 changes: 26 additions & 4 deletions audio_pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <fcntl.h>
#include <memory.h>
#include <stdlib.h>
#include <errno.h>
#include "common.h"
#include "audio.h"

Expand All @@ -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) {
Expand All @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions scripts/shairport-sync.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
};

0 comments on commit 4cd3f5c

Please sign in to comment.