diff --git a/Source/Core/AudioCommon/WASAPIStream.cpp b/Source/Core/AudioCommon/WASAPIStream.cpp index 794fb6781a..2ee39f668c 100644 --- a/Source/Core/AudioCommon/WASAPIStream.cpp +++ b/Source/Core/AudioCommon/WASAPIStream.cpp @@ -59,14 +59,16 @@ static bool HandleWinAPI(std::string_view message, HRESULT result) { if (FAILED(result)) { - _com_error err(result); - std::string error = TStrToUTF8(err.ErrorMessage()); + std::string error; switch (result) { case AUDCLNT_E_DEVICE_IN_USE: error = "Audio endpoint already in use!"; break; + default: + error = TStrToUTF8(_com_error(result).ErrorMessage()).c_str(); + break; } ERROR_LOG_FMT(AUDIO, "WASAPI: {}: {}", message, error); @@ -75,6 +77,7 @@ static bool HandleWinAPI(std::string_view message, HRESULT result) return SUCCEEDED(result); } + std::vector WASAPIStream::GetAvailableDevices() { HRESULT result = CoInitializeEx(nullptr, COINIT_MULTITHREADED); @@ -131,7 +134,7 @@ std::vector WASAPIStream::GetAvailableDevices() return device_names; } -ComPtr WASAPIStream::GetDeviceByName(std::string name) +ComPtr WASAPIStream::GetDeviceByName(std::string_view name) { HRESULT result = CoInitializeEx(nullptr, COINIT_MULTITHREADED); // RPC_E_CHANGED_MODE means that thread has COM already initialized with a different threading diff --git a/Source/Core/AudioCommon/WASAPIStream.h b/Source/Core/AudioCommon/WASAPIStream.h index b4337a378a..640d0155fc 100644 --- a/Source/Core/AudioCommon/WASAPIStream.h +++ b/Source/Core/AudioCommon/WASAPIStream.h @@ -40,7 +40,7 @@ public: static bool isValid(); static std::vector GetAvailableDevices(); - static Microsoft::WRL::ComPtr GetDeviceByName(std::string name); + static Microsoft::WRL::ComPtr GetDeviceByName(std::string_view name); private: u32 m_frames_in_buffer = 0;