mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-09 13:30:03 -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
|
|
@ -426,19 +426,7 @@ static int snd_pcm_dmix_sync_ptr(snd_pcm_t *pcm)
|
|||
snd_pcm_direct_t *dmix = pcm->private_data;
|
||||
int err;
|
||||
|
||||
switch (snd_pcm_state(dmix->spcm)) {
|
||||
case SND_PCM_STATE_DISCONNECTED:
|
||||
dmix->state = SND_PCM_STATE_DISCONNECTED;
|
||||
return -ENODEV;
|
||||
case SND_PCM_STATE_XRUN:
|
||||
case SND_PCM_STATE_SUSPENDED:
|
||||
if ((err = snd_pcm_direct_slave_recover(dmix)) < 0)
|
||||
return err;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
err = snd_pcm_direct_client_chk_xrun(dmix, pcm);
|
||||
err = snd_pcm_direct_check_xrun(dmix, pcm);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (dmix->slowptr)
|
||||
|
|
@ -454,22 +442,8 @@ 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_DISCONNECTED:
|
||||
dmix->state = state;
|
||||
return state;
|
||||
case SND_PCM_STATE_XRUN:
|
||||
case SND_PCM_STATE_SUSPENDED:
|
||||
if ((err = snd_pcm_direct_slave_recover(dmix)) < 0)
|
||||
return err;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
snd_pcm_direct_client_chk_xrun(dmix, pcm);
|
||||
|
||||
snd_pcm_direct_check_xrun(dmix, pcm);
|
||||
if (dmix->state == STATE_RUN_PENDING)
|
||||
return SNDRV_PCM_STATE_RUNNING;
|
||||
return dmix->state;
|
||||
|
|
@ -832,16 +806,7 @@ static snd_pcm_sframes_t snd_pcm_dmix_mmap_commit(snd_pcm_t *pcm,
|
|||
snd_pcm_direct_t *dmix = pcm->private_data;
|
||||
int err;
|
||||
|
||||
switch (snd_pcm_state(dmix->spcm)) {
|
||||
case SND_PCM_STATE_XRUN:
|
||||
case SND_PCM_STATE_SUSPENDED:
|
||||
if ((err = snd_pcm_direct_slave_recover(dmix)) < 0)
|
||||
return err;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
err = snd_pcm_direct_client_chk_xrun(dmix, pcm);
|
||||
err = snd_pcm_direct_check_xrun(dmix, pcm);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (! size)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue