fix(audio-info): crash when device name contains special characters (#4095)

This commit is contained in:
David Lane
2026-01-16 22:41:23 -05:00
committed by GitHub
parent fd2bfaac7e
commit ab52e27e0e
14 changed files with 476 additions and 163 deletions

View File

@@ -16,10 +16,10 @@
#include <synchapi.h>
// local includes
#include "misc.h"
#include "src/config.h"
#include "src/logging.h"
#include "src/platform/common.h"
#include "utf_utils.h"
// Must be the last included file
// clang-format off
@@ -703,7 +703,7 @@ namespace platf::audio {
audio::wstring_t id;
device->GetId(&id);
sink.host = to_utf8(id.get());
sink.host = utf_utils::to_utf8(id.get());
}
// Prepare to search for the device_id of the virtual audio sink device,
@@ -713,14 +713,14 @@ namespace platf::audio {
if (config::audio.virtual_sink.empty()) {
match_list = match_steam_speakers();
} else {
match_list = match_all_fields(from_utf8(config::audio.virtual_sink));
match_list = match_all_fields(utf_utils::from_utf8(config::audio.virtual_sink));
}
// Search for the virtual audio sink device currently present in the system.
auto matched = find_device_id(match_list);
if (matched) {
// Prepare to fill virtual audio sink names with device_id.
auto device_id = to_utf8(matched->second);
auto device_id = utf_utils::to_utf8(matched->second);
// Also prepend format name (basically channel layout at the moment)
// because we don't want to extend the platform interface.
sink.null = std::make_optional(sink_t::null_t {
@@ -736,7 +736,7 @@ namespace platf::audio {
}
bool is_sink_available(const std::string &sink) override {
const auto match_list = match_all_fields(from_utf8(sink));
const auto match_list = match_all_fields(utf_utils::from_utf8(sink));
const auto matched = find_device_id(match_list);
return static_cast<bool>(matched);
}
@@ -758,7 +758,7 @@ namespace platf::audio {
for (const auto &format : formats) {
auto &name = format.name;
if (current.find(name) == 0) {
auto device_id = from_utf8(current.substr(name.size(), current.size() - name.size()));
auto device_id = utf_utils::from_utf8(current.substr(name.size(), current.size() - name.size()));
return std::make_pair(device_id, std::reference_wrapper(format));
}
}
@@ -805,7 +805,7 @@ namespace platf::audio {
// Sink name does not begin with virtual-(format name), hence it's not a virtual sink
// and we don't want to change playback format of the corresponding device.
// Also need to perform matching, sink name is not necessarily device_id in this case.
auto matched = find_device_id(match_all_fields(from_utf8(sink)));
auto matched = find_device_id(match_all_fields(utf_utils::from_utf8(sink)));
if (matched) {
return matched->second;
} else {