pcm: add SND_PCM_EINTR open mode

Add possibility to return -EINTR instead waiting for the event. The
applications may want to handle -EINTR condition themselves.

BugLink: 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-03 11:42:35 +02:00
parent e2d9e41174
commit d6d5982d3a
2 changed files with 3 additions and 1 deletions

View file

@ -393,6 +393,8 @@ typedef long snd_pcm_sframes_t;
#define SND_PCM_NONBLOCK 0x00000001
/** Async notification (flag for open mode) \hideinitializer */
#define SND_PCM_ASYNC 0x00000002
/** Return EINTR instead blocking (wait operation) */
#define SND_PCM_EINTR 0x00000080
/** In an abort state (internal, not allowed for open) */
#define SND_PCM_ABORT 0x00008000
/** Disable automatic (but not forced!) rate resamplinig */

View file

@ -2938,7 +2938,7 @@ int snd_pcm_wait_nocheck(snd_pcm_t *pcm, int timeout)
err_poll = poll(pfd, npfds, timeout);
__snd_pcm_lock(pcm->fast_op_arg);
if (err_poll < 0) {
if (errno == EINTR && !PCMINABORT(pcm))
if (errno == EINTR && !PCMINABORT(pcm) && !(pcm->mode & SND_PCM_EINTR))
continue;
return -errno;
}