On Fri, Mar 23, 2012 at 1:47 AM, robs <aquegg@...> wrote:
> In fact, I had discovered this independently and implemented a local fix; here's what I've done:
>
> +static char const * try_device(char const * name)
> +{
> + sox_format_handler_t const * handler = sox_find_format(name, sox_false);
> + if (handler) {
> + sox_format_t format, * ft = &format;
> + memset(ft, 0, sizeof(*ft));
> + ft->filename = (char *)device_name(name);
> + ft->priv = lsx_calloc(1, handler->priv_size);
> + if (handler->startwrite(ft) == SOX_SUCCESS) {
> + handler->stopwrite(ft);
> + free(ft->priv);
> + return name;
> + }
> + free(ft->priv);
> + }
> + return NULL;
> +}
> +
> static char const * set_default_device(file_t * f)
> {
> /* Default audio driver type in order of preference: */
> if (!f->filetype) f->filetype = getenv("AUDIODRIVER");
> - if (!f->filetype && sox_find_format("coreaudio", sox_false)) f->filetype = "c
> - if (!f->filetype && sox_find_format("pulseaudio" , sox_false)) f->filetype =
> - if (!f->filetype && sox_find_format("alsa", sox_false)) f->filetype = "alsa";
> - if (!f->filetype && sox_find_format("waveaudio" , sox_false)) f->filetype = "
> - if (!f->filetype && sox_find_format("sndio", sox_false)) f->filetype = "sndio
> - if (!f->filetype && sox_find_format("oss" , sox_false)) f->filetype = "oss";
> - if (!f->filetype && sox_find_format("sunau",sox_false)) f->filetype = "sunau"
> - if (!f->filetype && sox_find_format("ao" , sox_false) && file_count) /*!rec*
> - f->filetype = "ao";
> + if (!f->filetype) f->filetype = try_device("coreaudio");
> + if (!f->filetype) f->filetype = try_device("pulseaudio");
> + if (!f->filetype) f->filetype = try_device("alsa");
> + if (!f->filetype) f->filetype = try_device("waveaudio");
> + if (!f->filetype) f->filetype = try_device("sndio");
> + if (!f->filetype) f->filetype = try_device("oss");
> + if (!f->filetype) f->filetype = try_device("sunau");
> + if (!f->filetype && file_count) /*!rec*/
> + f->filetype = try_device("ao");
>
> if (!f->filetype) {
> lsx_fail("Sorry, there is no default audio device configured");
>
> It works fine for pulse fallback to alsa, but might need a little more filling in of ft for other device handlers.
Hi Robs,
I've spent some time on SoX for Debian today and tested your patch.
It works fine for me so I pushed a new SoX package for Debian that includes it.
I notice that it not included upstream. Is there any reason?
Thanks,
-Pascal
--
Homepage (http://organact.mine.nu)
Debian GNU/Linux (http://www.debian.org)
COMunité/LACIME: École de technologie supérieure (http://www.comunite.ca)
Integrated Microsystems Laboratory: McGill (http://www.iml.ece.mcgill.ca)
|