pcm: improve handling for snd_pcm_wait()

The snd_pcm_wait() function is called also internally from
the various plugins to wait for the drain with -1 and from i/o
routines in pcm.c.

Define two special negative timeout values to distinguish the
drain and i/o wait and calculate the maximal timeout according
the wait place.

Fixes: https://github.com/alsa-project/alsa-lib/issues/228
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2023-05-02 16:56:49 +02:00
parent 1de6f99c7d
commit e2d9e41174
9 changed files with 55 additions and 10 deletions

View file

@ -522,7 +522,7 @@ static int ioplug_drain_via_poll(snd_pcm_t *pcm)
/* in non-blocking mode, let application to poll() by itself */
if (io->data->nonblock)
return -EAGAIN;
if (snd_pcm_wait_nocheck(pcm, -1) < 0)
if (snd_pcm_wait_nocheck(pcm, SND_PCM_WAIT_DRAIN) < 0)
break;
}