tunnel-sink-new: log buffer events
authorPierre Ossman <ossman@cendio.se>
Tue, 7 Jul 2015 11:01:22 +0000 (13:01 +0200)
committerGeorg Chini <georg@chini.tk>
Wed, 9 Dec 2020 11:54:37 +0000 (11:54 +0000)
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

index 802e6a59a474415f7c27b5075e52191bb42e7ac5..66a1787178f708c72d63ea874d9b5188be90d6d2 100644 (file)
@@ -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)))