From 00758ed2a7f7d96f53cccc4a2dc6043298fdcc62 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 7 Jul 2015 13:01:22 +0200 Subject: [PATCH] tunnel-sink-new: log buffer events Aids in tracking down exactly where in the chain underruns are happening. Signed-off-by: Pierre Ossman --- src/modules/module-tunnel-sink-new.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/modules/module-tunnel-sink-new.c b/src/modules/module-tunnel-sink-new.c index 7f83543..65698f0 100644 --- a/src/modules/module-tunnel-sink-new.c +++ b/src/modules/module-tunnel-sink-new.c @@ -280,6 +280,9 @@ static void stream_changed_buffer_attr_cb(pa_stream *stream, void *userdata) { bufferattr = pa_stream_get_buffer_attr(u->stream); pa_sink_set_max_request_within_thread(u->sink, bufferattr->tlength); + + pa_log_debug("Server reports buffer attrs changed. tlength now at %lu.", + (unsigned long) bufferattr->tlength); } /* called after we requested a change of the stream buffer_attr */ @@ -287,6 +290,16 @@ static void stream_set_buffer_attr_cb(pa_stream *stream, int success, void *user stream_changed_buffer_attr_cb(stream, userdata); } +/* called when the server experiences an underrun of our buffer */ +static void stream_underflow_callback(pa_stream *stream, void *userdata) { + pa_log_info("Server signalled buffer underrun."); +} + +/* called when the server experiences an overrun of our buffer */ +static void stream_overflow_callback(pa_stream *stream, void *userdata) { + pa_log_info("Server signalled buffer overrun."); +} + static void context_state_cb(pa_context *c, void *userdata) { struct userdata *u = userdata; pa_assert(u); @@ -333,8 +346,12 @@ static void context_state_cb(pa_context *c, void *userdata) { reset_bufferattr(&bufferattr); bufferattr.tlength = pa_usec_to_bytes(requested_latency, &u->sink->sample_spec); + pa_log_debug("tlength requested at %lu.", (unsigned long) bufferattr.tlength); + pa_stream_set_state_callback(u->stream, stream_state_cb, userdata); pa_stream_set_buffer_attr_callback(u->stream, stream_changed_buffer_attr_cb, userdata); + pa_stream_set_underflow_callback(u->stream, stream_underflow_callback, userdata); + pa_stream_set_overflow_callback(u->stream, stream_overflow_callback, userdata); if (pa_stream_connect_playback(u->stream, u->remote_sink_name, &bufferattr, @@ -383,6 +400,9 @@ static void sink_update_requested_latency_cb(pa_sink *s) { if (pa_stream_get_buffer_attr(u->stream)->tlength == nbytes) break; + pa_log_debug("Requesting new buffer attrs. tlength requested at %lu.", + (unsigned long) nbytes); + reset_bufferattr(&bufferattr); bufferattr.tlength = nbytes; if ((operation = pa_stream_set_buffer_attr(u->stream, &bufferattr, stream_set_buffer_attr_cb, u))) -- 2.4.3