Module Name: src Committed By: nia Date: Mon Mar 15 10:58:05 UTC 2021
Modified Files: src/lib/libossaudio: ossaudio.c Log Message: ossv4 mixer API: be extra careful with the inputs to AUDIO_MIXER_READ. some drivers (not hdaudio(4), but uaudio(4), eap(4), sb(4), various other old cards) will return error if a AUDIO_MIXER_VALUE is requested and the number of channels is not specified as input. this is not documented as well as it should be, unfortunately. To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/lib/libossaudio/ossaudio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libossaudio/ossaudio.c diff -u src/lib/libossaudio/ossaudio.c:1.65 src/lib/libossaudio/ossaudio.c:1.66 --- src/lib/libossaudio/ossaudio.c:1.65 Sat Dec 19 12:55:28 2020 +++ src/lib/libossaudio/ossaudio.c Mon Mar 15 10:58:05 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ossaudio.c,v 1.65 2020/12/19 12:55:28 nia Exp $ */ +/* $NetBSD: ossaudio.c,v 1.66 2021/03/15 10:58:05 nia Exp $ */ /*- * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: ossaudio.c,v 1.65 2020/12/19 12:55:28 nia Exp $"); +__RCSID("$NetBSD: ossaudio.c,v 1.66 2021/03/15 10:58:05 nia Exp $"); /* * This is an Open Sound System compatibility layer, which provides @@ -1442,6 +1442,7 @@ mixer_oss4_ioctl(int fd, unsigned long c errno = tmperrno; return retval; } + mc.type = mdi.type; switch (mdi.type) { case AUDIO_MIXER_ENUM: if (mv->value >= mdi.un.e.num_mem) { @@ -1469,6 +1470,7 @@ mixer_oss4_ioctl(int fd, unsigned long c #endif break; case AUDIO_MIXER_VALUE: + mc.un.value.num_channels = mdi.un.v.num_channels; if (mdi.un.v.num_channels != 2) { for (i = 0; i < mdi.un.v.num_channels; ++i) { mc.un.value.level[i] = mv->value; @@ -1512,6 +1514,9 @@ mixer_oss4_ioctl(int fd, unsigned long c return retval; } mc.dev = mdi.index; + mc.type = mdi.type; + if (mdi.type == AUDIO_MIXER_VALUE) + mc.un.value.num_channels = mdi.un.v.num_channels; retval = ioctl(newfd, AUDIO_MIXER_READ, &mc); if (retval < 0) { tmperrno = errno;