[alsa-devel] [PATCH 2/3] ioplug: Check for callback error codes
Arkadiusz (Arkq) Bokowy
arkadiusz.bokowy at gmail.com
Sun Jan 7 14:31:07 CET 2018
ioplug: Check for callback error codes
Signed-off-by: Arkadiusz Bokowy <arkadiusz.bokowy at gmail.com>
---
src/pcm/pcm_ioplug.c | 35 ++++++++++++++++++++++++-----------
1 file changed, 24 insertions(+), 11 deletions(-)
diff --git a/src/pcm/pcm_ioplug.c b/src/pcm/pcm_ioplug.c
index 7a782e68..06c20d7b 100644
--- a/src/pcm/pcm_ioplug.c
+++ b/src/pcm/pcm_ioplug.c
@@ -49,7 +49,7 @@ typedef struct snd_pcm_ioplug_priv {
/* update the hw pointer */
/* called in lock */
-static void snd_pcm_ioplug_hw_ptr_update(snd_pcm_t *pcm)
+static int snd_pcm_ioplug_hw_ptr_update(snd_pcm_t *pcm)
{
ioplug_priv_t *io = pcm->private_data;
snd_pcm_sframes_t hw;
@@ -63,8 +63,10 @@ static void snd_pcm_ioplug_hw_ptr_update(snd_pcm_t
*pcm) delta = pcm->buffer_size + hw - io->last_hw;
snd_pcm_mmap_hw_forward(io->data->pcm, delta);
io->last_hw = hw;
+ return 0;
} else
io->data->state = SNDRV_PCM_STATE_XRUN;
+ return -EPIPE;
}
static int snd_pcm_ioplug_info(snd_pcm_t *pcm, snd_pcm_info_t *info)
@@ -119,7 +121,10 @@ static int snd_pcm_ioplug_delay(snd_pcm_t *pcm,
snd_pcm_sframes_t *delayp) io->data->callback->delay)
return io->data->callback->delay(io->data, delayp);
else {
- snd_pcm_ioplug_hw_ptr_update(pcm);
+ int err;
+ err = snd_pcm_ioplug_hw_ptr_update(pcm);
+ if (err < 0)
+ return err;
*delayp = snd_pcm_mmap_hw_avail(pcm);
}
return 0;
@@ -468,11 +473,14 @@ static int snd_pcm_ioplug_start(snd_pcm_t *pcm)
static int snd_pcm_ioplug_drop(snd_pcm_t *pcm)
{
ioplug_priv_t *io = pcm->private_data;
+ int err;
if (io->data->state == SND_PCM_STATE_OPEN)
return -EBADFD;
- io->data->callback->stop(io->data);
+ err = io->data->callback->stop(io->data);
+ if (err < 0)
+ return err;
gettimestamp(&io->trigger_tstamp, pcm->tstamp_type);
io->data->state = SND_PCM_STATE_SETUP;
@@ -488,8 +496,11 @@ static int snd_pcm_ioplug_drain(snd_pcm_t *pcm)
if (io->data->state == SND_PCM_STATE_OPEN)
return -EBADFD;
- if (io->data->callback->drain)
- io->data->callback->drain(io->data);
+ if (io->data->callback->drain) {
+ err = io->data->callback->drain(io->data);
+ if (err < 0)
+ return err;
+ }
snd_pcm_lock(pcm);
err = snd_pcm_ioplug_drop(pcm);
snd_pcm_unlock(pcm);
@@ -545,7 +556,7 @@ static int snd_pcm_ioplug_resume(snd_pcm_t *pcm)
ioplug_priv_t *io = pcm->private_data;
if (io->data->callback->resume)
- io->data->callback->resume(io->data);
+ return io->data->callback->resume(io->data);
return 0;
}
@@ -641,10 +652,11 @@ static snd_pcm_sframes_t
snd_pcm_ioplug_avail_update(snd_pcm_t *pcm) {
ioplug_priv_t *io = pcm->private_data;
snd_pcm_uframes_t avail;
+ int err;
- snd_pcm_ioplug_hw_ptr_update(pcm);
- if (io->data->state == SND_PCM_STATE_XRUN)
- return -EPIPE;
+ err = snd_pcm_ioplug_hw_ptr_update(pcm);
+ if (err < 0)
+ return err;
if (pcm->stream == SND_PCM_STREAM_CAPTURE &&
pcm->access != SND_PCM_ACCESS_RW_INTERLEAVED &&
pcm->access != SND_PCM_ACCESS_RW_NONINTERLEAVED) {
@@ -799,13 +811,14 @@ static void clear_io_params(ioplug_priv_t *io)
static int snd_pcm_ioplug_close(snd_pcm_t *pcm)
{
ioplug_priv_t *io = pcm->private_data;
+ int err = 0;
clear_io_params(io);
if (io->data->callback->close)
- io->data->callback->close(io->data);
+ err = io->data->callback->close(io->data);
free(io);
- return 0;
+ return err;
}
static const snd_pcm_ops_t snd_pcm_ioplug_ops = {
--
2.13.6
More information about the Alsa-devel
mailing list