aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/cubeb_aaudio.cpp2
-rw-r--r--src/cubeb_triple_buffer.h7
-rw-r--r--test/test_triple_buffer.cpp3
3 files changed, 12 insertions, 0 deletions
diff --git a/src/cubeb_aaudio.cpp b/src/cubeb_aaudio.cpp
index cfae2d6..8b5eb23 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 a5a5978..759b92e 100644
--- a/src/cubeb_triple_buffer.h
+++ b/src/cubeb_triple_buffer.h
@@ -42,6 +42,13 @@ public:
{
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 a6e0049..d463c07 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());
}