diff options
author | Matthew Gregan <[email protected]> | 2023-07-26 16:32:26 +1200 |
---|---|---|
committer | Paul Adenot <[email protected]> | 2023-07-26 13:57:06 +0200 |
commit | 779f02495874213ff8f4dfb872dc4362032c56fb (patch) | |
tree | 665860d2e7fa222d2e48c266aac912111342e1b1 | |
parent | 48689ae7a73caeb747953f9ed664dc71d2f918d8 (diff) | |
download | cubeb-779f02495874213ff8f4dfb872dc4362032c56fb.tar.gz cubeb-779f02495874213ff8f4dfb872dc4362032c56fb.zip |
wasapi: Take stream_reset_lock earlier in render thread reconfig path.
-rw-r--r-- | src/cubeb_wasapi.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/cubeb_wasapi.cpp b/src/cubeb_wasapi.cpp index c28be38..d55be36 100644 --- a/src/cubeb_wasapi.cpp +++ b/src/cubeb_wasapi.cpp @@ -1419,6 +1419,7 @@ static unsigned int __stdcall wasapi_stream_render_loop(LPVOID stream) continue; } case WAIT_OBJECT_0 + 1: { /* reconfigure */ + auto_lock lock(stm->stream_reset_lock); XASSERT(stm->output_client || stm->input_client); LOG("Reconfiguring the stream"); /* Close the stream */ @@ -1431,23 +1432,20 @@ static unsigned int __stdcall wasapi_stream_render_loop(LPVOID stream) was_running = stm->input_client->Stop() == S_OK; LOG("Input stopped."); } - { - auto_lock lock(stm->stream_reset_lock); - close_wasapi_stream(stm); - LOG("Stream closed."); - /* Reopen a stream and start it immediately. This will automatically - pick the new default device for this role. */ - int r = setup_wasapi_stream(stm); - if (r != CUBEB_OK) { - LOG("Error setting up the stream during reconfigure."); - /* Don't destroy the stream here, since we expect the caller to do - so after the error has propagated via the state callback. */ - is_playing = false; - hr = E_FAIL; - continue; - } - LOG("Stream setup successfuly."); + close_wasapi_stream(stm); + LOG("Stream closed."); + /* Reopen a stream and start it immediately. This will automatically + pick the new default device for this role. */ + int r = setup_wasapi_stream(stm); + if (r != CUBEB_OK) { + LOG("Error setting up the stream during reconfigure."); + /* Don't destroy the stream here, since we expect the caller to do + so after the error has propagated via the state callback. */ + is_playing = false; + hr = E_FAIL; + continue; } + LOG("Stream setup successfuly."); XASSERT(stm->output_client || stm->input_client); if (was_running && stm->output_client) { hr = stm->output_client->Start(); |