mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
pcm: dmix: Fix doubly resume of slave PCM
The dmix plugin and co may trigger the resume for each instance in snd_pcm_direct_resume(). It means that the slave PCM gets resumed or re-prepared/started by each opened dmix stream, and this may end up with the doubly triggers even though the slave PCM has been already resumed by another dmix stream. For avoiding this conflicts, check the slave PCM state and resume only when it's still in the suspended state. Meanwhile we keep the shadow state updated no matter whether the slave was triggered or not. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
c14b0a08f0
commit
5610b356b5
1 changed files with 7 additions and 0 deletions
|
|
@ -841,6 +841,12 @@ int snd_pcm_direct_resume(snd_pcm_t *pcm)
|
|||
int err;
|
||||
|
||||
snd_pcm_direct_semaphore_down(dmix, DIRECT_IPC_SEM_CLIENT);
|
||||
/* resume only when the slave PCM is still in suspended state */
|
||||
if (snd_pcm_state(dmix->spcm) != SND_PCM_STATE_SUSPENDED) {
|
||||
err = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
err = snd_pcm_resume(dmix->spcm);
|
||||
if (err == -ENOSYS) {
|
||||
/* FIXME: error handling? */
|
||||
|
|
@ -848,6 +854,7 @@ int snd_pcm_direct_resume(snd_pcm_t *pcm)
|
|||
snd_pcm_start(dmix->spcm);
|
||||
err = 0;
|
||||
}
|
||||
out:
|
||||
dmix->state = snd_pcm_state(dmix->spcm);
|
||||
snd_pcm_direct_semaphore_up(dmix, DIRECT_IPC_SEM_CLIENT);
|
||||
return err;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue