pcm: direct: check state before enter poll on timer

To avoid the chances of timeout, we need to check the enter poll
in state xrun.

Signed-off-by: Andreas Pape <apape@de.adit-jv.com>
Signed-off-by: Mounesh Sutar <mounesh_sutar@mentor.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Andreas Pape 2017-01-10 12:03:54 +05:30 committed by Takashi Iwai
parent 1a9bd0f044
commit 789ee39727
5 changed files with 63 additions and 6 deletions

View file

@ -462,17 +462,22 @@ static int snd_pcm_dmix_sync_ptr(snd_pcm_t *pcm)
static snd_pcm_state_t snd_pcm_dmix_state(snd_pcm_t *pcm)
{
snd_pcm_direct_t *dmix = pcm->private_data;
int err;
snd_pcm_state_t state;
state = snd_pcm_state(dmix->spcm);
switch (state) {
case SND_PCM_STATE_XRUN:
case SND_PCM_STATE_SUSPENDED:
case SND_PCM_STATE_DISCONNECTED:
dmix->state = state;
return state;
case SND_PCM_STATE_XRUN:
if ((err = snd_pcm_direct_slave_recover(dmix)) < 0)
return err;
break;
default:
break;
}
snd_pcm_direct_client_chk_xrun(dmix, pcm);
if (dmix->state == STATE_RUN_PENDING)
return SNDRV_PCM_STATE_RUNNING;
return dmix->state;
@ -968,7 +973,7 @@ static const snd_pcm_fast_ops_t snd_pcm_dmix_fast_ops = {
.avail_update = snd_pcm_dmix_avail_update,
.mmap_commit = snd_pcm_dmix_mmap_commit,
.htimestamp = snd_pcm_dmix_htimestamp,
.poll_descriptors = NULL,
.poll_descriptors = snd_pcm_direct_poll_descriptors,
.poll_descriptors_count = NULL,
.poll_revents = snd_pcm_dmix_poll_revents,
};