OpenAL returns device names with UTF-8

This commit is contained in:
Ilya Fedin 2020-05-14 08:39:45 +04:00 committed by John Preston
parent 8d1db85a28
commit ced2652deb
2 changed files with 5 additions and 5 deletions

View File

@ -86,14 +86,14 @@ void EnumeratePlaybackDevices() {
Assert(devices != nullptr); Assert(devices != nullptr);
while (*devices != 0) { while (*devices != 0) {
auto deviceName8Bit = QByteArray(devices); auto deviceName8Bit = QByteArray(devices);
auto deviceName = QString::fromLocal8Bit(deviceName8Bit); auto deviceName = QString::fromUtf8(deviceName8Bit);
deviceNames.append(deviceName); deviceNames.append(deviceName);
devices += deviceName8Bit.size() + 1; devices += deviceName8Bit.size() + 1;
} }
LOG(("Audio Playback Devices: %1").arg(deviceNames.join(';'))); LOG(("Audio Playback Devices: %1").arg(deviceNames.join(';')));
if (auto device = alcGetString(nullptr, ALC_DEFAULT_ALL_DEVICES_SPECIFIER)) { if (auto device = alcGetString(nullptr, ALC_DEFAULT_ALL_DEVICES_SPECIFIER)) {
LOG(("Audio Playback Default Device: %1").arg(QString::fromLocal8Bit(device))); LOG(("Audio Playback Default Device: %1").arg(QString::fromUtf8(device)));
} else { } else {
LOG(("Audio Playback Default Device: (null)")); LOG(("Audio Playback Default Device: (null)"));
} }
@ -105,14 +105,14 @@ void EnumerateCaptureDevices() {
Assert(devices != nullptr); Assert(devices != nullptr);
while (*devices != 0) { while (*devices != 0) {
auto deviceName8Bit = QByteArray(devices); auto deviceName8Bit = QByteArray(devices);
auto deviceName = QString::fromLocal8Bit(deviceName8Bit); auto deviceName = QString::fromUtf8(deviceName8Bit);
deviceNames.append(deviceName); deviceNames.append(deviceName);
devices += deviceName8Bit.size() + 1; devices += deviceName8Bit.size() + 1;
} }
LOG(("Audio Capture Devices: %1").arg(deviceNames.join(';'))); LOG(("Audio Capture Devices: %1").arg(deviceNames.join(';')));
if (auto device = alcGetString(nullptr, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)) { if (auto device = alcGetString(nullptr, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)) {
LOG(("Audio Capture Default Device: %1").arg(QString::fromLocal8Bit(device))); LOG(("Audio Capture Default Device: %1").arg(QString::fromUtf8(device)));
} else { } else {
LOG(("Audio Capture Default Device: (null)")); LOG(("Audio Capture Default Device: (null)"));
} }

View File

@ -63,7 +63,7 @@ Instance::Instance() : _inner(new Inner(&_thread)) {
void Instance::check() { void Instance::check() {
_available = false; _available = false;
if (auto device = alcGetString(0, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)) { if (auto device = alcGetString(0, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)) {
if (!QString::fromLocal8Bit(device).isEmpty()) { if (!QString::fromUtf8(device).isEmpty()) {
_available = true; _available = true;
return; return;
} }