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

@ -255,17 +255,22 @@ static int snd_pcm_dshare_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
static snd_pcm_state_t snd_pcm_dshare_state(snd_pcm_t *pcm)
{
snd_pcm_direct_t *dshare = pcm->private_data;
int err;
snd_pcm_state_t state;
state = snd_pcm_state(dshare->spcm);
switch (state) {
case SND_PCM_STATE_XRUN:
case SND_PCM_STATE_SUSPENDED:
case SND_PCM_STATE_DISCONNECTED:
dshare->state = state;
return state;
case SND_PCM_STATE_XRUN:
if ((err = snd_pcm_direct_slave_recover(dshare)) < 0)
return err;
break;
default:
break;
}
snd_pcm_direct_client_chk_xrun(dshare, pcm);
if (dshare->state == STATE_RUN_PENDING)
return SNDRV_PCM_STATE_RUNNING;
return dshare->state;
@ -646,7 +651,7 @@ static const snd_pcm_fast_ops_t snd_pcm_dshare_fast_ops = {
.avail_update = snd_pcm_dshare_avail_update,
.mmap_commit = snd_pcm_dshare_mmap_commit,
.htimestamp = snd_pcm_dshare_htimestamp,
.poll_descriptors = NULL,
.poll_descriptors = snd_pcm_direct_poll_descriptors,
.poll_descriptors_count = NULL,
.poll_revents = snd_pcm_direct_poll_revents,
};