[xiph-cvs] cvs commit: ao/src/plugins/oss ao_oss.c
Stan Seibert
volsung at xiph.org
Mon Oct 15 17:13:47 PDT 2001
volsung 01/10/15 17:13:47
Modified: . README configure.in
src/plugins/oss ao_oss.c
Log:
Compromise on the blocking open() call with certain OSS drivers. The
workaround is now turned off by default. If the --enable-broken-oss
option is passed to configure or if ALSA is detected, the workaround is
turned on during compilation. This will resolve bug 48.
Revision Changes Path
1.6 +12 -0 ao/README
Index: README
===================================================================
RCS file: /usr/local/cvsroot/ao/README,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- README 2001/08/11 21:43:31 1.5
+++ README 2001/10/16 00:13:46 1.6
@@ -51,3 +51,15 @@
This code is being maintained by Stan Seibert (indigo at aztec.asu.edu)
and various other individuals. Please DO NOT annoy Aaron Holtzman about
bugs, features, comments, etc. regarding this code.
+
+WORKAROUNDS
+
+The OSS emulation in ALSA deviates from the OSS spec by not returning
+immediately from an open() call if the OSS device is already in use.
+Instead, it makes the application wait until the device is available.
+This is not desirable during the autodetection phase of libao, so a
+workaround has been included in the source. Since the workaround
+itself violates the OSS spec and causes other problems on some
+platforms, it is only enabled when ALSA is detected. The workaround
+can be turned on or off by passing the --enable-broken-oss or
+--disable-broken-oss flag to the configure script.
1.36 +12 -0 ao/configure.in
Index: configure.in
===================================================================
RCS file: /usr/local/cvsroot/ao/configure.in,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- configure.in 2001/09/26 19:23:53 1.35
+++ configure.in 2001/10/16 00:13:46 1.36
@@ -196,7 +196,19 @@
fi
AC_SUBST(ALSA09_LIBS)
+dnl Decide whether we need to enable the workaround for broken OSS APIs
+dnl such as the OSS emulation in ALSA.
+AC_ARG_ENABLE(broken-oss, [ --enable-broken-oss workaround for some OSS drivers (see README for details)],,
+if test "x$have_alsa" = "xyes" -o "x$have_alsa09" = "xyes"; then
+ enable_broken_oss="yes"
+fi)
+
+if test "x$enable_broken_oss" = "xyes"; then
+ AC_DEFINE(BROKEN_OSS)
+ AC_MSG_WARN(Broken OSS API workaround enabled. See README for details.)
+fi
+
dnl Check for Sun audio
AC_CHECK_HEADERS(sys/audioio.h)
1.12 +15 -4 ao/src/plugins/oss/ao_oss.c
Index: ao_oss.c
===================================================================
RCS file: /usr/local/cvsroot/ao/src/plugins/oss/ao_oss.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ao_oss.c 2001/08/13 06:20:05 1.11
+++ ao_oss.c 2001/10/16 00:13:47 1.12
@@ -70,10 +70,11 @@
* *dev_path. Assumes that *dev_path does not need to be free()'ed
* initially.
*
- * This opens the device in non-blocking mode at first in order to prevent
- * deadlock caused by ALSA's OSS emulation and some OSS drivers if the
- * device is already in use. If blocking is non-zero, we remove the blocking
- * flag if possible so that the device can be used for actual output.
+ * If BROKEN_OSS is defined, this opens the device in non-blocking
+ * mode at first in order to prevent deadlock caused by ALSA's OSS
+ * emulation and some OSS drivers if the device is already in use. If
+ * blocking is non-zero, we remove the blocking flag if possible so
+ * that the device can be used for actual output.
*/
int _open_default_oss_device (char **dev_path, int blocking)
{
@@ -83,7 +84,11 @@
/* default: first try the devfs path */
*dev_path = strdup("/dev/sound/dsp");
+#ifdef BROKEN_OSS
fd = open(*dev_path, O_WRONLY | O_NONBLOCK);
+#else
+ fd = open(*dev_path, O_WRONLY);
+#endif /* BROKEN_OSS */
/* then try the original dsp path */
if(fd < 0)
@@ -93,9 +98,14 @@
dev = strdup(*dev_path);
free(*dev_path);
*dev_path = strdup("/dev/dsp");
+#ifdef BROKEN_OSS
fd = open(*dev_path, O_WRONLY | O_NONBLOCK);
+#else
+ fd = open(*dev_path, O_WRONLY);
+#endif /* BROKEN_OSS */
}
+#ifdef BROKEN_OSS
/* Now have to remove the O_NONBLOCK flag if so instructed. */
if (fd > 0 && blocking) {
if (fcntl(fd, F_SETFL, 0) < 0) { /* Remove O_NONBLOCK */
@@ -105,6 +115,7 @@
fd = -1;
}
}
+#endif /* BROKEN_OSS */
/* Deal with error cases */
if(fd < 0)
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list