diff options
author | Chris Robinson <[email protected]> | 2018-11-13 06:29:02 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-13 06:29:02 -0800 |
commit | 0dfb805fa2f85bed47612a75628d7d9742877b26 (patch) | |
tree | 8b6bd359c5f1a6de8a06bcebdaf22add6a3555fe /Alc/backends | |
parent | 6f635d3b1a3c80767dd7f1ba6c9ccce78ac35efc (diff) |
Use utf8_to_wstr to convert UTF-8 to wstring
Diffstat (limited to 'Alc/backends')
-rw-r--r-- | Alc/backends/wasapi.cpp | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/Alc/backends/wasapi.cpp b/Alc/backends/wasapi.cpp index f2adf328..50c0baa8 100644 --- a/Alc/backends/wasapi.cpp +++ b/Alc/backends/wasapi.cpp @@ -707,16 +707,11 @@ static ALCenum ALCwasapiPlayback_open(ALCwasapiPlayback *self, const ALCchar *de ); if(iter == PlaybackDevices.cend()) { - int len; - if((len=MultiByteToWideChar(CP_UTF8, 0, deviceName, -1, nullptr, 0)) > 0) - { - std::vector<WCHAR> wname(len); - MultiByteToWideChar(CP_UTF8, 0, deviceName, -1, wname.data(), len); - iter = std::find_if(PlaybackDevices.cbegin(), PlaybackDevices.cend(), - [&wname](const DevMap &entry) -> bool - { return entry.devid == wname.data(); } - ); - } + std::wstring wname{utf8_to_wstr(deviceName)}; + iter = std::find_if(PlaybackDevices.cbegin(), PlaybackDevices.cend(), + [&wname](const DevMap &entry) -> bool + { return entry.devid == wname; } + ); } if(iter == PlaybackDevices.cend()) WARN("Failed to find device name matching \"%s\"\n", deviceName); @@ -1378,16 +1373,11 @@ static ALCenum ALCwasapiCapture_open(ALCwasapiCapture *self, const ALCchar *devi ); if(iter == CaptureDevices.cend()) { - int len; - if((len=MultiByteToWideChar(CP_UTF8, 0, deviceName, -1, nullptr, 0)) > 0) - { - std::vector<WCHAR> wname(len); - MultiByteToWideChar(CP_UTF8, 0, deviceName, -1, wname.data(), len); - iter = std::find_if(CaptureDevices.cbegin(), CaptureDevices.cend(), - [&wname](const DevMap &entry) -> bool - { return entry.devid == wname.data(); } - ); - } + std::wstring wname{utf8_to_wstr(deviceName)}; + iter = std::find_if(CaptureDevices.cbegin(), CaptureDevices.cend(), + [&wname](const DevMap &entry) -> bool + { return entry.devid == wname; } + ); } if(iter == CaptureDevices.cend()) WARN("Failed to find device name matching \"%s\"\n", deviceName); |