mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-06 13:29:59 -05:00
pcm: direct: Move slave PCM state checks into XRUN check helper
The check of slave PCM state is always done before the client's recoveries count check, so let's merge them to the common helper. Also rename the helper function to snd_pcm_direct_check_xrun() as it's checking both slave and client states now. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
b3ce9cb839
commit
3577a7a26b
5 changed files with 33 additions and 132 deletions
|
|
@ -658,8 +658,23 @@ int snd_pcm_direct_slave_recover(snd_pcm_direct_t *direct)
|
|||
* enter xrun or suspended state, if slave xrun occurred or suspended
|
||||
* @return: 0 for no xrun/suspend or a negative error code for xrun/suspend
|
||||
*/
|
||||
int snd_pcm_direct_client_chk_xrun(snd_pcm_direct_t *direct, snd_pcm_t *pcm)
|
||||
int snd_pcm_direct_check_xrun(snd_pcm_direct_t *direct, snd_pcm_t *pcm)
|
||||
{
|
||||
int err;
|
||||
|
||||
switch (snd_pcm_state(direct->spcm)) {
|
||||
case SND_PCM_STATE_DISCONNECTED:
|
||||
direct->state = SNDRV_PCM_STATE_DISCONNECTED;
|
||||
return -ENODEV;
|
||||
case SND_PCM_STATE_XRUN:
|
||||
case SND_PCM_STATE_SUSPENDED:
|
||||
if ((err = snd_pcm_direct_slave_recover(direct)) < 0)
|
||||
return err;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (direct->state == SND_PCM_STATE_XRUN)
|
||||
return -EPIPE;
|
||||
else if (direct->state == SND_PCM_STATE_SUSPENDED)
|
||||
|
|
@ -750,19 +765,11 @@ timer_changed:
|
|||
}
|
||||
empty = avail < pcm->avail_min;
|
||||
}
|
||||
switch (snd_pcm_state(dmix->spcm)) {
|
||||
case SND_PCM_STATE_XRUN:
|
||||
case SND_PCM_STATE_SUSPENDED:
|
||||
/* recover slave and update client state to xrun
|
||||
* before returning POLLERR
|
||||
*/
|
||||
snd_pcm_direct_slave_recover(dmix);
|
||||
snd_pcm_direct_client_chk_xrun(dmix, pcm);
|
||||
/* fallthrough */
|
||||
case SND_PCM_STATE_SETUP:
|
||||
|
||||
if (snd_pcm_direct_check_xrun(dmix, pcm) < 0 ||
|
||||
snd_pcm_state(dmix->spcm) == SND_PCM_STATE_SETUP) {
|
||||
events |= POLLERR;
|
||||
break;
|
||||
default:
|
||||
} else {
|
||||
if (empty) {
|
||||
/* here we have a race condition:
|
||||
* if period event arrived after the avail_update call
|
||||
|
|
@ -786,7 +793,6 @@ timer_changed:
|
|||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
*revents = events;
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue