Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/sound/pcm/sound.c
| Show First 20 Lines • Show All 214 Lines • ▼ Show 20 Lines | pcm_killchans(struct snddev_info *d) | ||||
| PCM_BUSYASSERT(d); | PCM_BUSYASSERT(d); | ||||
| for (;;) { | for (;;) { | ||||
| again = false; | again = false; | ||||
| /* Make sure all channels are stopped. */ | /* Make sure all channels are stopped. */ | ||||
| CHN_FOREACH(ch, d, channels.pcm) { | CHN_FOREACH(ch, d, channels.pcm) { | ||||
| CHN_LOCK(ch); | CHN_LOCK(ch); | ||||
| if ((ch->flags & CHN_F_SLEEPING) == 0 && | if (ch->intr_cv.cv_waiters == 0 && CHN_STOPPED(ch) && | ||||
| CHN_STOPPED(ch) && ch->inprog == 0) { | ch->inprog == 0) { | ||||
markj: Checking the waiters field directly like this is a bit of a layering violation, though the… | |||||
Done Inline ActionsIn order to get past this loop we'll have to eventually execute this check without waiters for all channels, so I'm pretty sure it's fine. christos: In order to get past this loop we'll have to eventually execute this check without waiters for… | |||||
Done Inline ActionsAh sorry, you meant what happens if the lines below this check are executed. Still, nothing. chn_shutdown() calls CHN_BROADCAST() which also checks for cv_waiters, and the rest shouldn't concern the value of cv_waiters anyway. christos: Ah sorry, you meant what happens if the lines //below// this check are executed. Still, nothing. | |||||
| CHN_UNLOCK(ch); | CHN_UNLOCK(ch); | ||||
| continue; | continue; | ||||
| } | } | ||||
| chn_shutdown(ch); | chn_shutdown(ch); | ||||
| if (ch->direction == PCMDIR_PLAY) | if (ch->direction == PCMDIR_PLAY) | ||||
| chn_flush(ch); | chn_flush(ch); | ||||
| else | else | ||||
| chn_abort(ch); | chn_abort(ch); | ||||
| ▲ Show 20 Lines • Show All 568 Lines • Show Last 20 Lines | |||||
Checking the waiters field directly like this is a bit of a layering violation, though the sound driver framework already does this. In fact, cv_waiters == 0 implies there are no waiters, but the converse is not true: cv_waiters != 0 does not imply that there are waiters.
What happens if the code below is executed and there are no waiters? Is it harmless?