diff options
author | Matthew Gregan <[email protected]> | 2023-07-26 16:37:45 +1200 |
---|---|---|
committer | Paul Adenot <[email protected]> | 2023-07-26 13:57:06 +0200 |
commit | 68084e902e93077305919c9c9cd1cb8e336a26d8 (patch) | |
tree | 075eca7e616593a2bd952ace464cd1f82c21ab4c | |
parent | 779f02495874213ff8f4dfb872dc4362032c56fb (diff) | |
download | cubeb-68084e902e93077305919c9c9cd1cb8e336a26d8.tar.gz cubeb-68084e902e93077305919c9c9cd1cb8e336a26d8.zip |
wasapi: Flag cubeb_stream as inactive when stopped, avoid reconfiguring inactive streams from render thread.
-rw-r--r-- | src/cubeb_wasapi.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cubeb_wasapi.cpp b/src/cubeb_wasapi.cpp index d55be36..711836a 100644 --- a/src/cubeb_wasapi.cpp +++ b/src/cubeb_wasapi.cpp @@ -452,6 +452,9 @@ struct cubeb_stream { * called and the render loop thread has exited, destroy this stream object. */ LONG ref_count = 0; + + /* True if the stream is active, false if inactive. */ + bool active = false; }; class monitor_device_notifications { @@ -1420,6 +1423,11 @@ static unsigned int __stdcall wasapi_stream_render_loop(LPVOID stream) } case WAIT_OBJECT_0 + 1: { /* reconfigure */ auto_lock lock(stm->stream_reset_lock); + if (!stm->active) { + /* Avoid reconfiguring, stream start will handle it. */ + LOG("Stream is not active, ignoring reconfigure."); + continue; + } XASSERT(stm->output_client || stm->input_client); LOG("Reconfiguring the stream"); /* Close the stream */ @@ -2985,6 +2993,8 @@ wasapi_stream_start(cubeb_stream * stm) } } + stm->active = true; + stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_STARTED); return CUBEB_OK; @@ -3015,6 +3025,8 @@ wasapi_stream_stop(cubeb_stream * stm) } } + stm->active = false; + wasapi_state_callback(stm, stm->user_ptr, CUBEB_STATE_STOPPED); } |