From: Jaroslav Kysela Date: Tue, 23 Mar 2004 13:29:52 +0000 (+0000) Subject: Added mmap_avail() check to snd_pcm_wait() function X-Git-Tag: v1.0.4~10 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=f70e0fd46840fc5de2544495a2fc0f2cf2bfbde7;p=alsa-lib.git Added mmap_avail() check to snd_pcm_wait() function --- diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 971dba08..724a97c2 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -2066,6 +2066,20 @@ int snd_pcm_wait(snd_pcm_t *pcm, int timeout) struct pollfd pfd; unsigned short revents; int err, err_poll; + + if (snd_pcm_mmap_avail(pcm) >= pcm->avail_min) { + /* check more precisely */ + switch (snd_pcm_state(pcm)) { + case SND_PCM_STATE_XRUN: + return -EPIPE; + case SND_PCM_STATE_SUSPENDED: + return -ESTRPIPE; + case SND_PCM_STATE_DISCONNECTED: + return -ENOTTY; /* linux VFS does this? */ + default: + return 1; + } + } err = snd_pcm_poll_descriptors(pcm, &pfd, 1); assert(err == 1); err_poll = poll(&pfd, 1, timeout);