diff options
author | Marcelo Fernandez <marcelofg55@gmail.com> | 2018-07-25 17:58:56 -0300 |
---|---|---|
committer | Saracen <SaracenOne@gmail.com> | 2018-07-27 16:50:11 +0100 |
commit | 909cf03568b2b9ca62cd72a7d20e494fac21be66 (patch) | |
tree | d7b05fcd2dada46809a4ee12ac08cea57f7d05c4 | |
parent | 2cf8da9d9f5e73bcd123cd497a0adbaa65fcc7a6 (diff) |
Fixed device capture switching for WASAPI driver
-rw-r--r-- | drivers/wasapi/audio_driver_wasapi.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp index 7113a77735..a01d991450 100644 --- a/drivers/wasapi/audio_driver_wasapi.cpp +++ b/drivers/wasapi/audio_driver_wasapi.cpp @@ -699,6 +699,32 @@ void AudioDriverWASAPI::thread_func(void *p_udata) { ERR_BREAK(hr != S_OK); } } + + // If we're using the Default device and it changed finish it so we'll re-init the device + if (ad->audio_input.device_name == "Default" && default_capture_device_changed) { + Error err = ad->finish_capture_device(); + if (err != OK) { + ERR_PRINT("WASAPI: finish_capture_device error"); + } + + default_capture_device_changed = false; + } + + // User selected a new device, finish the current one so we'll init the new device + if (ad->audio_input.device_name != ad->audio_input.new_device) { + ad->audio_input.device_name = ad->audio_input.new_device; + Error err = ad->finish_capture_device(); + if (err != OK) { + ERR_PRINT("WASAPI: finish_capture_device error"); + } + } + + if (!ad->audio_input.audio_client) { + Error err = ad->init_capture_device(true); + if (err == OK) { + ad->capture_start(); + } + } } ad->stop_counting_ticks(); @@ -798,10 +824,10 @@ Array AudioDriverWASAPI::capture_get_device_list() { return audio_device_get_list(true); } -StringName AudioDriverWASAPI::capture_get_device() { +String AudioDriverWASAPI::capture_get_device() { lock(); - StringName name = audio_input.device_name; + String name = audio_input.device_name; unlock(); return name; |