I have made a patch.
This patch allows play(1) to determine audio device to use at run-time.
Actually, this patch changes behavior of set_device function.
What changes is:
* To use audio device only when it is available,
add this for each one.
if (sox_find_format("name", sox_false)) {
...
return;
}
* To try next device if previous one is unavailable,
replace
#elif
with
#endif
#if
After the patch applied,
play(1) works correctly while at least one of
libsox-fmt-alsa, libsox-fmt-ao or libsox-fmt-oss is installed.
I hope this helps.
--
Morita Sho <[EMAIL PROTECTED]>
--- sox-14.0.0/src/sox.c.orig 2007-09-07 05:47:20.000000000 +0900
+++ sox-14.0.0/src/sox.c 2008-01-13 18:11:06.000000000 +0900
@@ -372,25 +372,37 @@
{
#ifdef HAVE_LIBAO
if (!recording) {
- f->filetype = "ao";
+ if (sox_find_format("ao", sox_false)) {
+ f->filetype = "ao";
+ f->filename = xstrdup("default");
+ return;
+ }
+ }
+#endif
+#if defined(HAVE_ALSA)
+ if (sox_find_format("alsa", sox_false)) {
+ f->filetype = "alsa";
f->filename = xstrdup("default");
return;
}
#endif
-#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");
-#else
+#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
sox_fail("Sorry, there is no default audio device configured");
exit(1);
-#endif
}
static void set_replay_gain(char const * comment, file_t f)