bluez5-device: Add logic to do not send release event to bt framework if sbc decode... 11/301311/1 accepted/tizen/unified/20231115.173517
authorhanbi.park@samsung.com <hanbi.park@samsung.com>
Wed, 20 Oct 2021 02:15:23 +0000 (11:15 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Tue, 14 Nov 2023 02:51:54 +0000 (11:51 +0900)
This modification is for A2DP sink audio streaming.

Change-Id: I30d7a7520d5e116c2da24461ed0424332ea62435
Signed-off-by: hanbi.park <hanbi.park@samsung.com>
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
src/modules/bluetooth/module-bluez5-device.c

index 5b9e083..4f8a28f 100644 (file)
@@ -492,6 +492,10 @@ static int bt_process_push(struct userdata *u) {
     uint8_t *ptr;
     ssize_t received;
     size_t processed = 0;
+#ifdef __TIZEN_BT__
+    static int decode_error_count = 0;
+    const int max_decode_error_count = 100;
+#endif
 
     pa_assert(u);
     pa_assert(u->source);
@@ -521,9 +525,21 @@ static int bt_process_push(struct userdata *u) {
 
     if (processed != (size_t) received) {
         pa_log_error("Decoding error");
+#ifdef __TIZEN_BT__
+        if (++decode_error_count < max_decode_error_count) {
+            pa_log_warn("Continuous decode error count [%3d/%3d]", decode_error_count, max_decode_error_count);
+            pa_memblock_unref(memchunk.memblock);
+            return 0;
+        }
+        pa_log_error("Continuous decode error count [%3d/%3d]", decode_error_count, max_decode_error_count);
+        decode_error_count = 0;
+#endif
         pa_memblock_unref(memchunk.memblock);
         return -1;
     }
+#ifdef __TIZEN_BT__
+    decode_error_count = 0;
+#endif
 
     u->read_index += (uint64_t) memchunk.length;
     pa_smoother_put(u->read_smoother, tstamp, pa_bytes_to_usec(u->read_index, &u->decoder_sample_spec));