Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Renane ioctl AUDIO_SETPROC to AUDIO_SETCHAN.
details: https://anonhg.NetBSD.org/src/rev/e1a0976da2cd
branches: trunk
changeset: 352209:e1a0976da2cd
user: nat <nat%NetBSD.org@localhost>
date: Tue Mar 21 07:04:29 2017 +0000
description:
Renane ioctl AUDIO_SETPROC to AUDIO_SETCHAN.
Add an ioctl to return channel number (AUDIO_GETCHAN). This can be used
on audio/sound/audioctl devices.
Return EIO in read/write/ioctl/poll/stat if fp has been closed or is
invalid.
Update audio.4, audioio.h and audioctl(1) to reflect these changes.
diffstat:
share/man/man4/audio.4 | 6 ++++--
sys/dev/audio.c | 29 ++++++++++++++++++++++++++---
sys/sys/audioio.h | 5 +++--
usr.bin/audio/ctl/ctl.c | 12 ++++++------
4 files changed, 39 insertions(+), 13 deletions(-)
diffs (178 lines):
diff -r 3af24815dfc8 -r e1a0976da2cd share/man/man4/audio.4
--- a/share/man/man4/audio.4 Tue Mar 21 04:03:17 2017 +0000
+++ b/share/man/man4/audio.4 Tue Mar 21 07:04:29 2017 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: audio.4,v 1.75 2017/02/12 14:44:20 wiz Exp $
+.\" $NetBSD: audio.4,v 1.76 2017/03/21 07:04:29 nat Exp $
.\"
.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -245,7 +245,9 @@
commands are supported on the sample devices:
.Pp
.Bl -tag -width indent
-.It Dv AUDIO_SETPROC (int)
+.It Dv AUDIO_GETCHAN (int)
+This command will return the audio channel in use.
+.It Dv AUDIO_SETCHAN (int)
This command will select the audio channel for subsequent ioctl calls.
.It Dv AUDIO_FLUSH
This command stops all playback and recording, clears all queued
diff -r 3af24815dfc8 -r e1a0976da2cd sys/dev/audio.c
--- a/sys/dev/audio.c Tue Mar 21 04:03:17 2017 +0000
+++ b/sys/dev/audio.c Tue Mar 21 07:04:29 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.316 2017/03/20 22:42:39 nat Exp $ */
+/* $NetBSD: audio.c,v 1.317 2017/03/21 07:04:29 nat Exp $ */
/*-
* Copyright (c) 2016 Nathanial Sloss <nathanialsloss%yahoo.com.au@localhost>
@@ -148,7 +148,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.316 2017/03/20 22:42:39 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.317 2017/03/21 07:04:29 nat Exp $");
#include "audio.h"
#if NAUDIO > 0
@@ -1525,6 +1525,8 @@
found = false;
SIMPLEQ_FOREACH(vchan, &sc->sc_audiochan, entries) {
+ if (vchan == SIMPLEQ_FIRST(&sc->sc_audiochan))
+ continue;
if (vchan->vc == vc) {
found = true;
break;
@@ -1660,6 +1662,9 @@
int error;
dev_t dev;
+ if (fp->f_audioctx == NULL)
+ return EIO;
+
dev = fp->f_audioctx->dev;
if ((error = audio_enter(dev, RW_READER, &sc)) != 0)
@@ -1693,6 +1698,9 @@
int error;
dev_t dev;
+ if (fp->f_audioctx == NULL)
+ return EIO;
+
dev = fp->f_audioctx->dev;
if ((error = audio_enter(dev, RW_READER, &sc)) != 0)
@@ -1727,6 +1735,9 @@
krw_t rw;
dev_t dev;
+ if (fp->f_audioctx == NULL)
+ return EIO;
+
chan = fp->f_audioctx;
dev = chan->dev;
@@ -1773,6 +1784,9 @@
static int
audiostat(struct file *fp, struct stat *st)
{
+ if (fp->f_audioctx == NULL)
+ return EIO;
+
memset(st, 0, sizeof(*st));
st->st_dev = fp->f_audioctx->dev;
@@ -1792,6 +1806,9 @@
int revents;
dev_t dev;
+ if (fp->f_audioctx == NULL)
+ return EIO;
+
dev = fp->f_audioctx->dev;
/* Don't bother with device level lock here. */
@@ -2947,6 +2964,8 @@
KASSERT(mutex_owned(sc->sc_lock));
SIMPLEQ_FOREACH(pchan, &sc->sc_audiochan, entries) {
+ if (pchan == SIMPLEQ_FIRST(&sc->sc_audiochan))
+ continue;
if (pchan->chan == chan->deschan)
break;
}
@@ -2962,7 +2981,11 @@
return ENXIO;
error = 0;
switch (cmd) {
- case AUDIO_SETPROC:
+ case AUDIO_GETCHAN:
+ if ((int *)addr != NULL)
+ *(int*)addr = chan->chan;
+ break;
+ case AUDIO_SETCHAN:
if ((int *)addr != NULL && *(int*)addr > 0)
chan->deschan = *(int*)addr;
break;
diff -r 3af24815dfc8 -r e1a0976da2cd sys/sys/audioio.h
--- a/sys/sys/audioio.h Tue Mar 21 04:03:17 2017 +0000
+++ b/sys/sys/audioio.h Tue Mar 21 07:04:29 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audioio.h,v 1.36 2017/02/10 19:31:42 nat Exp $ */
+/* $NetBSD: audioio.h,v 1.37 2017/03/21 07:04:29 nat Exp $ */
/*
* Copyright (c) 1991-1993 Regents of the University of California.
@@ -191,7 +191,8 @@
#define AUDIO_PROP_PLAYBACK 0x10
#define AUDIO_PROP_CAPTURE 0x20
#define AUDIO_GETBUFINFO _IOR('A', 35, struct audio_info)
-#define AUDIO_SETPROC _IOW('A', 36, int)
+#define AUDIO_SETCHAN _IOW('A', 36, int)
+#define AUDIO_GETCHAN _IOR('A', 37, int)
/*
* Mixer device
diff -r 3af24815dfc8 -r e1a0976da2cd usr.bin/audio/ctl/ctl.c
--- a/usr.bin/audio/ctl/ctl.c Tue Mar 21 04:03:17 2017 +0000
+++ b/usr.bin/audio/ctl/ctl.c Tue Mar 21 07:04:29 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ctl.c,v 1.42 2017/02/10 19:31:42 nat Exp $ */
+/* $NetBSD: ctl.c,v 1.43 2017/03/21 07:04:29 nat Exp $ */
/*
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: ctl.c,v 1.42 2017/02/10 19:31:42 nat Exp $");
+__RCSID("$NetBSD: ctl.c,v 1.43 2017/03/21 07:04:29 nat Exp $");
#endif
@@ -291,8 +291,8 @@
{
int pos, i;
- if (channel >= 0 && ioctl(fd, AUDIO_SETPROC, &channel) < 0)
- err(1, "AUDIO_SETPROC");
+ if (channel >= 0 && ioctl(fd, AUDIO_SETCHAN, &channel) < 0)
+ err(1, "AUDIO_SETCHAN");
if (ioctl(fd, AUDIO_GETDEV, &adev) < 0)
err(1, "AUDIO_GETDEV");
@@ -440,8 +440,8 @@
{
struct field *p;
- if (channel >= 0 && ioctl(fd, AUDIO_SETPROC, &channel) < 0)
- err(1, "AUDIO_SETPROC");
+ if (channel >= 0 && ioctl(fd, AUDIO_SETCHAN, &channel) < 0)
+ err(1, "AUDIO_SETCHAN");
AUDIO_INITINFO(&info);
while (argc--) {
Home |
Main Index |
Thread Index |
Old Index