aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChun-Min Chang <[email protected]>2022-03-23 09:58:31 -0700
committerMatthew Gregan <[email protected]>2022-03-24 10:27:52 +1300
commitbdf2837ae5ce8ec6c4db110e3618465b97859fee (patch)
tree0db5a6da295ffdcad91fbadc1ea309d37bd3621d
parent2f50db3669bdef605f6ccc10a3f9d0e9246e1374 (diff)
downloadcubeb-bdf2837ae5ce8ec6c4db110e3618465b97859fee.tar.gz
cubeb-bdf2837ae5ce8ec6c4db110e3618465b97859fee.zip
Don't reset device if DISABLE_DEVICE_SWITCHING is set
We should not always reset the device when the current device is unplugged. The device reset or not should follow the CUBEB_STREAM_PREF_DISABLE_DEVICE_SWITCHING pref.
-rw-r--r--src/cubeb_wasapi.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/cubeb_wasapi.cpp b/src/cubeb_wasapi.cpp
index ca183db..3bfbb51 100644
--- a/src/cubeb_wasapi.cpp
+++ b/src/cubeb_wasapi.cpp
@@ -983,8 +983,11 @@ get_input_buffer(cubeb_stream * stm)
if (hr == AUDCLNT_E_DEVICE_INVALIDATED) {
// Application can recover from this error. More info
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd316605(v=vs.85).aspx
- LOG("Device invalidated error, reset default device");
- if (!trigger_async_reconfigure(stm)) {
+ LOG("Input device invalidated error");
+ // No need to reset device if switching is disabled.
+ if ((stm->input_stream_params.prefs &
+ CUBEB_STREAM_PREF_DISABLE_DEVICE_SWITCHING) ||
+ !trigger_async_reconfigure(stm)) {
stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_ERROR);
return false;
}
@@ -1092,8 +1095,11 @@ get_output_buffer(cubeb_stream * stm, void *& buffer, size_t & frame_count)
if (hr == AUDCLNT_E_DEVICE_INVALIDATED) {
// Application can recover from this error. More info
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd316605(v=vs.85).aspx
- LOG("Device invalidated error, reset default device");
- if (!trigger_async_reconfigure(stm)) {
+ LOG("Output device invalidated error");
+ // No need to reset device if switching is disabled.
+ if ((stm->output_stream_params.prefs &
+ CUBEB_STREAM_PREF_DISABLE_DEVICE_SWITCHING) ||
+ !trigger_async_reconfigure(stm)) {
stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_ERROR);
return false;
}