diff options
author | Paul Adenot <[email protected]> | 2023-04-18 17:27:25 +0200 |
---|---|---|
committer | Paul Adenot <[email protected]> | 2023-04-19 13:37:43 +0200 |
commit | 3f45761b4f002249691a1a9a7a5bf8e8a01add78 (patch) | |
tree | 752c691cea94906932172c8e536ed475431c0e68 | |
parent | 2840590affe5e438804d77aaa787144de6d375ec (diff) | |
download | cubeb-3f45761b4f002249691a1a9a7a5bf8e8a01add78.tar.gz cubeb-3f45761b4f002249691a1a9a7a5bf8e8a01add78.zip |
Add a way to know if the data callback is running
-rw-r--r-- | src/cubeb_aaudio.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/cubeb_aaudio.cpp b/src/cubeb_aaudio.cpp index 1c98ed3..80bd4ac 100644 --- a/src/cubeb_aaudio.cpp +++ b/src/cubeb_aaudio.cpp @@ -135,6 +135,7 @@ struct cubeb_stream { std::atomic<bool> in_use{false}; std::atomic<bool> latency_metrics_available{false}; std::atomic<stream_state> state{stream_state::INIT}; + std::atomic<bool> in_data_callback{false}; triple_buffer<AAudioTimingInfo> timing_info; AAudioStream * ostream{}; @@ -180,6 +181,15 @@ struct cubeb { struct cubeb_stream streams[MAX_STREAMS]; }; +struct AutoInCallback { + AutoInCallback(cubeb_stream * stm) : stm(stm) + { + stm->in_data_callback.store(true); + } + ~AutoInCallback() { stm->in_data_callback.store(false); } + cubeb_stream * stm; +}; + // Only allowed from state thread, while mutex on stm is locked static void shutdown_with_error(cubeb_stream * stm) @@ -612,6 +622,7 @@ aaudio_duplex_data_cb(AAudioStream * astream, void * user_data, void * audio_data, int32_t num_frames) { cubeb_stream * stm = (cubeb_stream *)user_data; + AutoInCallback aic(stm); assert(stm->ostream == astream); assert(stm->istream); assert(num_frames >= 0); @@ -693,6 +704,7 @@ aaudio_output_data_cb(AAudioStream * astream, void * user_data, void * audio_data, int32_t num_frames) { cubeb_stream * stm = (cubeb_stream *)user_data; + AutoInCallback aic(stm); assert(stm->ostream == astream); assert(!stm->istream); assert(num_frames >= 0); @@ -741,6 +753,7 @@ aaudio_input_data_cb(AAudioStream * astream, void * user_data, void * audio_data, int32_t num_frames) { cubeb_stream * stm = (cubeb_stream *)user_data; + AutoInCallback aic(stm); assert(stm->istream == astream); assert(!stm->ostream); assert(num_frames >= 0); |