Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src pad(4) must be open before corresponding audio device is ope...
details: https://anonhg.NetBSD.org/src/rev/f28ac2515ded
branches: trunk
changeset: 348325:f28ac2515ded
user: nat <nat%NetBSD.org@localhost>
date: Sat Oct 15 07:08:06 2016 +0000
description:
pad(4) must be open before corresponding audio device is opened.
OK christos@
diffstat:
sys/dev/pad/pad.c | 23 ++++++++++++++++++++---
tests/dev/audio/h_pad.c | 10 +++++-----
2 files changed, 25 insertions(+), 8 deletions(-)
diffs (100 lines):
diff -r 744302c8607b -r f28ac2515ded sys/dev/pad/pad.c
--- a/sys/dev/pad/pad.c Sat Oct 15 06:50:13 2016 +0000
+++ b/sys/dev/pad/pad.c Sat Oct 15 07:08:06 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pad.c,v 1.25 2016/07/07 06:55:41 msaitoh Exp $ */
+/* $NetBSD: pad.c,v 1.26 2016/10/15 07:08:06 nat Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.25 2016/07/07 06:55:41 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.26 2016/10/15 07:08:06 nat Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -74,6 +74,7 @@
static int pad_detach(device_t, int);
static void pad_childdet(device_t, device_t);
+static int pad_audio_open(void *, int);
static int pad_query_encoding(void *, struct audio_encoding *);
static int pad_set_params(void *, int, int,
audio_params_t *, audio_params_t *,
@@ -99,6 +100,7 @@
static void pad_swvol_dtor(stream_filter_t *);
static const struct audio_hw_if pad_hw_if = {
+ .open = pad_audio_open,
.query_encoding = pad_query_encoding,
.set_params = pad_set_params,
.start_output = pad_start_output,
@@ -341,7 +343,7 @@
#define PAD_BYTES_PER_SEC (44100 * sizeof(int16_t) * 2)
#define TIMENEXTREAD (20 * 1000)
-#define BYTESTOSLEEP (PAD_BYTES_PER_SEC / (1000000 / TIMENEXTREAD))
+#define BYTESTOSLEEP ((PAD_BYTES_PER_SEC / (1000000 / TIMENEXTREAD)) + PAD_BLKSIZE)
int
pad_read(dev_t dev, struct uio *uio, int flags)
@@ -420,6 +422,19 @@
}
static int
+pad_audio_open(void *opaque, int flags)
+{
+ pad_softc_t *sc;
+ sc = opaque;
+
+ if (sc->sc_open == 0)
+ return EIO;
+
+ getmicrotime(&sc->sc_last);
+ return 0;
+}
+
+static int
pad_query_encoding(void *opaque, struct audio_encoding *ae)
{
pad_softc_t *sc;
@@ -477,6 +492,8 @@
sc = (pad_softc_t *)opaque;
KASSERT(mutex_owned(&sc->sc_lock));
+ if (!sc->sc_open)
+ return EIO;
sc->sc_intr = intr;
sc->sc_intrarg = intrarg;
diff -r 744302c8607b -r f28ac2515ded tests/dev/audio/h_pad.c
--- a/tests/dev/audio/h_pad.c Sat Oct 15 06:50:13 2016 +0000
+++ b/tests/dev/audio/h_pad.c Sat Oct 15 07:08:06 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: h_pad.c,v 1.1 2010/08/04 13:15:15 pooka Exp $ */
+/* $NetBSD: h_pad.c,v 1.2 2016/10/15 07:08:06 nat Exp $ */
/*
* Copyright (c) 2010 Antti Kantee. All Rights Reserved.
@@ -56,14 +56,14 @@
ssize_t n;
rump_init();
+ padfd = rump_sys_open("/dev/pad0", O_RDONLY);
+ if (padfd == -1)
+ err(1, "open pad");
+
audiofd = rump_sys_open("/dev/audio0", O_RDWR);
if (audiofd == -1)
err(1, "open audio");
- padfd = rump_sys_open("/dev/pad0", O_RDONLY);
- if (padfd == -1)
- err(1, "open pad");
-
if ((n = rump_sys_write(audiofd, musa, sizeof(musa))) != sizeof(musa))
err(1, "write");
Home |
Main Index |
Thread Index |
Old Index