Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libossaudio ossaudio(3): Clone some useful behaviour fro...
details: https://anonhg.NetBSD.org/src/rev/80b64f9d3c3e
branches: trunk
changeset: 956988:80b64f9d3c3e
user: nia <nia%NetBSD.org@localhost>
date: Fri Nov 13 09:02:39 2020 +0000
description:
ossaudio(3): Clone some useful behaviour from the Solaris kernel
Both SNDCTL_DSP_SPEED and SNDCTL_DSP_CHANNELS support a special value
0 to "query the configured value without changing it". In our case,
this actually means setting and querying the hardware rate.
I don't know if OSSv3 or FreeBSD or other implementations also do this.
But it seems safe and sensible to support.
diffstat:
lib/libossaudio/ossaudio.c | 27 ++++++++++++++++++++++++---
1 files changed, 24 insertions(+), 3 deletions(-)
diffs (55 lines):
diff -r c8e22518b957 -r 80b64f9d3c3e lib/libossaudio/ossaudio.c
--- a/lib/libossaudio/ossaudio.c Fri Nov 13 09:01:59 2020 +0000
+++ b/lib/libossaudio/ossaudio.c Fri Nov 13 09:02:39 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ossaudio.c,v 1.63 2020/11/04 22:59:24 nia Exp $ */
+/* $NetBSD: ossaudio.c,v 1.64 2020/11/13 09:02:39 nia Exp $ */
/*-
* Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: ossaudio.c,v 1.63 2020/11/04 22:59:24 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.64 2020/11/13 09:02:39 nia Exp $");
/*
* This is an Open Sound System compatibility layer, which provides
@@ -184,7 +184,26 @@
break;
case SNDCTL_DSP_SPEED:
AUDIO_INITINFO(&tmpinfo);
- /* Conform to kernel limits. */
+ /*
+ * In Solaris, 0 is used a special value to query the
+ * current rate. This seems useful to support.
+ */
+ if (INTARG == 0) {
+ retval = ioctl(fd, AUDIO_GETBUFINFO, &tmpinfo);
+ if (retval < 0)
+ return retval;
+ retval = ioctl(fd, AUDIO_GETFORMAT, &hwfmt);
+ if (retval < 0)
+ return retval;
+ INTARG = (tmpinfo.mode == AUMODE_RECORD) ?
+ hwfmt.record.sample_rate :
+ hwfmt.play.sample_rate;
+ }
+ /*
+ * Conform to kernel limits.
+ * NetBSD will reject unsupported sample rates, but OSS
+ * applications need to be able to negotiate a supported one.
+ */
if (INTARG < 1000)
INTARG = 1000;
if (INTARG > 192000)
@@ -1708,6 +1727,8 @@
* case an application is abusing SNDCTL_DSP_CHANNELS - OSSv4 always sets and
* returns a reasonable value, even if it wasn't what the user requested.
*
+ * Solaris guarantees this behaviour if nchannels = 0.
+ *
* XXX: If a device is opened for both playback and recording, and supports
* fewer channels for recording than playback, applications that do both will
* behave very strangely. OSS doesn't allow for reporting separate channel
Home |
Main Index |
Thread Index |
Old Index