diff options
| author | Vadim Yanitskiy <axilirator@gmail.com> | 2017-09-08 00:02:20 +0300 |
|---|---|---|
| committer | Vadim Yanitskiy <axilirator@gmail.com> | 2017-09-08 00:13:42 +0300 |
| commit | 01edb56d7bb082ecc187254c2f0a54178dd9ff3f (patch) | |
| tree | b42e92f6943f75d27c74f9e76d8ef6f70fa59e31 | |
| parent | 8923276018b9a8d5ebafa2e18676fe6b8cef26a4 (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.c | 9 |
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; |
