From 8a4d3f74310f0b42361d4dad4525f8854f94d61b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 26 Jul 2019 20:46:11 +0200 Subject: [PATCH] (XAudio 2.8) Audio device selection can now be set --- audio/common/mmdevice_common.c | 5 ++--- audio/drivers/xaudio.c | 5 ++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/audio/common/mmdevice_common.c b/audio/common/mmdevice_common.c index 0f60eb2f88..6a09aa583a 100644 --- a/audio/common/mmdevice_common.c +++ b/audio/common/mmdevice_common.c @@ -93,16 +93,15 @@ void *mmdevice_list_new(void *u) br = string_list_append(sl, dev_name_str, attr); if (!br) goto error; + if (dev_id_str) + sl->elems[sl->size-1].userdata = dev_id_str; PropVariantClear(&prop_var); prop_var_init = false; if (dev_id_wstr) CoTaskMemFree(dev_id_wstr); - if (dev_id_str) - free(dev_id_str); if (dev_name_str) free(dev_name_str); - dev_id_str = NULL; dev_name_str = NULL; dev_id_wstr = NULL; IFACE_RELEASE(prop_store); diff --git a/audio/drivers/xaudio.c b/audio/drivers/xaudio.c index b889a133e6..2b9532a529 100644 --- a/audio/drivers/xaudio.c +++ b/audio/drivers/xaudio.c @@ -243,7 +243,10 @@ static xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels, #if (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/) { - wchar_t *temp = utf8_to_utf16_string_alloc((const char*)(char)idx_found); + wchar_t *temp = NULL; + if (device) + temp = utf8_to_utf16_string_alloc((const char*)list->elems[idx_found].userdata); + if (FAILED(IXAudio2_CreateMasteringVoice(handle->pXAudio2, &handle->pMasterVoice, channels, samplerate, 0, (LPCWSTR)(uintptr_t)temp, NULL, AudioCategory_GameEffects))) { free(temp);