diff --git a/sys/dev/sound/dummy.c b/sys/dev/sound/dummy.c --- a/sys/dev/sound/dummy.c +++ b/sys/dev/sound/dummy.c @@ -65,6 +65,7 @@ struct dummy_chan chans[DUMMY_NCHAN]; struct callout callout; struct mtx *lock; + bool stopped; }; static bool @@ -92,6 +93,9 @@ struct dummy_chan *ch; int i = 0; + if (sc->stopped) + return; + /* Do not reschedule if no channel is running. */ if (!dummy_active(sc)) return; @@ -108,7 +112,8 @@ chn_intr(ch->chan); snd_mtxlock(sc->lock); } - callout_schedule(&sc->callout, 1); + if (!sc->stopped) + callout_schedule(&sc->callout, 1); } static int @@ -195,6 +200,11 @@ snd_mtxlock(sc->lock); + if (sc->stopped) { + snd_mtxunlock(sc->lock); + return (0); + } + switch (go) { case PCMTRIG_START: ch->ptr = 0; @@ -345,8 +355,11 @@ struct dummy_softc *sc = device_get_softc(dev); int err; - err = pcm_unregister(dev); + snd_mtxlock(sc->lock); + sc->stopped = true; + snd_mtxunlock(sc->lock); callout_drain(&sc->callout); + err = pcm_unregister(dev); snd_mtxfree(sc->lock); return (err);