diff options
author | Jaroslav Kysela <perex@perex.cz> | 2013-04-08 13:28:03 +0200 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2013-04-08 13:28:03 +0200 |
commit | e23fb2c4de29b24c28f0c609521faa28d948a05b (patch) | |
tree | 6ba8d5d89dd8ee955f221f3ef5bf8c71c9f633d1 /src/pcm | |
parent | 730c833dd8b76cc280246be698980422cb1bce47 (diff) |
control, pcm: implement snd_ctl_abort() and snd_pcm_abort() functions
Upon an interrupt, it is necessary to abort the wait loops with the EINTR
error code. Introduce snd_*_abort() functions to handle this case.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'src/pcm')
-rw-r--r-- | src/pcm/pcm.c | 8 | ||||
-rw-r--r-- | src/pcm/pcm_local.h | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 0868dd58..38febb9d 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -716,7 +716,7 @@ int snd_pcm_close(snd_pcm_t *pcm) /** * \brief set nonblock mode * \param pcm PCM handle - * \param nonblock 0 = block, 1 = nonblock mode + * \param nonblock 0 = block, 1 = nonblock mode, 2 = abort * \return 0 on success otherwise a negative error code */ int snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock) @@ -725,6 +725,10 @@ int snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock) assert(pcm); if ((err = pcm->ops->nonblock(pcm->op_arg, nonblock)) < 0) return err; + if (nonblock == 2) { + pcm->mode |= SND_PCM_ABORT; + return 0; + } if (nonblock) pcm->mode |= SND_PCM_NONBLOCK; else { @@ -2401,7 +2405,7 @@ int snd_pcm_wait_nocheck(snd_pcm_t *pcm, int timeout) do { err_poll = poll(pfd, npfds, timeout); if (err_poll < 0) { - if (errno == EINTR) + if (errno == EINTR && !PCMINABORT(pcm)) continue; return -errno; } diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h index 63b9036f..e1c0baa8 100644 --- a/src/pcm/pcm_local.h +++ b/src/pcm/pcm_local.h @@ -1006,3 +1006,5 @@ static inline void sw_set_period_event(snd_pcm_sw_params_t *params, int val) { params->reserved[sizeof(params->reserved) / sizeof(params->reserved[0]) - 1] = val; } + +#define PCMINABORT(pcm) (((pcm)->mode & SND_PCM_ABORT) != 0) |