ref: 531c646d192d9a2173cc2e649fc83f75d1799d3e
parent: c255b1194c22edcd085d13410620f0b363e97df8
author: Ron <[email protected]>
date: Fri Jun 28 21:37:46 EDT 2013
Tweak the sound driver detection tests Test for the available possibilities in the code in the same order that we use when including the headers. This ensures that BSDs which test positive for both sndio and oss compat won't include the headers for one and the code for the other. The sndio support was added in commit 064bb2176518117531e0032747128761a19e5439, but only preferred sndio when including the headers. Enable the OSS code for all the possible HAVE_*_SOUNDCARD_H options. A more comprehensive test and additional macros were added in commit a0c500527daa6a8638eabac382810b1c42f442a2, but only to include the headers, not to also enable the relevant code.
--- a/src/opusdec.c
+++ b/src/opusdec.c
@@ -284,7 +284,33 @@
/*Open output file*/
if (strlen(outFile)==0)
{
-#if defined HAVE_SYS_SOUNDCARD_H
+#if defined HAVE_LIBSNDIO
+ struct sio_par par;
+
+ hdl = sio_open(NULL, SIO_PLAY, 0);
+ if (!hdl)
+ {
+ fprintf(stderr, "Cannot open sndio device\n");
+ quit(1);
+ }
+
+ sio_initpar(&par);
+ par.sig = 1;
+ par.bits = 16;
+ par.rate = rate;
+ par.pchan = *channels;
+
+ if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par) ||
+ par.sig != 1 || par.bits != 16 || par.rate != rate) {
+ fprintf(stderr, "could not set sndio parameters\n");
+ quit(1);
+ }
+ *channels = par.pchan;
+ if (!sio_start(hdl)) {
+ fprintf(stderr, "could not start sndio\n");
+ quit(1);
+ }
+#elif defined HAVE_SYS_SOUNDCARD_H || defined HAVE_MACHINE_SOUNDCARD_H || HAVE_SOUNDCARD_H
int audio_fd, format, stereo;
audio_fd=open("/dev/dsp", O_WRONLY);
if (audio_fd<0)
@@ -339,32 +365,6 @@
{
perror("Cannot open output");
quit(1);
- }
-#elif defined HAVE_LIBSNDIO
- struct sio_par par;
-
- hdl = sio_open(NULL, SIO_PLAY, 0);
- if (!hdl)
- {
- fprintf(stderr, "Cannot open sndio device\n");
- quit(1);
- }
-
- sio_initpar(&par);
- par.sig = 1;
- par.bits = 16;
- par.rate = rate;
- par.pchan = *channels;
-
- if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par) ||
- par.sig != 1 || par.bits != 16 || par.rate != rate) {
- fprintf(stderr, "could not set sndio parameters\n");
- quit(1);
- }
- *channels = par.pchan;
- if (!sio_start(hdl)) {
- fprintf(stderr, "could not start sndio\n");
- quit(1);
}
#elif defined HAVE_SYS_AUDIOIO_H
audio_info_t info;