shithub: sox

Download patch

ref: 301fd25e93c7bfce542242a434dd35fd32a35346
parent: 7e2970263047d11aa33cc6bf37811d29c5247966
author: cbagwell <cbagwell>
date: Tue Jan 15 10:08:54 EST 2008

Applying a debian patch that helped audio device detection when no libao.

--- a/src/sox.c
+++ b/src/sox.c
@@ -371,24 +371,42 @@
 static void set_device(file_t f, sox_bool recording UNUSED)
 {
 #if defined(HAVE_ALSA)
-  f->filetype = "alsa";
-  f->filename = xstrdup("default");
-#elif defined(HAVE_SYS_SOUNDCARD_H) || defined(HAVE_MACHINE_SOUNDCARD_H)
-  f->filetype = "ossdsp";
-  f->filename = xstrdup("/dev/dsp");
-#elif defined(HAVE_SYS_AUDIOIO_H) || defined(HAVE_SUN_AUDIOIO_H)
-  char *device = getenv("AUDIODEV");
-  f->filetype = "sunau";
-  f->filename = xstrdup(device ? device : "/dev/audio");
-#elif HAVE_LIBAO
-  if (!recording) {
-    f->filetype = "ao";
+  if (sox_find_format("alsa", sox_false))
+  {
+    f->filetype = "alsa";
     f->filename = xstrdup("default");
+    return;
   }
-#else
+#endif
+#if defined(HAVE_SYS_SOUNDCARD_H) || defined(HAVE_MACHINE_SOUNDCARD_H)
+  if (sox_find_format("ossdsp", sox_false))
+  {
+    f->filetype = "ossdsp";
+    f->filename = xstrdup("/dev/dsp");
+    return;
+  }
+#endif
+#if defined(HAVE_SYS_AUDIOIO_H) || defined(HAVE_SUN_AUDIOIO_H)
+  if (sox_find_format("sunau", sox_false))
+  {
+    char *device = getenv("AUDIODEV");
+    f->filetype = "sunau";
+    f->filename = xstrdup(device ? device : "/dev/audio");
+    return;
+  }
+#endif
+#ifdef HAVE_LIBAO
+  if (!recording) {
+    if (sox_find_format("ao", sox_false))
+    {
+        f->filetype = "ao";
+        f->filename = xstrdup("default");
+        return;
+    }
+  }
+#endif
   sox_fail("Sorry, there is no default audio device configured");
   exit(1);
-#endif
 }
 
 static void set_replay_gain(char const * comment, file_t f)