chiark / gitweb /
New disorder-choose program for performing random selection.
[disorder] / server / speaker-command.c
index 8a8f63cbbf21ad3e16b440d1f80ddcd80a939be5..27b26647a0e9c61aa4f92db7328c80d06be52ef9 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * This file is part of DisOrder
  * Copyright (C) 2005, 2006, 2007 Richard Kettlewell
+ * Portions (C) 2007 Mark Wooding
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,6 +26,7 @@
 
 #include <unistd.h>
 #include <poll.h>
+#include <errno.h>
 
 #include "configuration.h"
 #include "syscalls.h"
@@ -52,6 +54,7 @@ static void fork_cmd(void) {
   xpipe(pfd);
   cmdpid = xfork();
   if(!cmdpid) {
+    exitfn = _exit;
     signal(SIGPIPE, SIG_DFL);
     xdup2(pfd[0], 0);
     close(pfd[0]);
@@ -72,7 +75,7 @@ static void command_init(void) {
 
 /** @brief Play to a subprocess */
 static size_t command_play(size_t frames) {
-  size_t bytes = frames * device_bpf;
+  size_t bytes = frames * bpf;
   int written_bytes;
 
   written_bytes = write(cmdfd, playing->buffer + playing->start, bytes);
@@ -90,11 +93,11 @@ static size_t command_play(size_t frames) {
       fatal(errno, "error writing to subprocess");
     }
   } else
-    return written_bytes / device_bpf;
+    return written_bytes / bpf;
 }
 
 /** @brief Update poll array for writing to subprocess */
-static void command_beforepoll(void) {
+static void command_beforepoll(int attribute((unused)) *timeoutp) {
   /* We send sample data to the subprocess as fast as it can accept it.
    * This isn't ideal as pause latency can be very high as a result. */
   if(cmdfd >= 0)
@@ -111,7 +114,7 @@ static int command_ready(void) {
 
 const struct speaker_backend command_backend = {
   BACKEND_COMMAND,
-  FIXED_FORMAT,
+  0,
   command_init,
   0,                                    /* activate */
   command_play,