chiark / gitweb /
New configuration option sox_generation to choose between different
authorrjk@greenend.org.uk <>
Tue, 10 Jul 2007 21:53:42 +0000 (22:53 +0100)
committerrjk@greenend.org.uk <>
Tue, 10 Jul 2007 21:53:42 +0000 (22:53 +0100)
sox syntaxes.

configure.ac
doc/disorder_config.5.in
lib/configuration.c
lib/configuration.h
server/speaker.c

index 6a393e57cf39815eccb84ae64b8f1af2f3e13c6d..7bf4ebfe676c8222c138081a703350987e195bb2 100644 (file)
@@ -199,6 +199,7 @@ fi
 AC_C_CONST
 AC_TYPE_SIZE_T
 AC_C_INLINE
+AC_C_BIGENDIAN
 AC_CHECK_TYPES([struct sockaddr_in6],,,[AC_INCLUDES_DEFAULT
 #include <netinet/in.h>])
 
index 29af21e6e84bbea1266dc67c5142196fe6ccb36b..8a03b4985db14317cad3ac6edf4d26abb9550904 100644 (file)
@@ -323,6 +323,11 @@ scratched.  The default is \fBSIGKILL\fR.
 Signals are specified by their full C name, i.e. \fBSIGINT\fR and not \fBINT\fR
 or \fBInterrupted\fR or whatever.
 .TP
+.B sox_generation \fB0\fR|\fB1
+Determines whether calls to \fBsox\fR(1) should use \fB-b\fR, \fB-x\fR, etc (if
+the generation is 0) or \fB-\fIbits\fR, \fB-L\fR etc (if it is 1).  The default
+is 0.
+.TP
 .B speaker_command \fICOMMAND
 Causes the speaker subprocess to pipe audio data into shell command
 \fICOMMAND\fR, rather than writing to a local sound card.  The sample format is
index 99e6d40c7c6bc327f2a31f0744b12b139eb7ce67..0282630d9ed7133c291ea2d6e89286ed3776c725 100644 (file)
@@ -754,6 +754,7 @@ static const struct conf conf[] = {
   { C(sample_format),    &type_sample_format,    validate_sample_format },
   { C(scratch),          &type_string_accum,     validate_isreg },
   { C(signal),           &type_signal,           validate_any },
+  { C(sox_generation),   &type_integer,          validate_non_negative },
   { C(speaker_command),  &type_string,           validate_any },
   { C(stopword),         &type_string_accum,     validate_any },
   { C(templates),        &type_string_accum,     validate_isdir },
index 75e066c43f3913e7a159fb0d90aa495db644195b..dbdb65b651d45cbb23f4be70dfd286df56826f5d 100644 (file)
@@ -101,6 +101,7 @@ struct config {
   long nice_speaker;                   /* nice value for speaker */
   const char *speaker_command;         /* command for speaker to run */
   ao_sample_format sample_format;      /* sample format to enforce */
+  long sox_generation;                 /* sox syntax generation */
   /* shared client/server config */
   const char *home;                    /* home directory for state files */
   /* client config */
index 2d4c6eaa487b0aa4ad57964aaa734eb9e8d8f454..055b08a7d7f3fd53aa57bfef1fb75bc67f7d392b 100644 (file)
 #include <alsa/asoundlib.h>
 #endif
 
+#ifdef WORDS_BIGENDIAN
+# define MACHINE_AO_FMT AO_FMT_BIG
+#else
+# define MACHINE_AO_FMT AO_FMT_LITTLE
+#endif
+
 #define BUFFER_SECONDS 5                /* How many seconds of input to
                                          * buffer. */
 
@@ -300,20 +306,39 @@ static void log_params(snd_pcm_hw_params_t *hwparams,
 }
 #endif
 
-static void soxargs(const char ***pp, char **qq, ao_sample_format *ao)
-{
+static void soxargs(const char ***pp, char **qq, ao_sample_format *ao) {
   int n;
 
   *(*pp)++ = "-t.raw";
   *(*pp)++ = "-s";
   *(*pp)++ = *qq; n = sprintf(*qq, "-r%d", ao->rate); *qq += n + 1;
-  switch(ao->byte_format) {
+  *(*pp)++ = *qq; n = sprintf(*qq, "-c%d", ao->channels); *qq += n + 1;
+  /* sox 12.17.9 insists on -b etc; CVS sox insists on -<n> etc; both are
+   * deployed! */
+  switch(config->sox_generation) {
+  case 0:
+    if(ao->bits != 8
+       && ao->byte_format != AO_FMT_NATIVE
+       && ao->byte_format != MACHINE_AO_FMT) {
+      *(*pp)++ = "-x";
+    }
+    switch(ao->bits) {
+    case 8: *(*pp)++ = "-b"; break;
+    case 16: *(*pp)++ = "-w"; break;
+    case 32: *(*pp)++ = "-l"; break;
+    case 64: *(*pp)++ = "-d"; break;
+    default: fatal(0, "cannot handle sample size %d", (int)ao->bits);
+    }
+    break;
+  case 1:
+    switch(ao->byte_format) {
     case AO_FMT_NATIVE: break;
     case AO_FMT_BIG: *(*pp)++ = "-B"; break;
     case AO_FMT_LITTLE: *(*pp)++ = "-L"; break;
+    }
+    *(*pp)++ = *qq; n = sprintf(*qq, "-%d", ao->bits/8); *qq += n + 1;
+    break;
   }
-  *(*pp)++ = *qq; n = sprintf(*qq, "-%d", ao->bits/8); *qq += n + 1;
-  *(*pp)++ = *qq; n = sprintf(*qq, "-c%d", ao->channels); *qq += n + 1;
 }
 
 /* Make sure the sound device is open and has the right sample format.  Return