Index: pcm/dsp.c =================================================================== RCS file: /home/ncvs/src/sys/dev/sound/pcm/dsp.c,v retrieving revision 1.15.2.10 diff -u -r1.15.2.10 dsp.c --- pcm/dsp.c 2001/08/24 18:39:21 1.15.2.10 +++ pcm/dsp.c 2001/09/14 14:34:49 @@ -245,10 +245,10 @@ chn_reset(rdch, fmt); if (flags & O_NONBLOCK) rdch->flags |= CHN_F_NBIO; - } else { + } else CHN_LOCK(rdch); - pcm_chnref(rdch, 1); - } + + pcm_chnref(rdch, 1); CHN_UNLOCK(rdch); } if (wrch) { @@ -256,10 +256,10 @@ chn_reset(wrch, fmt); if (flags & O_NONBLOCK) wrch->flags |= CHN_F_NBIO; - } else { + } else CHN_LOCK(wrch); - pcm_chnref(wrch, 1); - } + + pcm_chnref(wrch, 1); CHN_UNLOCK(wrch); } splx(s); Index: pcm/sndstat.c =================================================================== RCS file: /home/ncvs/src/sys/dev/sound/pcm/sndstat.c,v retrieving revision 1.4.2.1 diff -u -r1.4.2.1 sndstat.c --- pcm/sndstat.c 2001/08/01 03:41:03 1.4.2.1 +++ pcm/sndstat.c 2001/09/14 17:41:15 @@ -246,6 +246,12 @@ return 0; } +int +sndstat_busy(void) +{ + return (sndstat_isopen); +} + static void sndstat_sysinit(void *p) { Index: pcm/sound.c =================================================================== RCS file: /home/ncvs/src/sys/dev/sound/pcm/sound.c,v retrieving revision 1.17.2.11 diff -u -r1.17.2.11 sound.c --- pcm/sound.c 2001/08/02 14:50:59 1.17.2.11 +++ pcm/sound.c 2001/09/14 17:34:27 @@ -416,19 +416,24 @@ snd_mtxlock(d->lock); if (d->inprog) { - device_printf(dev, "unregister: operation in progress"); + device_printf(dev, "unregister: operation in progress\n"); snd_mtxunlock(d->lock); return EBUSY; } + if (sndstat_busy() != 0) { + device_printf(dev, "unregister: sndstat busy\n"); + snd_mtxunlock(d->lock); + return EBUSY; + } SLIST_FOREACH(sce, &d->channels, link) { if (sce->channel->refcount > 0) { - device_printf(dev, "unregister: channel busy"); + device_printf(dev, "unregister: channel busy\n"); snd_mtxunlock(d->lock); return EBUSY; } } if (mixer_uninit(dev)) { - device_printf(dev, "unregister: mixer busy"); + device_printf(dev, "unregister: mixer busy\n"); snd_mtxunlock(d->lock); return EBUSY; } Index: pcm/sound.h =================================================================== RCS file: /home/ncvs/src/sys/dev/sound/pcm/sound.h,v retrieving revision 1.10.2.10 diff -u -r1.10.2.10 sound.h --- pcm/sound.h 2001/08/01 03:41:03 1.10.2.10 +++ pcm/sound.h 2001/09/14 17:34:39 @@ -261,6 +261,7 @@ void snd_mtxassert(void *m); void snd_mtxlock(void *m); void snd_mtxunlock(void *m); +int sndstat_busy(void); #endif /* _KERNEL */ /* usage of flags in device config entry (config file) */