Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/ossaudio add a lot more debugging and error check...
details: https://anonhg.NetBSD.org/src/rev/8fe9e27d1514
branches: trunk
changeset: 746898:8fe9e27d1514
user: christos <christos%NetBSD.org@localhost>
date: Sat Aug 22 23:31:16 2009 +0000
description:
add a lot more debugging and error checking. Alas, skype seems to be happy
getting back our values, but still does not work.
diffstat:
sys/compat/ossaudio/ossaudio.c | 507 +++++++++++++++++++++++++++++++++-------
1 files changed, 418 insertions(+), 89 deletions(-)
diffs (truncated from 921 to 300 lines):
diff -r dba8720cb43d -r 8fe9e27d1514 sys/compat/ossaudio/ossaudio.c
--- a/sys/compat/ossaudio/ossaudio.c Sat Aug 22 23:08:01 2009 +0000
+++ b/sys/compat/ossaudio/ossaudio.c Sat Aug 22 23:31:16 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ossaudio.c,v 1.64 2008/11/13 10:05:52 ad Exp $ */
+/* $NetBSD: ossaudio.c,v 1.65 2009/08/22 23:31:16 christos Exp $ */
/*-
* Copyright (c) 1997, 2008 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.64 2008/11/13 10:05:52 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.65 2009/08/22 23:31:16 christos Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -66,6 +66,88 @@
static void setblocksize(file_t *, struct audio_info *);
+#ifdef AUDIO_DEBUG
+static const char *
+compat_ossaudio_getcmd(u_long cmd)
+{
+ static char buf[64];
+ switch (cmd) {
+#define _DO(_a) \
+ case _a: \
+ return # _a;
+_DO(OSS_SNDCTL_DSP_RESET)
+_DO(OSS_SNDCTL_DSP_SYNC)
+_DO(OSS_SNDCTL_DSP_SPEED)
+_DO(OSS_SOUND_PCM_READ_RATE)
+_DO(OS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YNTHS)
+_DO(OSS_SEQ_NRMIDIS)
+#ifdef notyet
+_DO(OSS_MIDI_INFO)
+#endif
+_DO(OSS_SEQ_THRESHOLD)
+_DO(OSS_MEMAVL)
+_DO(OSS_FM_4OP_ENABLE)
+_DO(OSS_SEQ_PANIC)
+_DO(OSS_SEQ_OUTOFBAND)
+_DO(OSS_SEQ_GETTIME)
+_DO(OSS_ID)
+_DO(OSS_CONTROL)
+_DO(OSS_REMOVESAMPLE)
+_DO(OSS_TMR_TIMEBASE)
+_DO(OSS_TMR_START)
+_DO(OSS_TMR_STOP)
+_DO(OSS_TMR_CONTINUE)
+_DO(OSS_TMR_TEMPO)
+_DO(OSS_TMR_SOURCE)
+_DO(OSS_TMR_METRONOME)
+_DO(OSS_TMR_SELECT)
+#undef _DO
+ default:
+ (void)snprintf(buf, sizeof(buf), "*0x%lx*", cmd);
+ return buf;
+ }
+}
+#endif
+
+
static int
compat_ossaudio_modcmd(modcmd_t cmd, void *arg)
{
@@ -108,7 +190,7 @@
}
com = SCARG(uap, com);
- DPRINTF(("oss_ioctl_audio: com=%08lx\n", com));
+ DPRINTF(("%s: com=%s\n", __func__, compat_ossaudio_getcmd(com)));
retval[0] = 0;
@@ -116,13 +198,17 @@
switch (com) {
case OSS_SNDCTL_DSP_RESET:
error = ioctlf(fp, AUDIO_FLUSH, NULL);
- if (error)
+ if (error) {
+ DPRINTF(("%s: AUDIO_FLUSH %d\n", __func__, error));
goto out;
+ }
break;
case OSS_SNDCTL_DSP_SYNC:
error = ioctlf(fp, AUDIO_DRAIN, NULL);
- if (error)
+ if (error) {
+ DPRINTF(("%s: AUDIO_DRAIN %d\n", __func__, error));
goto out;
+ }
break;
case OSS_SNDCTL_DSP_POST:
/* This call is merely advisory, and may be a nop. */
@@ -130,56 +216,93 @@
case OSS_SNDCTL_DSP_SPEED:
AUDIO_INITINFO(&tmpinfo);
error = copyin(SCARG(uap, data), &idat, sizeof idat);
- if (error)
+ if (error) {
+ DPRINTF(("%s: SNDCTL_DSP_SPEED %d\n",
+ __func__, error));
goto out;
+ }
tmpinfo.play.sample_rate =
tmpinfo.record.sample_rate = idat;
+ DPRINTF(("%s: SNDCTL_DSP_SPEED > %d\n", __func__, idat));
error = ioctlf(fp, AUDIO_SETINFO, &tmpinfo);
- DPRINTF(("oss_sys_ioctl: SNDCTL_DSP_SPEED %d = %d\n",
- idat, error));
- if (error)
+ if (error) {
+ DPRINTF(("%s: SNDCTL_DSP_SPEED %d = %d\n",
+ __func__, idat, error));
goto out;
+ }
/* fall into ... */
case OSS_SOUND_PCM_READ_RATE:
error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo);
- if (error)
+ if (error) {
+ DPRINTF(("%s: AUDIO_GETBUFINFO %d\n",
+ __func__, error));
goto out;
+ }
idat = tmpinfo.play.sample_rate;
+ DPRINTF(("%s: SNDCTL_PCM_READ_RATE < %d\n", __func__, idat));
error = copyout(&idat, SCARG(uap, data), sizeof idat);
- if (error)
+ if (error) {
+ DPRINTF(("%s: SOUND_PCM_READ_RATE %d = %d\n",
+ __func__, idat, error));
goto out;
+ }
break;
case OSS_SNDCTL_DSP_STEREO:
AUDIO_INITINFO(&tmpinfo);
error = copyin(SCARG(uap, data), &idat, sizeof idat);
- if (error)
+ if (error) {
+ DPRINTF(("%s: SNDCTL_DSP_STEREO %d\n",
+ __func__, error));
goto out;
+ }
tmpinfo.play.channels =
tmpinfo.record.channels = idat ? 2 : 1;
- (void) ioctlf(fp, AUDIO_SETINFO, &tmpinfo);
+ error = ioctlf(fp, AUDIO_SETINFO, &tmpinfo);
+ if (error) {
+ DPRINTF(("%s: AUDIO_SETINFO %d\n",
+ __func__, error));
+ goto out;
+ }
error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo);
- if (error)
+ if (error) {
+ DPRINTF(("%s: AUDIO_GETBUFINFO %d\n",
+ __func__, error));
goto out;
+ }
idat = tmpinfo.play.channels - 1;
error = copyout(&idat, SCARG(uap, data), sizeof idat);
- if (error)
+ if (error) {
+ DPRINTF(("%s: SNDCTL_DSP_STEREO %d = %d\n",
+ __func__, idat, error));
goto out;
+ }
break;
case OSS_SNDCTL_DSP_GETBLKSIZE:
error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo);
- if (error)
+ if (error) {
+ DPRINTF(("%s: AUDIO_GETBUFINFO %d\n",
+ __func__, error));
goto out;
+ }
setblocksize(fp, &tmpinfo);
idat = tmpinfo.blocksize;
+ DPRINTF(("%s: SNDCTL_DSP_GETBLKSIZE < %d\n",
+ __func__, idat));
error = copyout(&idat, SCARG(uap, data), sizeof idat);
- if (error)
+ if (error) {
+ DPRINTF(("%s: SNDCTL_DSP_GETBLKSIZE %d = %d\n",
+ __func__, idat, error));
goto out;
+ }
break;
case OSS_SNDCTL_DSP_SETFMT:
AUDIO_INITINFO(&tmpinfo);
error = copyin(SCARG(uap, data), &idat, sizeof idat);
- if (error)
+ if (error) {
+ DPRINTF(("%s: SNDCTL_DSP_SETFMT %d\n",
+ __func__, error));
goto out;
+ }
switch (idat) {
case OSS_AFMT_MU_LAW:
tmpinfo.play.precision =
@@ -230,15 +353,27 @@
tmpinfo.record.encoding = AUDIO_ENCODING_ULINEAR_BE;
break;
default:
+ DPRINTF(("%s: SNDCTL_DSP_SETFMT bad fmt %d\n",
+ __func__, idat));
error = EINVAL;
goto out;
}
- (void) ioctlf(fp, AUDIO_SETINFO, &tmpinfo);
+ DPRINTF(("%s: SNDCTL_DSP_SETFMT > 0x%x\n",
+ __func__, idat));
+ error = ioctlf(fp, AUDIO_SETINFO, &tmpinfo);
+ if (error) {
+ DPRINTF(("%s: AUDIO_SETINFO %d\n",
+ __func__, error));
+ goto out;
+ }
/* fall into ... */
case OSS_SOUND_PCM_READ_BITS:
error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo);
- if (error)
+ if (error) {
+ DPRINTF(("%s: AUDIO_GETBUFINFO %d\n",
+ __func__, error));
goto out;
+ }
switch (tmpinfo.play.encoding) {
case AUDIO_ENCODING_ULAW:
idat = OSS_AFMT_MU_LAW;
@@ -273,83 +408,139 @@
case AUDIO_ENCODING_ADPCM:
idat = OSS_AFMT_IMA_ADPCM;
break;
+ default:
+ DPRINTF(("%s: SOUND_PCM_READ_BITS bad encoding %d\n",
+ __func__, tmpinfo.play.encoding));
+ error = EINVAL;
+ goto out;
}
+ DPRINTF(("%s: SOUND_PCM_READ_BITS < 0x%x\n",
+ __func__, idat));
error = copyout(&idat, SCARG(uap, data), sizeof idat);
- if (error)
+ if (error) {
+ DPRINTF(("%s: SOUND_PCM_READ_BITS %d = %d\n",
+ __func__, idat, error));
goto out;
+ }
break;
case OSS_SNDCTL_DSP_CHANNELS:
AUDIO_INITINFO(&tmpinfo);
error = copyin(SCARG(uap, data), &idat, sizeof idat);
- if (error)
+ if (error) {
+ DPRINTF(("%s: SNDCTL_DSP_CHANNELS %d\n",
+ __func__, error));
Home |
Main Index |
Thread Index |
Old Index