AudioCommon/WASAPI: Use std::string_view where applicable

This commit is contained in:
Silent 2019-08-17 11:05:33 +02:00
parent 7d59ad262f
commit 5dbbf36563
No known key found for this signature in database
GPG Key ID: AE53149BB0C45AF1
2 changed files with 7 additions and 4 deletions

View File

@ -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<std::string> WASAPIStream::GetAvailableDevices()
{
HRESULT result = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
@ -131,7 +134,7 @@ std::vector<std::string> WASAPIStream::GetAvailableDevices()
return device_names;
}
ComPtr<IMMDevice> WASAPIStream::GetDeviceByName(std::string name)
ComPtr<IMMDevice> 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

View File

@ -40,7 +40,7 @@ public:
static bool isValid();
static std::vector<std::string> GetAvailableDevices();
static Microsoft::WRL::ComPtr<IMMDevice> GetDeviceByName(std::string name);
static Microsoft::WRL::ComPtr<IMMDevice> GetDeviceByName(std::string_view name);
private:
u32 m_frames_in_buffer = 0;