Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-3-0]: src/sys/dev Pull up following revision(s) (requested by jmc...
details: https://anonhg.NetBSD.org/src/rev/ac2a94a9387e
branches: netbsd-3-0
changeset: 579197:ac2a94a9387e
user: tron <tron%NetBSD.org@localhost>
date: Tue Apr 18 21:15:07 2006 +0000
description:
Pull up following revision(s) (requested by jmcneill in ticket #1277):
sys/dev/audio_if.h: revision 1.60 via patch
sys/dev/audiovar.h: revision 1.35 via patch
sys/dev/audio.c: revision 1.203 via patch
Protect audio_write's filter graph from being modified in the
middle of a
write. Fixes the 'audioctl of death' problem (PR#32563).
diffstat:
sys/dev/audio.c | 33 +++++++++++++++++++++++++++++----
sys/dev/audio_if.h | 3 ++-
sys/dev/audiovar.h | 3 ++-
3 files changed, 33 insertions(+), 6 deletions(-)
diffs (168 lines):
diff -r e922556541c3 -r ac2a94a9387e sys/dev/audio.c
--- a/sys/dev/audio.c Mon Apr 17 23:21:23 2006 +0000
+++ b/sys/dev/audio.c Tue Apr 18 21:15:07 2006 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.192.4.2 2005/06/11 11:18:32 tron Exp $ */
+/* $NetBSD: audio.c,v 1.192.4.2.2.1 2006/04/18 21:15:07 tron Exp $ */
/*
* Copyright (c) 1991-1993 Regents of the University of California.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.192.4.2 2005/06/11 11:18:32 tron Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.192.4.2.2.1 2006/04/18 21:15:07 tron Exp $");
#include "audio.h"
#if NAUDIO > 0
@@ -81,6 +81,7 @@
#include <sys/conf.h>
#include <sys/audioio.h>
#include <sys/device.h>
+#include <sys/lock.h>
#include <dev/audio_if.h>
#include <dev/audiovar.h>
@@ -157,9 +158,11 @@
static void audio_stream_dtor(audio_stream_t *);
static int audio_stream_ctor(audio_stream_t *, const audio_params_t *, int);
static void stream_filter_list_append
- (stream_filter_list_t *, stream_filter_factory_t, const audio_params_t *);
+ (stream_filter_list_t *, stream_filter_factory_t,
+ const audio_params_t *);
static void stream_filter_list_prepend
- (stream_filter_list_t *, stream_filter_factory_t, const audio_params_t *);
+ (stream_filter_list_t *, stream_filter_factory_t,
+ const audio_params_t *);
static void stream_filter_list_set
(stream_filter_list_t *, int, stream_filter_factory_t,
const audio_params_t *);
@@ -305,6 +308,7 @@
sc->hw_if = hwp;
sc->hw_hdl = hdlp;
sc->sc_dev = parent;
+ simple_lock_init(&sc->sc_pfiltlock);
error = audio_alloc_ring(sc, &sc->sc_pr, AUMODE_PLAY, AU_RING_SIZE);
if (error) {
@@ -657,6 +661,8 @@
audio_params_t *to_param;
int i, n;
+ simple_lock(&sc->sc_pfiltlock);
+
memset(pf, 0, sizeof(pf));
memset(ps, 0, sizeof(ps));
from_param = pp;
@@ -680,6 +686,7 @@
pf[i]->dtor(pf[i]);
audio_stream_dtor(&ps[i]);
}
+ simple_unlock(&sc->sc_pfiltlock);
return EINVAL;
}
@@ -709,6 +716,8 @@
}
audio_print_params("[HW]", &sc->sc_pr.s.param);
#endif /* AUDIO_DEBUG */
+
+ simple_unlock(&sc->sc_pfiltlock);
return 0;
}
@@ -787,12 +796,16 @@
{
int i;
+ simple_lock(&sc->sc_pfiltlock);
+
for (i = 0; i < sc->sc_npfilters; i++) {
sc->sc_pfilters[i]->dtor(sc->sc_pfilters[i]);
sc->sc_pfilters[i] = NULL;
audio_stream_dtor(&sc->sc_pstreams[i]);
}
sc->sc_npfilters = 0;
+
+ simple_unlock(&sc->sc_pfiltlock);
}
static void
@@ -859,10 +872,12 @@
stream_filter_factory_t factory,
const audio_params_t *param)
{
+
if (i < 0 || i >= AUDIO_MAX_FILTERS) {
printf("%s: invalid index: %d\n", __func__, i);
return;
}
+
list->filters[i].factory = factory;
list->filters[i].param = *param;
if (list->req_size <= i)
@@ -1893,12 +1908,21 @@
* work with a temporary audio_stream_t to narrow
* splaudio() enclosure
*/
+
+ simple_lock(&sc->sc_pfiltlock);
if (sc->sc_npfilters > 0) {
filter = sc->sc_pfilters[0];
filter->set_fetcher(filter, &ufetcher.base);
}
cc = stream.end - stream.start;
+ if (sc->sc_npfilters > 0) {
+ fetcher = &sc->sc_pfilters[sc->sc_npfilters - 1]->base;
+ } else {
+ fetcher = &ufetcher.base;
+ }
error = fetcher->fetch_to(fetcher, &stream, cc);
+ simple_unlock(&sc->sc_pfiltlock);
+
s = splaudio();
if (sc->sc_npfilters > 0) {
cb->fstamp += audio_stream_get_used(sc->sc_pustream)
@@ -1943,6 +1967,7 @@
audio_fill_silence(&cb->s.param, einp, cc);
}
}
+
return error;
}
diff -r e922556541c3 -r ac2a94a9387e sys/dev/audio_if.h
--- a/sys/dev/audio_if.h Mon Apr 17 23:21:23 2006 +0000
+++ b/sys/dev/audio_if.h Tue Apr 18 21:15:07 2006 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audio_if.h,v 1.55 2005/01/10 22:01:37 kent Exp $ */
+/* $NetBSD: audio_if.h,v 1.55.18.1 2006/04/18 21:15:07 tron Exp $ */
/*
* Copyright (c) 1994 Havard Eidnes.
@@ -37,6 +37,7 @@
#ifndef _SYS_DEV_AUDIO_IF_H_
#define _SYS_DEV_AUDIO_IF_H_
#include <sys/types.h>
+#include <sys/lock.h>
#include <sys/audioio.h>
/* check we have an audio(4) configured into kernel */
diff -r e922556541c3 -r ac2a94a9387e sys/dev/audiovar.h
--- a/sys/dev/audiovar.h Mon Apr 17 23:21:23 2006 +0000
+++ b/sys/dev/audiovar.h Tue Apr 18 21:15:07 2006 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audiovar.h,v 1.32 2005/01/10 22:01:37 kent Exp $ */
+/* $NetBSD: audiovar.h,v 1.32.18.1 2006/04/18 21:15:07 tron Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -174,6 +174,7 @@
audio_stream_t sc_pstreams[AUDIO_MAX_FILTERS];
stream_filter_t *sc_pfilters[AUDIO_MAX_FILTERS];
struct audio_ringbuffer sc_pr; /* Play ring */
+ struct simplelock sc_pfiltlock;
/**
* hardware
Home |
Main Index |
Thread Index |
Old Index