diff options
author | John Lin <[email protected]> | 2024-04-29 13:46:57 -0700 |
---|---|---|
committer | Matthew Gregan <[email protected]> | 2024-04-30 10:52:29 +1200 |
commit | 19fcbefe1a9c5e22f8111af251df27b41658bc77 (patch) | |
tree | fc838880c3111deff3c84d30e3bbde015f311b28 /src | |
parent | b82e270abf5391afbb84f7fb678ae5ebe4a6eb13 (diff) | |
download | cubeb-19fcbefe1a9c5e22f8111af251df27b41658bc77.tar.gz cubeb-19fcbefe1a9c5e22f8111af251df27b41658bc77.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/cubeb_aaudio.cpp | 2 | ||||
-rw-r--r-- | src/cubeb_triple_buffer.h | 7 |
2 files changed, 9 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 |