Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src ossaudio: Implement SNDCTL_DSP_(SET|GET)TRIGGER.
details: https://anonhg.NetBSD.org/src/rev/8f4d7e1dc069
branches: trunk
changeset: 971246:8f4d7e1dc069
user: nia <nia%NetBSD.org@localhost>
date: Sun Apr 19 13:44:50 2020 +0000
description:
ossaudio: Implement SNDCTL_DSP_(SET|GET)TRIGGER.
diffstat:
lib/libossaudio/ossaudio.c | 48 ++++++++++---------------
sys/compat/ossaudio/ossaudio.c | 77 +++++++++++++++--------------------------
2 files changed, 49 insertions(+), 76 deletions(-)
diffs (198 lines):
diff -r dff5124a035b -r 8f4d7e1dc069 lib/libossaudio/ossaudio.c
--- a/lib/libossaudio/ossaudio.c Sun Apr 19 13:26:17 2020 +0000
+++ b/lib/libossaudio/ossaudio.c Sun Apr 19 13:44:50 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ossaudio.c,v 1.42 2020/04/19 11:27:40 nia Exp $ */
+/* $NetBSD: ossaudio.c,v 1.43 2020/04/19 13:44:50 nia Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: ossaudio.c,v 1.42 2020/04/19 11:27:40 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.43 2020/04/19 13:44:50 nia Exp $");
/*
* This is an OSS (Linux) sound API emulator.
@@ -501,43 +501,35 @@
retval = ioctl(fd, AUDIO_GETPROPS, &idata);
if (retval < 0)
return retval;
- idat = DSP_CAP_TRIGGER; /* pretend we have trigger */
+ idat = DSP_CAP_TRIGGER;
if (idata & AUDIO_PROP_FULLDUPLEX)
idat |= DSP_CAP_DUPLEX;
if (idata & AUDIO_PROP_MMAP)
idat |= DSP_CAP_MMAP;
INTARG = idat;
break;
-#if 0
+ case SNDCTL_DSP_SETTRIGGER:
+ retval = ioctl(fd, AUDIO_GETBUFINFO, &tmpinfo);
+ if (retval < 0)
+ return retval;
+ AUDIO_INITINFO(&tmpinfo);
+ if (tmpinfo.mode & AUMODE_PLAY)
+ tmpinfo.play.pause = (INTARG & PCM_ENABLE_OUTPUT) == 0;
+ if (tmpinfo.mode & AUMODE_RECORD)
+ tmpinfo.record.pause = (INTARG & PCM_ENABLE_INPUT) == 0;
+ (void)ioctl(fd, AUDIO_SETINFO, &tmpinfo);
+ /* FALLTHRU */
case SNDCTL_DSP_GETTRIGGER:
retval = ioctl(fd, AUDIO_GETBUFINFO, &tmpinfo);
if (retval < 0)
return retval;
- idat = (tmpinfo.play.pause ? 0 : PCM_ENABLE_OUTPUT) |
- (tmpinfo.record.pause ? 0 : PCM_ENABLE_INPUT);
- retval = copyout(&idat, SCARG(uap, data), sizeof idat);
- if (retval < 0)
- return retval;
+ idat = 0;
+ if ((tmpinfo.mode & AUMODE_PLAY) && !tmpinfo.play.pause)
+ idat |= PCM_ENABLE_OUTPUT;
+ if ((tmpinfo.mode & AUMODE_RECORD) && !tmpinfo.record.pause)
+ idat |= PCM_ENABLE_INPUT;
+ INTARG = idat;
break;
- case SNDCTL_DSP_SETTRIGGER:
- AUDIO_INITINFO(&tmpinfo);
- retval = copyin(SCARG(uap, data), &idat, sizeof idat);
- if (retval < 0)
- return retval;
- tmpinfo.play.pause = (idat & PCM_ENABLE_OUTPUT) == 0;
- tmpinfo.record.pause = (idat & PCM_ENABLE_INPUT) == 0;
- (void) ioctl(fd, AUDIO_SETINFO, &tmpinfo);
- retval = copyout(&idat, SCARG(uap, data), sizeof idat);
- if (retval < 0)
- return retval;
- break;
-#else
- case SNDCTL_DSP_GETTRIGGER:
- case SNDCTL_DSP_SETTRIGGER:
- /* XXX Do nothing for now. */
- INTARG = PCM_ENABLE_OUTPUT;
- break;
-#endif
case SNDCTL_DSP_GETIPTR:
retval = ioctl(fd, AUDIO_GETIOFFS, &tmpoffs);
if (retval < 0)
diff -r dff5124a035b -r 8f4d7e1dc069 sys/compat/ossaudio/ossaudio.c
--- a/sys/compat/ossaudio/ossaudio.c Sun Apr 19 13:26:17 2020 +0000
+++ b/sys/compat/ossaudio/ossaudio.c Sun Apr 19 13:44:50 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ossaudio.c,v 1.81 2020/04/15 16:39:06 nia Exp $ */
+/* $NetBSD: ossaudio.c,v 1.82 2020/04/19 13:44:51 nia 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.81 2020/04/15 16:39:06 nia Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.82 2020/04/19 13:44:51 nia Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -715,7 +715,7 @@
__func__, error));
goto out;
}
- idat = OSS_DSP_CAP_TRIGGER; /* pretend we have trigger */
+ idat = OSS_DSP_CAP_TRIGGER;
if (idata & AUDIO_PROP_FULLDUPLEX)
idat |= OSS_DSP_CAP_DUPLEX;
if (idata & AUDIO_PROP_MMAP)
@@ -730,7 +730,26 @@
goto out;
}
break;
-#if 0
+ case OSS_SNDCTL_DSP_SETTRIGGER:
+ error = copyin(SCARG(uap, data), &idat, sizeof idat);
+ if (error) {
+ DPRINTF(("%s: SNDCTL_DSP_SETTRIGGER: %d\n",
+ __func__, error));
+ goto out;
+ }
+ error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo);
+ if (error) {
+ DPRINTF(("%s: AUDIO_GETBUFINFO %d\n",
+ __func__, error));
+ goto out;
+ }
+ AUDIO_INITINFO(&tmpinfo);
+ if (tmpinfo.mode & AUMODE_PLAY)
+ tmpinfo.play.pause = (idat & OSS_PCM_ENABLE_OUTPUT) == 0;
+ if (tmpinfo.mode & AUMODE_RECORD)
+ tmpinfo.record.pause = (idat & OSS_PCM_ENABLE_INPUT) == 0;
+ (void)ioctlf(fp, AUDIO_SETINFO, &tmpinfo);
+ /* FALLTHRU */
case OSS_SNDCTL_DSP_GETTRIGGER:
error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo);
if (error) {
@@ -738,56 +757,18 @@
__func__, error));
goto out;
}
- idat = (tmpinfo.play.pause ? 0 : OSS_PCM_ENABLE_OUTPUT) |
- (tmpinfo.record.pause ? 0 : OSS_PCM_ENABLE_INPUT);
+ idat = 0;
+ if ((tmpinfo.mode & AUMODE_PLAY) && !tmpinfo.play.pause)
+ idat |= OSS_PCM_ENABLE_OUTPUT;
+ if ((tmpinfo.mode & AUMODE_RECORD) && !tmpinfo.record.pause)
+ idat |= OSS_PCM_ENABLE_INPUT;
error = copyout(&idat, SCARG(uap, data), sizeof idat);
if (error) {
- DPRINTF(("%s: SNDCTL_DSP_SETRIGGER %x = %d\n",
+ DPRINTF(("%s: SNDCTL_DSP_GETTRIGGER = %x = %d\n",
__func__, idat, error));
goto out;
}
break;
- case OSS_SNDCTL_DSP_SETTRIGGER:
- error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo, p);
- if (error) {
- DPRINTF(("%s: AUDIO_GETBUFINFO %d\n",
- __func__, error));
- goto out;
- }
- error = copyin(SCARG(uap, data), &idat, sizeof idat);
- if (error) {
- DPRINTF(("%s: AUDIO_GETBUFINFO %d\n",
- __func__, error));
- goto out;
- }
- tmpinfo.play.pause = (idat & OSS_PCM_ENABLE_OUTPUT) == 0;
- tmpinfo.record.pause = (idat & OSS_PCM_ENABLE_INPUT) == 0;
- error = ioctlf(fp, AUDIO_SETINFO, &tmpinfo);
- if (error) {
- DPRINTF(("%s: AUDIO_SETINFO %d\n",
- __func__, error));
- goto out;
- }
- error = copyout(&idat, SCARG(uap, data), sizeof idat);
- if (error) {
- DPRINTF(("%s: SNDCTL_DSP_SETRIGGER %x = %d\n",
- __func__, idat, error));
- goto out;
- }
- break;
-#else
- case OSS_SNDCTL_DSP_GETTRIGGER:
- case OSS_SNDCTL_DSP_SETTRIGGER:
- /* XXX Do nothing for now. */
- idat = OSS_PCM_ENABLE_OUTPUT;
- error = copyout(&idat, SCARG(uap, data), sizeof idat);
- if (error) {
- DPRINTF(("%s: SNDCTL_DSP_{GET,SET}RIGGER %x = %d\n",
- __func__, idat, error));
- goto out;
- }
- break;
-#endif
case OSS_SNDCTL_DSP_GETIPTR:
error = ioctlf(fp, AUDIO_GETIOFFS, &tmpoffs);
if (error) {
Home |
Main Index |
Thread Index |
Old Index