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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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(+)

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;
-- 
2.18.0

_______________________________________________
pulseaudio-discuss mailing list
pulseaudio-discuss@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss




[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux