[pulseaudio-discuss,2/7] tunnel-sink-new: log buffer events

Submitted by Pierre Ossman on May 23, 2016, 2:57 p.m.

Details

Message ID 20160523165752.0edf84f1@ossman.lkpg.cendio.se
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in PulseAudio

Not browsing as part of any series.

Commit Message

Pierre Ossman May 23, 2016, 2:57 p.m.
Aids in tracking down exactly where in the chain underruns are
happening.

Signed-off-by: Pierre Ossman <ossman@cendio.se>
---
 src/modules/module-tunnel-sink-new.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

 /* 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)))

Patch hide | download patch | download mbox

diff --git a/src/modules/module-tunnel-sink-new.c
b/src/modules/module-tunnel-sink-new.c index c56654a..bec6e8c 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);
 }