summaryrefslogtreecommitdiff
path: root/audio/ossaudio.c
diff options
context:
space:
mode:
authorJuergen Lock <nox@jelal.kn-bremen.de>2010-01-12 23:48:04 +0100
committermalc <av1474@comtv.ru>2010-01-13 01:59:03 +0300
commit72ff25e4e98d6dba9286d032b9ff5432553bbad5 (patch)
treebf39163f08bcd88e0a400853122cd4f410524e48 /audio/ossaudio.c
parentc9f79a3f79a48de28b4575cb5644bcf45d3754d0 (diff)
downloadqemu-72ff25e4e98d6dba9286d032b9ff5432553bbad5.tar.gz
qemu-72ff25e4e98d6dba9286d032b9ff5432553bbad5.tar.bz2
qemu-72ff25e4e98d6dba9286d032b9ff5432553bbad5.zip
Workaround for broken OSS_GETVERSION on FreeBSD, part two
Turns out on those versions of FreeBSD (>= 7.x) that know OSS_GETVERSION the ioctl doesn't actually work yet (except in the Linuxolator), so if building on FreeBSD assume the sound drivers are new enough if the ioctl returns the errno it does currently on FreeBSD. (Rev 2 after private discussion with malc.) Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de> Signed-off-by: malc <av1474@comtv.ru>
Diffstat (limited to 'audio/ossaudio.c')
-rw-r--r--audio/ossaudio.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index ebf8b2397f..42bffaeafd 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -240,6 +240,31 @@ static void oss_dump_info (struct oss_params *req, struct oss_params *obt)
}
#endif
+#ifdef USE_DSP_POLICY
+static int oss_get_version (int fd, int *version, const char *typ)
+{
+ if (ioctl (fd, OSS_GETVERSION, &version)) {
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ /*
+ * Looks like atm (20100109) FreeBSD knows OSS_GETVERSION
+ * since 7.x, but currently only on the mixer device (or in
+ * the Linuxolator), and in the native version that part of
+ * the code is in fact never reached so the ioctl fails anyway.
+ * Until this is fixed, just check the errno and if its what
+ * FreeBSD's sound drivers return atm assume they are new enough.
+ */
+ if (errno == EINVAL) {
+ *version = 0x040000;
+ return 0;
+ }
+#endif
+ oss_logerr2 (errno, typ, "Failed to get OSS version\n");
+ return -1;
+ }
+ return 0;
+}
+#endif
+
static int oss_open (int in, struct oss_params *req,
struct oss_params *obt, int *pfd)
{
@@ -289,10 +314,7 @@ static int oss_open (int in, struct oss_params *req,
if (conf.policy >= 0) {
int version;
- if (ioctl (fd, OSS_GETVERSION, &version)) {
- oss_logerr2 (errno, typ, "Failed to get OSS version\n");
- }
- else {
+ if (!oss_get_version (fd, &version, typ)) {
if (conf.debug) {
dolog ("OSS version = %#x\n", version);
}