summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-09-08 00:02:20 +0300
committerVadim Yanitskiy <axilirator@gmail.com>2017-12-31 12:20:59 +0100
commita183ced71eb78c27123d29ea3e9bbc646bcd4fdc (patch)
treed842b4c250f937b1dc5900e4d730713730411815
parent1f6f807bb35228f7d6f50cf61283b9ceb8f46eee (diff)
src/pq_alsa.c: implement processing state callback
Using the snd_pcm_avail_update() call from ALSA API it's possible to know, how much samples are still to be processed.
-rw-r--r--src/pq_alsa.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/pq_alsa.c b/src/pq_alsa.c
index 779dd96..b434b5b 100644
--- a/src/pq_alsa.c
+++ b/src/pq_alsa.c
@@ -70,6 +70,13 @@ pq_cb_alsa_output(void *_state, uint8_t *out, const uint8_t *in, unsigned int in
return rv == num_samples ? 0 : -1;
}
+static int
+pq_cb_alsa_wait(void *_state)
+{
+ struct pq_state_alsa *state = _state;
+ return snd_pcm_avail_update(state->pcm_handle) > 0;
+}
+
static void
pq_cb_alsa_exit(void *_state)
{
@@ -138,7 +145,7 @@ pq_queue_alsa_op(struct osmo_gapk_pq *pq, const char *alsa_dev, unsigned int blk
item->len_out = in_out_n ? blk_len : 0;
item->state = state;
item->proc = in_out_n ? pq_cb_alsa_input : pq_cb_alsa_output;
- item->wait = NULL;
+ item->wait = pq_cb_alsa_wait;
item->exit = pq_cb_alsa_exit;
return 0;