ref: a5e16714a074879a88755d6fd17836e19d42eca1
parent: a47fa363333f286d6039f0aebc782ef46d059ab7
author: cbagwell <cbagwell>
date: Fri Jan 11 22:57:12 EST 2008
Allow user to specify libao plugin to use. Demote priority of libao driver until it works with at least Fedora+Pulseaudio.
--- a/soxformat.7
+++ b/soxformat.7
@@ -148,9 +148,14 @@
.EE
to see if you have support for this file type. It works only for
playing audio files. It can play to a wide range of devices and sound
-systems. See its documentation for the full range. At the moment SoX's
+systems. See its documentation for the full range. For the most part, SoX's
use of libao cannot be configured directly; you must use libao
configuration files.
+.SP
+The filename specified is used to determine which libao plugin to
+us. Normally, you should specify "default" as the filename. If that
+doesn't give the desired behavior then you can specify the short name
+for a given plugin (such as pulse for pulse audio plugin).
.TP
\&\fB.au\fR, \fB.snd\fR \fB(also with \-t sndfile)\fR
Sun Microsystems AU files.
--- a/src/ao.c
+++ b/src/ao.c
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <ao/ao.h>
typedef struct ao_priv
@@ -41,10 +42,20 @@
ao_priv_t ao = (ao_priv_t)ft->priv;
ao_initialize();
- if ((ao->driver_id = ao_default_driver_id()) < 0) {
- sox_fail("Could not find a default driver");
- return SOX_EOF;
+ if (strcmp(ft->filename,"default") == 0)
+ {
+ if ((ao->driver_id = ao_default_driver_id()) < 0) {
+ sox_fail("Could not find a default ao driver");
+ return SOX_EOF;
+ }
}
+ else
+ {
+ if ((ao->driver_id = ao_driver_id(ft->filename)) < 0) {
+ sox_fail("Could not find a ao driver %s", ft->filename);
+ return SOX_EOF;
+ }
+ }
ao->format.bits = SOX_SAMPLE_BITS;
ao->format.rate = ft->signal.rate;
@@ -51,7 +62,7 @@
ao->format.channels = ft->signal.channels;
ao->format.byte_format = AO_FMT_NATIVE;
if ((ao->device = ao_open_live(ao->driver_id, &ao->format, NULL)) == NULL) {
- sox_fail("Could not open default device: error %d", errno);
+ sox_fail("Could not open device: error %d", errno);
return SOX_EOF;
}
--- a/src/sox.c
+++ b/src/sox.c
@@ -370,13 +370,6 @@
static void set_device(file_t f, sox_bool recording UNUSED)
{
-#ifdef HAVE_LIBAO
- if (!recording) {
- f->filetype = "ao";
- f->filename = xstrdup("default");
- return;
- }
-#endif
#if defined(HAVE_ALSA)
f->filetype = "alsa";
f->filename = xstrdup("default");
@@ -387,6 +380,11 @@
char *device = getenv("AUDIODEV");
f->filetype = "sunau";
f->filename = xstrdup(device ? device : "/dev/audio");
+#elif HAVE_LIBAO
+ if (!recording) {
+ f->filetype = "ao";
+ f->filename = xstrdup("default");
+ }
#else
sox_fail("Sorry, there is no default audio device configured");
exit(1);