summaryrefslogtreecommitdiffstats
path: root/media/libcubeb/0005-aaudio-timing-fix.patch
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
commitda4c7e7ed675c3bf405668739c3012d140856109 (patch)
treecdd868dba063fecba609a1d819de271f0d51b23e /media/libcubeb/0005-aaudio-timing-fix.patch
parentAdding upstream version 125.0.3. (diff)
downloadfirefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz
firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'media/libcubeb/0005-aaudio-timing-fix.patch')
-rw-r--r--media/libcubeb/0005-aaudio-timing-fix.patch57
1 files changed, 57 insertions, 0 deletions
diff --git a/media/libcubeb/0005-aaudio-timing-fix.patch b/media/libcubeb/0005-aaudio-timing-fix.patch
new file mode 100644
index 0000000000..aabaec9c50
--- /dev/null
+++ b/media/libcubeb/0005-aaudio-timing-fix.patch
@@ -0,0 +1,57 @@
+From 19fcbefe1a9c5e22f8111af251df27b41658bc77 Mon Sep 17 00:00:00 2001
+From: John Lin <jolin@mozilla.com>
+Date: Mon, 29 Apr 2024 13:46:57 -0700
+Subject: [PATCH] Invalidate timing info buffers when destorying AAudio stream.
+
+aaudio_stream_get_position() returns incorrect result because
+aaudio_stream_init() recycled destroyed stream where the
+timing_info buffers contain stale data.
+---
+ src/cubeb_aaudio.cpp | 2 ++
+ src/cubeb_triple_buffer.h | 7 +++++++
+ test/test_triple_buffer.cpp | 3 +++
+ 3 files changed, 12 insertions(+)
+
+diff --git a/src/cubeb_aaudio.cpp b/src/cubeb_aaudio.cpp
+index cfae2d6f..8b5eb231 100644
+--- a/src/cubeb_aaudio.cpp
++++ b/src/cubeb_aaudio.cpp
+@@ -1049,6 +1049,8 @@ aaudio_stream_destroy_locked(cubeb_stream * stm, lock_guard<mutex> & lock)
+ stm->istream = nullptr;
+ }
+
++ stm->timing_info.invalidate();
++
+ if (stm->resampler) {
+ cubeb_resampler_destroy(stm->resampler);
+ stm->resampler = nullptr;
+diff --git a/src/cubeb_triple_buffer.h b/src/cubeb_triple_buffer.h
+index a5a5978f..759b92e6 100644
+--- a/src/cubeb_triple_buffer.h
++++ b/src/cubeb_triple_buffer.h
+@@ -42,6 +42,13 @@ template <typename T> class triple_buffer {
+ {
+ return (shared_state.load(std::memory_order_relaxed) & BACK_DIRTY_BIT) != 0;
+ }
++ // Reset state and indices to initial values.
++ void invalidate()
++ {
++ shared_state.store(0, std::memory_order_release);
++ input_idx = 1;
++ output_idx = 2;
++ }
+
+ private:
+ // Publish a value to the consumer. Returns true if the data was overwritten
+diff --git a/test/test_triple_buffer.cpp b/test/test_triple_buffer.cpp
+index a6e0049b..d463c07e 100644
+--- a/test/test_triple_buffer.cpp
++++ b/test/test_triple_buffer.cpp
+@@ -64,4 +64,7 @@ TEST(cubeb, triple_buffer)
+ }
+
+ t.join();
++
++ buffer.invalidate();
++ ASSERT_FALSE(buffer.updated());
+ }