mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-05 13:30:00 -05:00
pcm: fix wait condition in snd_pcm_write_areas() to avoid return zero
The hw_ptr might be updated during the snd_pcm_may_wait_for_avail_min() call, so even if it returns zero (OK), the avail must be updated again. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
4694a6643d
commit
c7fc3fdbe2
1 changed files with 19 additions and 10 deletions
|
|
@ -7389,9 +7389,9 @@ snd_pcm_sframes_t snd_pcm_write_areas(snd_pcm_t *pcm, const snd_pcm_channel_area
|
|||
err = avail;
|
||||
goto _end;
|
||||
}
|
||||
if ((state == SND_PCM_STATE_RUNNING &&
|
||||
size > (snd_pcm_uframes_t)avail &&
|
||||
snd_pcm_may_wait_for_avail_min(pcm, avail))) {
|
||||
if (state == SND_PCM_STATE_RUNNING &&
|
||||
size > (snd_pcm_uframes_t)avail) {
|
||||
if (snd_pcm_may_wait_for_avail_min(pcm, avail)) {
|
||||
if (pcm->mode & SND_PCM_NONBLOCK) {
|
||||
err = -EAGAIN;
|
||||
goto _end;
|
||||
|
|
@ -7402,6 +7402,15 @@ snd_pcm_sframes_t snd_pcm_write_areas(snd_pcm_t *pcm, const snd_pcm_channel_area
|
|||
break;
|
||||
goto _again;
|
||||
}
|
||||
/* the snd_pcm_may_wait_for_avail_min may check against the
|
||||
* updated hw.ptr (slaves), get the avail again here
|
||||
*/
|
||||
avail = __snd_pcm_avail_update(pcm);
|
||||
if (avail < 0) {
|
||||
err = avail;
|
||||
goto _end;
|
||||
}
|
||||
}
|
||||
frames = size;
|
||||
if (frames > (snd_pcm_uframes_t) avail)
|
||||
frames = avail;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue