chiark / gitweb /
Support uniform audio command backend from disorder-playrtp. A useful
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 1 Mar 2009 17:45:15 +0000 (17:45 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sun, 1 Mar 2009 17:45:15 +0000 (17:45 +0000)
way to test it but potentially a useful feature too.

clients/playrtp.c
doc/disorder-playrtp.1.in

index f5103a30865c486a5b60f5c92525620d7e84b641..03e4ad2e297de1a3c10601f3c8c3c6418953a234 100644 (file)
@@ -216,6 +216,7 @@ static const struct option options[] = {
   { "core-audio", no_argument, 0, 'c' },
 #endif
   { "dump", required_argument, 0, 'r' },
+  { "command", required_argument, 0, 'e' },
   { "socket", required_argument, 0, 's' },
   { "config", required_argument, 0, 'C' },
   { 0, 0, 0, 0 }
@@ -491,6 +492,7 @@ static void help(void) {
 #if HAVE_COREAUDIO_AUDIOHARDWARE_H
           "  --core-audio, -c        Use Core Audio to play audio\n"
 #endif
+          "  --command, -e COMMAND   Pipe audio to command\n"
          "  --help, -h              Display usage message\n"
          "  --version, -V           Display version number\n"
           );
@@ -577,7 +579,6 @@ int main(int argc, char **argv) {
   };
   union any_sockaddr mgroup;
   const char *dumpfile = 0;
-  const char *device = 0;
   pthread_t ltid;
 
   static const struct addrinfo prefs = {
@@ -590,12 +591,12 @@ int main(int argc, char **argv) {
   mem_init();
   if(!setlocale(LC_CTYPE, "")) fatal(errno, "error calling setlocale");
   backend = uaudio_apis[0];
-  while((n = getopt_long(argc, argv, "hVdD:m:b:x:L:R:M:aocC:r", options, 0)) >= 0) {
+  while((n = getopt_long(argc, argv, "hVdD:m:b:x:L:R:M:aocC:re:", options, 0)) >= 0) {
     switch(n) {
     case 'h': help();
     case 'V': version("disorder-playrtp");
     case 'd': debugging = 1; break;
-    case 'D': device = optarg; break;
+    case 'D': uaudio_set("device", optarg); break;
     case 'm': minbuffer = 2 * atol(optarg); break;
     case 'b': readahead = 2 * atol(optarg); break;
     case 'x': maxbuffer = 2 * atol(optarg); break;
@@ -613,6 +614,7 @@ int main(int argc, char **argv) {
     case 'C': configfile = optarg; break;
     case 's': control_socket = optarg; break;
     case 'r': dumpfile = optarg; break;
+    case 'e': backend = &uaudio_command; uaudio_set("command", optarg); break;
     default: fatal(0, "invalid option");
     }
   }
@@ -742,9 +744,6 @@ int main(int argc, char **argv) {
       fatal(errno, "mapping %s", dumpfile);
     info("dumping to %s", dumpfile);
   }
-  /* Choose output device */
-  if(device)
-    uaudio_set("device", device);
   /* Set up output.  Currently we only support L16 so there's no harm setting
    * the format before we know what it is! */
   uaudio_set_format(44100/*Hz*/, 2/*channels*/,
index 440604ffae32f47bbf3a5690db58304ee440d6f3..ea4c93fe408f775e6487cd15e8a44aab19ffcb94 100644 (file)
@@ -40,14 +40,17 @@ multicast to that group address and port.
 The default sound API is the first of the ones listed below that are available.
 Usually this implies ALSA under Linux and Core Audio under OS X.
 .TP
-.B \-\-alsa\fR, \fB-\a
+.B \-\-alsa\fR, \fB\-a
 Use ALSA to play sound.
+Only available on Linux.
 .TP
 .B \-\-oss\fR, \fB\-o
 Use OSS to play sound.
+Only available on Linux and FreeBSD.
 .TP
 .B \-\-core\-audio\fR, \fB\-c
 Use Core Audio to play sound.
+Only available on Macs.
 .TP
 .B \-\-device \fIDEVICE\fR, \fB\-D \fIDEVICE\fR
 Specifies the audio device to use.
@@ -55,6 +58,23 @@ See
 .B "DEVICE NAMES"
 below for more information.
 .TP
+.B \-\-command \fICOMMAND\fR, \fB-e \fICOMMAND\fR
+Instead of sending to a physical audio device, invoke \fICOMMAND\fR using the
+shell and write audio samples to its standard input.
+Currently the input will be 44100KHz 16-bit signed stereo samples.
+If \fICOMMAND\fR exits it is re-executed; any samples that had been written to
+the pipe but not processed by the previous instance will be lost.
+.IP
+.B \-\-device
+is redundant with this option.
+.IP
+As an example,
+.B "-e \(aqcat > dump\(aq"
+would log audio data to a file for later processing.
+You could convert it to another format with, for instance:
+.IP
+.B "sox -c2 -traw -r44100 -s -w dump dump.wav"
+.TP
 .B \-\-config \fIPATH\fR, \fB\-C \fIPATH
 Set the configuration file.
 The default is