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:
Takashi Iwai 2022-03-03 15:04:09 +01:00
parent 5b035bfa4a
commit 29fbe34a0d
4 changed files with 21 additions and 14 deletions

View file

@ -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;
}