Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/sound/pcm/vchan.c
| Show First 20 Lines • Show All 832 Lines • ▼ Show 20 Lines | vchan_destroy(struct pcm_channel *c) | ||||
| parent = c->parentchannel; | parent = c->parentchannel; | ||||
| PCM_BUSYASSERT(c->parentsnddev); | PCM_BUSYASSERT(c->parentsnddev); | ||||
| CHN_LOCKASSERT(parent); | CHN_LOCKASSERT(parent); | ||||
| CHN_UNLOCK(c); | CHN_UNLOCK(c); | ||||
| if (!(parent->flags & CHN_F_BUSY)) | |||||
| return (EBUSY); | |||||
| if (CHN_EMPTY(parent, children)) | |||||
| return (EINVAL); | |||||
| /* remove us from our parent's children list */ | /* remove us from our parent's children list */ | ||||
| CHN_REMOVE(parent, c, children); | CHN_REMOVE(parent, c, children); | ||||
| if (CHN_EMPTY(parent, children)) { | if (CHN_EMPTY(parent, children)) { | ||||
| parent->flags &= ~(CHN_F_BUSY | CHN_F_HAS_VCHAN); | parent->flags &= ~(CHN_F_BUSY | CHN_F_HAS_VCHAN); | ||||
| chn_reset(parent, parent->format, parent->speed); | chn_reset(parent, parent->format, parent->speed); | ||||
christos: Neither this nor the left diff guarantee us that the vchan we are removing from the list has… | |||||
Done Inline ActionsDo I see that correctly, SLIST_REMOVE() will just happily dereference the terminal NULL pointer of the list, when the element to be removed is not present? Yes, I think CHN_REMOVE_SAFE is a good choice here. dev_submerge.ch: Do I see that correctly, `SLIST_REMOVE()` will just happily dereference the terminal NULL… | |||||
Done Inline ActionsYes, there is no checking whatsoever. christos: Yes, there is no checking whatsoever. | |||||
Done Inline ActionsThis check shouldn't be necessary anymore. But how about an assertion that the channel isn't in use, per CHN_F_BUSY flag? dev_submerge.ch: This check shouldn't be necessary anymore. But how about an assertion that the channel isn't in… | |||||
Done Inline ActionsI agree with removing the check. However, I am actually not sure whether the correct behavior here is to not go through with the deletion if the channel is busy or to just force it. christos: I agree with removing the check. However, I am actually not sure whether the correct behavior… | |||||
Not Done Inline ActionsSure, at this point we should go through with the deletion. An assertion would just help to catch programming errors where the vchan is not properly closed and shut down first, in debug builds. dev_submerge.ch: Sure, at this point we should go through with the deletion. An assertion would just help to… | |||||
| } | } | ||||
| CHN_UNLOCK(parent); | CHN_UNLOCK(parent); | ||||
| /* destroy ourselves */ | /* destroy ourselves */ | ||||
| chn_kill(c); | chn_kill(c); | ||||
| CHN_LOCK(parent); | CHN_LOCK(parent); | ||||
| ▲ Show 20 Lines • Show All 258 Lines • Show Last 20 Lines | |||||
Neither this nor the left diff guarantee us that the vchan we are removing from the list has actually been added. Perhaps it's better to use CHN_REMOVE_SAFE instead?