mirror of
https://github.com/badaix/snapcast.git
synced 2025-08-06 10:09:33 +02:00
Fix deprecation warning
This commit is contained in:
parent
2cc9567847
commit
74b3e7d9a4
1 changed files with 12 additions and 3 deletions
|
@ -107,9 +107,18 @@ inline PcmDevice convertToDevice(int idx, IMMDevicePtr& device)
|
||||||
|
|
||||||
desc.idx = idx;
|
desc.idx = idx;
|
||||||
|
|
||||||
using converter = wstring_convert<codecvt_utf8_utf16<wchar_t>, wchar_t>;
|
// Convert a wide Unicode string to an UTF8 string
|
||||||
desc.name = converter{}.to_bytes(id);
|
auto utf8_encode = [](const std::wstring& wstr) {
|
||||||
desc.description = converter{}.to_bytes(deviceName.pwszVal);
|
if (wstr.empty())
|
||||||
|
return std::string();
|
||||||
|
int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
|
||||||
|
std::string strTo(size_needed, 0);
|
||||||
|
WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
|
||||||
|
return strTo;
|
||||||
|
};
|
||||||
|
|
||||||
|
desc.name = utf8_encode(id);
|
||||||
|
desc.description = utf8_encode(deviceName.pwszVal);
|
||||||
|
|
||||||
CoTaskMemFree(id);
|
CoTaskMemFree(id);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue