Audio: device switching and channel count detection (#12246)

This commit is contained in:
Vestrel 2022-07-09 00:13:38 +09:00 committed by GitHub
parent 4b787b22c8
commit 98b730c806
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 1235 additions and 395 deletions

View file

@ -5,6 +5,8 @@
#include "util/logs.hpp"
#include "util/v128.hpp"
#include <locale>
#include <codecvt>
#include <algorithm>
#include <string_view>
#include "Thread.h"
@ -13,8 +15,6 @@
#include <Windows.h>
#else
#include <errno.h>
#include <locale>
#include <codecvt>
#endif
std::string wchar_to_utf8(std::wstring_view src)
@ -26,11 +26,17 @@ std::string wchar_to_utf8(std::wstring_view src)
WideCharToMultiByte(CP_UTF8, 0, src.data(), src.size(), utf8_string.data(), tmp_size, nullptr, nullptr);
return utf8_string;
#else
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> converter{};
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converter{};
return converter.to_bytes(src.data());
#endif
}
std::string utf16_to_utf8(std::u16string_view src)
{
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> converter{};
return converter.to_bytes(src.data());
}
std::wstring utf8_to_wchar(std::string_view src)
{
#ifdef _WIN32

View file

@ -10,6 +10,7 @@
std::wstring utf8_to_wchar(std::string_view src);
std::string wchar_to_utf8(std::wstring_view src);
std::string utf16_to_utf8(std::u16string_view src);
// Copy null-terminated string from a std::string or a char array to a char array with truncation
template <typename D, typename T>