From d6d5982d3ae68b72a1a53420b77ac269ef93d40e Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 3 May 2023 11:42:35 +0200 Subject: 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 --- include/pcm.h | 2 ++ src/pcm/pcm.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/pcm.h b/include/pcm.h index 25cd12d1..a29ea980 100644 --- a/include/pcm.h +++ b/include/pcm.h @@ -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 */ diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 01c624d3..41a36b36 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -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; } -- cgit v1.2.1