diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/polyp/internal.h | 2 | ||||
-rw-r--r-- | src/polyp/stream.c | 15 | ||||
-rw-r--r-- | src/polyp/stream.h | 3 |
3 files changed, 19 insertions, 1 deletions
diff --git a/src/polyp/internal.h b/src/polyp/internal.h index f41744ef..80c28616 100644 --- a/src/polyp/internal.h +++ b/src/polyp/internal.h @@ -151,6 +151,8 @@ struct pa_stream { void *overflow_userdata; pa_stream_notify_cb_t underflow_callback; void *underflow_userdata; + pa_stream_notify_cb_t latency_update_callback; + void *latency_update_userdata; }; typedef void (*pa_operation_cb_t)(void); diff --git a/src/polyp/stream.c b/src/polyp/stream.c index c67b3e51..bccdebe5 100644 --- a/src/polyp/stream.c +++ b/src/polyp/stream.c @@ -63,6 +63,8 @@ pa_stream *pa_stream_new(pa_context *c, const char *name, const pa_sample_spec * s->overflow_userdata = NULL; s->underflow_callback = NULL; s->underflow_userdata = NULL; + s->latency_update_callback = NULL; + s->latency_update_userdata = NULL; s->direction = PA_STREAM_NODIRECTION; s->name = pa_xstrdup(name); @@ -849,8 +851,11 @@ static void stream_get_timing_info_callback(pa_pdispatch *pd, uint32_t command, o->stream->write_index_corrections[n].valid = 0; } } + + if (o->stream->latency_update_callback) + o->stream->latency_update_callback(o->stream, o->stream->latency_update_userdata); - if (o->callback) { + if (o->callback && o->stream && o->stream->state == PA_STREAM_READY) { pa_stream_success_cb_t cb = (pa_stream_success_cb_t) o->callback; cb(o->stream, o->stream->timing_info_valid, o->userdata); } @@ -999,6 +1004,14 @@ void pa_stream_set_underflow_callback(pa_stream *s, pa_stream_notify_cb_t cb, vo s->underflow_userdata = userdata; } +void pa_stream_set_latency_update_callback(pa_stream *s, pa_stream_notify_cb_t cb, void *userdata) { + assert(s); + assert(s->ref >= 1); + + s->latency_update_callback = cb; + s->latency_update_userdata = userdata; +} + void pa_stream_simple_ack_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint32_t tag, pa_tagstruct *t, void *userdata) { pa_operation *o = userdata; int success = 1; diff --git a/src/polyp/stream.h b/src/polyp/stream.h index b6522efe..ad77d938 100644 --- a/src/polyp/stream.h +++ b/src/polyp/stream.h @@ -375,6 +375,9 @@ void pa_stream_set_overflow_callback(pa_stream *p, pa_stream_notify_cb_t cb, voi /** Set the callback function that is called when a buffer underflow happens. (Only for playback streams) \since 0.8 */ void pa_stream_set_underflow_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata); +/** Set the callback function that is called whenever a latency information update happens. Useful on PA_STREAM_AUTO_TIMING_UPDATE streams only. (Only for playback streams) \since 0.8.2 */ +void pa_stream_set_latency_update_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata); + /** Pause (or resume) playback of this stream temporarily. Available on both playback and recording streams. \since 0.3 */ pa_operation* pa_stream_cork(pa_stream *s, int b, pa_stream_success_cb_t cb, void *userdata); |