[RFC,v2,3/3] bluetooth: Add skipped bytes statistic message

Submitted by Frédéric Danis on May 27, 2019, 9:14 a.m.

Details

Message ID 20190527091452.13940-4-frederic.danis@collabora.com
State New
Headers show
Series "Add dynamic configuration of SBC bitpool" ( rev: 2 ) in PulseAudio

Not browsing as part of any series.

Commit Message

Frédéric Danis May 27, 2019, 9:14 a.m.
This allows to get the total amount of bytes skipped since connected to
the device.

pacmd send-message /bluetooth/bluez_sink.<device address> get-skipped-bytes
---
 src/modules/bluetooth/module-bluez5-device.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c
index 3ab4be508..4abc55fd1 100644
--- a/src/modules/bluetooth/module-bluez5-device.c
+++ b/src/modules/bluetooth/module-bluez5-device.c
@@ -31,6 +31,7 @@ 
 #include <pulse/timeval.h>
 #include <pulse/utf8.h>
 #include <pulse/util.h>
+#include <pulse/message-params.h>
 
 #include <pulsecore/core-error.h>
 #include <pulsecore/core-rtclock.h>
@@ -133,6 +134,7 @@  struct userdata {
     pa_usec_t started_at;
     pa_smoother *read_smoother;
     pa_memchunk write_memchunk;
+    uint64_t skipped_bytes;
 
     const pa_a2dp_codec *a2dp_codec;
     bool a2dp_codec_config_pending;
@@ -1425,6 +1427,8 @@  static void thread_func(void *userdata) {
                             pa_log_debug("Skipping %llu us (= %llu bytes) in audio stream",
                                         (unsigned long long) skip_usec,
                                         (unsigned long long) skip_bytes);
+                            u->skipped_bytes += skip_bytes;
+                            pa_log_debug("Total bytes skipped = %llu", (unsigned long long) u->skipped_bytes);
 
                             while (skip_bytes > 0) {
                                 size_t bytes_to_render;
@@ -1550,6 +1554,11 @@  static int bluetooth_handler(const char *object_path, const char *message, char
             return res;
         }
         return -PA_ERR_NOTSUPPORTED;
+    } else if (pa_streq(message, "get-skipped-bytes")) {
+        pa_message_params *param = pa_message_params_new();
+        pa_message_params_write_uint64(param, u->skipped_bytes);
+        *response = pa_message_params_to_string_free(param);
+        return PA_OK;
     }
 
     return -PA_ERR_NOTIMPLEMENTED;