From 14ef1eed0d59834c781d84b22b34c15b75ed9036 Mon Sep 17 00:00:00 2001 From: cg Date: Thu, 23 Aug 2001 11:56:07 +0000 Subject: MFS: allow multiple opens of mixer devices --- sys/dev/sound/pcm/mixer.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index ba8a473..cddb515 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -397,14 +397,13 @@ mixer_open(dev_t i_dev, int flags, int mode, struct proc *p) struct snd_mixer *m; intrmask_t s; - s = spltty(); m = i_dev->si_drv1; - if (m->busy) { - splx(s); - return EBUSY; - } - m->busy = 1; + s = spltty(); + snd_mtxlock(m->lock); + + m->busy++; + snd_mtxunlock(m->lock); splx(s); return 0; } @@ -415,14 +414,18 @@ mixer_close(dev_t i_dev, int flags, int mode, struct proc *p) struct snd_mixer *m; intrmask_t s; - s = spltty(); m = i_dev->si_drv1; + s = spltty(); + snd_mtxlock(m->lock); + if (!m->busy) { + snd_mtxunlock(m->lock); splx(s); return EBADF; } - m->busy = 0; + m->busy--; + snd_mtxunlock(m->lock); splx(s); return 0; } -- cgit v1.1