mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
pcm: direct: Propagate error code from snd_pcm_direct_client_chk_xrun()
Change the snd_pcm_direct_client_chk_xrun() function to return the current XRUN state via an error code instead of the state change. This allows the caller more straightforwardly returning its error, and also covers the case where XRUN has been set but the function gets called twice. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
5b035bfa4a
commit
29fbe34a0d
4 changed files with 21 additions and 14 deletions
|
|
@ -633,7 +633,7 @@ int snd_pcm_direct_slave_recover(snd_pcm_direct_t *direct)
|
|||
|
||||
/*
|
||||
* enter xrun state, if slave xrun occurred
|
||||
* @return: 0 - no xrun >0: xrun happened
|
||||
* @return: 0 for no xrun or a negative error code for xrun
|
||||
*/
|
||||
int snd_pcm_direct_client_chk_xrun(snd_pcm_direct_t *direct, snd_pcm_t *pcm)
|
||||
{
|
||||
|
|
@ -650,8 +650,9 @@ int snd_pcm_direct_client_chk_xrun(snd_pcm_direct_t *direct, snd_pcm_t *pcm)
|
|||
* snd_pcm_direct_clear_timer_queue(direct);
|
||||
*/
|
||||
direct->state = SND_PCM_STATE_XRUN;
|
||||
return 1;
|
||||
}
|
||||
if (direct->state == SND_PCM_STATE_XRUN)
|
||||
return -EPIPE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -437,8 +437,9 @@ static int snd_pcm_dmix_sync_ptr(snd_pcm_t *pcm)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
if (snd_pcm_direct_client_chk_xrun(dmix, pcm))
|
||||
return -EPIPE;
|
||||
err = snd_pcm_direct_client_chk_xrun(dmix, pcm);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (dmix->slowptr)
|
||||
snd_pcm_hwsync(dmix->spcm);
|
||||
|
||||
|
|
@ -840,8 +841,9 @@ static snd_pcm_sframes_t snd_pcm_dmix_mmap_commit(snd_pcm_t *pcm,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
if (snd_pcm_direct_client_chk_xrun(dmix, pcm))
|
||||
return -EPIPE;
|
||||
err = snd_pcm_direct_client_chk_xrun(dmix, pcm);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (! size)
|
||||
return 0;
|
||||
snd_pcm_mmap_appl_forward(pcm, size);
|
||||
|
|
|
|||
|
|
@ -212,8 +212,9 @@ static int snd_pcm_dshare_sync_ptr(snd_pcm_t *pcm)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
if (snd_pcm_direct_client_chk_xrun(dshare, pcm))
|
||||
return -EPIPE;
|
||||
err = snd_pcm_direct_client_chk_xrun(dshare, pcm);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (dshare->slowptr)
|
||||
snd_pcm_hwsync(dshare->spcm);
|
||||
|
||||
|
|
@ -539,8 +540,9 @@ static snd_pcm_sframes_t snd_pcm_dshare_mmap_commit(snd_pcm_t *pcm,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
if (snd_pcm_direct_client_chk_xrun(dshare, pcm))
|
||||
return -EPIPE;
|
||||
err = snd_pcm_direct_client_chk_xrun(dshare, pcm);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (! size)
|
||||
return 0;
|
||||
snd_pcm_mmap_appl_forward(pcm, size);
|
||||
|
|
|
|||
|
|
@ -145,8 +145,9 @@ static int snd_pcm_dsnoop_sync_ptr(snd_pcm_t *pcm)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
if (snd_pcm_direct_client_chk_xrun(dsnoop, pcm))
|
||||
return -EPIPE;
|
||||
err = snd_pcm_direct_client_chk_xrun(dsnoop, pcm);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (dsnoop->slowptr)
|
||||
snd_pcm_hwsync(dsnoop->spcm);
|
||||
old_slave_hw_ptr = dsnoop->slave_hw_ptr;
|
||||
|
|
@ -430,8 +431,9 @@ static snd_pcm_sframes_t snd_pcm_dsnoop_mmap_commit(snd_pcm_t *pcm,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
if (snd_pcm_direct_client_chk_xrun(dsnoop, pcm))
|
||||
return -EPIPE;
|
||||
err = snd_pcm_direct_client_chk_xrun(dsnoop, pcm);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (dsnoop->state == SND_PCM_STATE_RUNNING) {
|
||||
err = snd_pcm_dsnoop_sync_ptr(pcm);
|
||||
if (err < 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue