Blame SOURCES/0001-bluetooth-skip-audio-in-smaller-chunks.patch

4bc40d
From 2ead0a39408cb335749dedca9b18b330a0af8d26 Mon Sep 17 00:00:00 2001
4bc40d
From: Wim Taymans <wtaymans@redhat.com>
4bc40d
Date: Mon, 24 Feb 2014 09:45:52 +0100
4bc40d
Subject: [PATCH] bluetooth: skip audio in smaller chunks
4bc40d
4bc40d
Render audio in smaller chunks, the amount of data to mix is not bounded
4bc40d
and we might end up hitting the maximum memory limit (96M).
4bc40d
4bc40d
Fixes rhbz#989552
4bc40d
---
4bc40d
 src/modules/bluetooth/module-bluetooth-device.c | 14 +++++++++-----
4bc40d
 1 file changed, 9 insertions(+), 5 deletions(-)
4bc40d
4bc40d
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
4bc40d
index 6c0c746..d06f669 100644
4bc40d
--- a/src/modules/bluetooth/module-bluetooth-device.c
4bc40d
+++ b/src/modules/bluetooth/module-bluetooth-device.c
4bc40d
@@ -1116,15 +1116,19 @@ static void thread_func(void *userdata) {
4bc40d
                             skip_bytes = pa_usec_to_bytes(skip_usec, &u->sample_spec);
4bc40d
 
4bc40d
                             if (skip_bytes > 0) {
4bc40d
-                                pa_memchunk tmp;
4bc40d
-
4bc40d
                                 pa_log_warn("Skipping %llu us (= %llu bytes) in audio stream",
4bc40d
                                             (unsigned long long) skip_usec,
4bc40d
                                             (unsigned long long) skip_bytes);
4bc40d
+                                do {
4bc40d
+                                  pa_memchunk tmp;
4bc40d
+                                  uint64_t to_skip = MIN (skip_bytes, 65535);
4bc40d
+
4bc40d
+                                  pa_sink_render_full(u->sink, to_skip, &tmp);
4bc40d
+                                  pa_memblock_unref(tmp.memblock);
4bc40d
 
4bc40d
-                                pa_sink_render_full(u->sink, skip_bytes, &tmp);
4bc40d
-                                pa_memblock_unref(tmp.memblock);
4bc40d
-                                u->write_index += skip_bytes;
4bc40d
+                                  u->write_index += to_skip;
4bc40d
+                                  skip_bytes -= to_skip;
4bc40d
+                                } while (skip_bytes > 0);
4bc40d
 
4bc40d
                                 if (u->profile == PROFILE_A2DP)
4bc40d
                                     a2dp_reduce_bitpool(u);
4bc40d
-- 
4bc40d
1.8.5.3
4bc40d