mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-06 13:29:59 -05:00
pcm: Add the PCM state checks to plugins
I noticed that some plugin codes have no proper PCM state checks and it results in expected outcomes. For example, when snd_pcm_drain() is called for a dmix PCM after calling snd_pcm_drop(), it stalls unexpectedly. It's just because its drain callback doesn't expect the SND_PCM_SETUP state. We can fix such a bug in each place one by one, but a safer way would be to filter out all such cases commonly in the PCM API functions themselves. This patch adds the PCM state sanity checks to major API functions so that they return -EBADFD when called in the unexpected PCM states. As well as for the thread-safety extension, it'd be a question of the performance; again at this time, the hw PCM is considered as an exception, and it has pcm->own_state_check flag set, which means that the common PCM state checks are skipped. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
3e4887c112
commit
ea74ebbe4d
3 changed files with 50 additions and 0 deletions
|
|
@ -234,6 +234,7 @@ struct _snd_pcm {
|
|||
* use the mmaped buffer of the slave
|
||||
*/
|
||||
unsigned int donot_close: 1; /* don't close this PCM */
|
||||
unsigned int own_state_check:1; /* plugin has own PCM state check */
|
||||
snd_pcm_channel_info_t *mmap_channels;
|
||||
snd_pcm_channel_area_t *running_areas;
|
||||
snd_pcm_channel_area_t *stopped_areas;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue