engine: sync editor rendering and ui changes
This commit is contained in:
@@ -10,6 +10,45 @@ namespace XCEngine {
|
||||
namespace Audio {
|
||||
namespace WASAPI {
|
||||
|
||||
namespace {
|
||||
|
||||
std::string ConvertWaveOutDeviceName(const TCHAR* deviceName) {
|
||||
if (deviceName == nullptr) {
|
||||
return {};
|
||||
}
|
||||
|
||||
#if defined(UNICODE) || defined(_UNICODE)
|
||||
const int requiredBytes = WideCharToMultiByte(
|
||||
CP_UTF8,
|
||||
0,
|
||||
deviceName,
|
||||
-1,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
if (requiredBytes <= 1) {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string utf8Name(static_cast<std::size_t>(requiredBytes - 1), '\0');
|
||||
WideCharToMultiByte(
|
||||
CP_UTF8,
|
||||
0,
|
||||
deviceName,
|
||||
-1,
|
||||
utf8Name.data(),
|
||||
requiredBytes,
|
||||
nullptr,
|
||||
nullptr);
|
||||
return utf8Name;
|
||||
#else
|
||||
return std::string(deviceName);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
WASAPIBackend::WASAPIBackend()
|
||||
: m_audioBuffer1(BufferSize * 2)
|
||||
, m_audioBuffer2(BufferSize * 2)
|
||||
@@ -65,7 +104,7 @@ std::string WASAPIBackend::GetDeviceName() const {
|
||||
void WASAPIBackend::GetAvailableDevices(std::vector<std::string>& devices) {
|
||||
devices.clear();
|
||||
for (const auto& caps : m_waveOutCaps) {
|
||||
devices.push_back(caps.szPname);
|
||||
devices.push_back(ConvertWaveOutDeviceName(caps.szPname));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +112,7 @@ bool WASAPIBackend::SetDevice(const std::string& deviceName) {
|
||||
for (UINT i = 0; i < waveOutGetNumDevs(); ++i) {
|
||||
WAVEOUTCAPS caps;
|
||||
waveOutGetDevCaps(i, &caps, sizeof(WAVEOUTCAPS));
|
||||
if (deviceName == caps.szPname) {
|
||||
if (deviceName == ConvertWaveOutDeviceName(caps.szPname)) {
|
||||
m_deviceName = deviceName;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user