]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: add SND_PCM_EINTR open mode
authorJaroslav Kysela <perex@perex.cz>
Wed, 3 May 2023 09:42:35 +0000 (11:42 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 3 May 2023 13:59:15 +0000 (15:59 +0200)
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>
include/pcm.h
src/pcm/pcm.c

index 25cd12d1e4a2d84b9a24b1499f3ab8e384165a6c..a29ea98093adcad546f8a281469b532e7770d092 100644 (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 */
index 01c624d323bf06487c2b09f815f4d6c242556129..41a36b36eaf37331c2d78fc43ec475dfe0057098 100644 (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;
                 }