Don't use simple_locks; we can't hold them while calling malloc and
friends.
This commit is contained in:
parent
1b9393837d
commit
f77081f364
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: audio.c,v 1.203 2006/04/18 19:15:27 jmcneill Exp $ */
|
||||
/* $NetBSD: audio.c,v 1.204 2006/04/19 14:10:58 jmcneill 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.203 2006/04/18 19:15:27 jmcneill Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.204 2006/04/19 14:10:58 jmcneill Exp $");
|
||||
|
||||
#include "audio.h"
|
||||
#if NAUDIO > 0
|
||||
|
@ -81,7 +81,6 @@ __KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.203 2006/04/18 19:15:27 jmcneill Exp $")
|
|||
#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>
|
||||
|
@ -309,7 +308,7 @@ audioattach(struct device *parent, struct device *self, void *aux)
|
|||
sc->hw_hdl = hdlp;
|
||||
sc->sc_dev = parent;
|
||||
sc->sc_opencnt = 0;
|
||||
simple_lock_init(&sc->sc_pfiltlock);
|
||||
sc->sc_writing = sc->sc_waitcomp = 0;
|
||||
|
||||
error = audio_alloc_ring(sc, &sc->sc_pr, AUMODE_PLAY, AU_RING_SIZE);
|
||||
if (error) {
|
||||
|
@ -662,7 +661,10 @@ audio_setup_pfilters(struct audio_softc *sc, const audio_params_t *pp,
|
|||
audio_params_t *to_param;
|
||||
int i, n;
|
||||
|
||||
simple_lock(&sc->sc_pfiltlock);
|
||||
while (sc->sc_writing) {
|
||||
sc->sc_waitcomp = 1;
|
||||
(void)tsleep(sc, 0, "audioch", 10*hz);
|
||||
}
|
||||
|
||||
memset(pf, 0, sizeof(pf));
|
||||
memset(ps, 0, sizeof(ps));
|
||||
|
@ -687,7 +689,7 @@ audio_setup_pfilters(struct audio_softc *sc, const audio_params_t *pp,
|
|||
pf[i]->dtor(pf[i]);
|
||||
audio_stream_dtor(&ps[i]);
|
||||
}
|
||||
simple_unlock(&sc->sc_pfiltlock);
|
||||
sc->sc_waitcomp = 0;
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
|
@ -718,7 +720,7 @@ audio_setup_pfilters(struct audio_softc *sc, const audio_params_t *pp,
|
|||
audio_print_params("[HW]", &sc->sc_pr.s.param);
|
||||
#endif /* AUDIO_DEBUG */
|
||||
|
||||
simple_unlock(&sc->sc_pfiltlock);
|
||||
sc->sc_waitcomp = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -797,16 +799,12 @@ audio_destruct_pfilters(struct audio_softc *sc)
|
|||
{
|
||||
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
|
||||
|
@ -1913,7 +1911,8 @@ audio_write(struct audio_softc *sc, struct uio *uio, int ioflag)
|
|||
* splaudio() enclosure
|
||||
*/
|
||||
|
||||
simple_lock(&sc->sc_pfiltlock);
|
||||
sc->sc_writing = 1;
|
||||
|
||||
if (sc->sc_npfilters > 0) {
|
||||
filter = sc->sc_pfilters[0];
|
||||
filter->set_fetcher(filter, &ufetcher.base);
|
||||
|
@ -1925,7 +1924,10 @@ audio_write(struct audio_softc *sc, struct uio *uio, int ioflag)
|
|||
fetcher = &ufetcher.base;
|
||||
}
|
||||
error = fetcher->fetch_to(fetcher, &stream, cc);
|
||||
simple_unlock(&sc->sc_pfiltlock);
|
||||
|
||||
sc->sc_writing = 0;
|
||||
if (sc->sc_waitcomp)
|
||||
wakeup(sc);
|
||||
|
||||
s = splaudio();
|
||||
if (sc->sc_npfilters > 0) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: audio_if.h,v 1.60 2006/04/18 19:15:27 jmcneill Exp $ */
|
||||
/* $NetBSD: audio_if.h,v 1.61 2006/04/19 14:10:58 jmcneill Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Havard Eidnes.
|
||||
|
@ -37,7 +37,6 @@
|
|||
#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 */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: audiovar.h,v 1.35 2006/04/18 19:15:27 jmcneill Exp $ */
|
||||
/* $NetBSD: audiovar.h,v 1.36 2006/04/19 14:10:59 jmcneill Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -174,7 +174,9 @@ struct audio_softc {
|
|||
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;
|
||||
int sc_writing;
|
||||
int sc_waitcomp;
|
||||
int sc_changing;
|
||||
|
||||
/**
|
||||
* hardware
|
||||
|
|
Loading…
Reference in New Issue