mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-15 12:47:00 +02:00
[desktop] fix audio output engine not saving (#3083)
This issue has like 15 different causes, and I'm surprised it took this long to pop up. 1. LoadString had a hack *specific* to the AudioEngine enum. Why? Solving this was easy, just use the explicit type ctor. -_- 2. The LoadString hack was abused in configure_audio.cpp to get around the canonicalization infrastructure that was explicitly put in to make this exact operation easier. Why? 3. ToString was also broken because of LoadString's garbage output. Technically it might work now, but it's better to just use the canonicalization infrastructure that was made specifically for this purpose. Also did a few tiny optimizations in config/settings cuz wynaut. Signed-off-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3083 Reviewed-by: Caio Oliveira <caiooliveirafarias0@gmail.com> Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: Lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
f40025fd9b
commit
027085e5ba
3 changed files with 93 additions and 68 deletions
|
|
@ -186,16 +186,23 @@ void ConfigureAudio::SetConfiguration() {
|
|||
void ConfigureAudio::SetOutputSinkFromSinkID() {
|
||||
[[maybe_unused]] const QSignalBlocker blocker(sink_combo_box);
|
||||
|
||||
int new_sink_index = 0;
|
||||
const QString sink_id = QString::fromStdString(Settings::values.sink_id.ToString());
|
||||
for (int index = 0; index < sink_combo_box->count(); index++) {
|
||||
if (sink_combo_box->itemText(index) == sink_id) {
|
||||
new_sink_index = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const std::string new_sink_id = []() -> const std::string {
|
||||
const Settings::AudioEngine sink_id = Settings::values.sink_id.GetValue();
|
||||
const auto canonicalizations
|
||||
= Settings::EnumMetadata<Settings::AudioEngine>::Canonicalizations();
|
||||
|
||||
sink_combo_box->setCurrentIndex(new_sink_index);
|
||||
for (u32 i = 0; i < canonicalizations.size(); ++i) {
|
||||
const Settings::AudioEngine value = canonicalizations[i].second;
|
||||
const std::string_view key = canonicalizations[i].first;
|
||||
|
||||
if (sink_id == value)
|
||||
return std::string(key);
|
||||
}
|
||||
|
||||
return std::string("null");
|
||||
}();
|
||||
|
||||
sink_combo_box->setCurrentText(QString::fromStdString(new_sink_id));
|
||||
}
|
||||
|
||||
void ConfigureAudio::SetOutputDevicesFromDeviceID() {
|
||||
|
|
@ -233,8 +240,20 @@ void ConfigureAudio::ApplyConfiguration() {
|
|||
apply_func(is_powered_on);
|
||||
}
|
||||
|
||||
Settings::values.sink_id.LoadString(
|
||||
sink_combo_box->itemText(sink_combo_box->currentIndex()).toStdString());
|
||||
const u32 new_sink_id = [this]() {
|
||||
const std::string sink_id = sink_combo_box->currentText().toStdString();
|
||||
const auto canonicalizations
|
||||
= Settings::EnumMetadata<Settings::AudioEngine>::Canonicalizations();
|
||||
|
||||
for (u32 i = 0; i < canonicalizations.size(); ++i) {
|
||||
if (sink_id == canonicalizations[i].first)
|
||||
return i;
|
||||
}
|
||||
|
||||
return u32(0);
|
||||
}();
|
||||
|
||||
Settings::values.sink_id.SetValue(Settings::AudioEngine(new_sink_id));
|
||||
Settings::values.audio_output_device_id.SetValue(
|
||||
output_device_combo_box->itemText(output_device_combo_box->currentIndex()).toStdString());
|
||||
Settings::values.audio_input_device_id.SetValue(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue