[PATCH 2/2] plugio: Check for pointer callback error codes

Arkadiusz Bokowy arkadiusz.bokowy at gmail.com
Mon Aug 23 13:48:38 CEST 2021


By checking error code returned by the pointer callback, we can
determine more precisely PCM state. Previous implementation assumed,
that a software PCM can only produce overrun or underrun. It was
impossible to mark software PCM as disconnected.

Signed-off-by: Arkadiusz Bokowy <arkadiusz.bokowy at gmail.com>
---
 src/pcm/pcm_ioplug.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/pcm/pcm_ioplug.c b/src/pcm/pcm_ioplug.c
index c96104e9..0e27e121 100644
--- a/src/pcm/pcm_ioplug.c
+++ b/src/pcm/pcm_ioplug.c
@@ -81,11 +81,21 @@ static int snd_pcm_ioplug_hw_ptr_update(snd_pcm_t *pcm)
  }
  io->last_hw = (snd_pcm_uframes_t)hw;
  } else {
+ switch (hw) {
+ case -ESTRPIPE:
+ io->data->state = SND_PCM_STATE_SUSPENDED;
+ break;
+ case -ENODEV:
+ io->data->state = SND_PCM_STATE_DISCONNECTED;
+ break;
+ default:
+ io->data->state = SND_PCM_STATE_XRUN;
+ }
  if (io->data->state == SND_PCM_STATE_DRAINING)
  snd_pcm_ioplug_drop(pcm);
  else
  io->data->state = SNDRV_PCM_STATE_XRUN;
- return -EPIPE;
+ return hw;
  }
  return 0;
 }
-- 
2.31.1


More information about the Alsa-devel mailing list