diff options
Diffstat (limited to 'src/cubeb_aaudio.cpp')
-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); |