Feature: Allow choosing audio backend (#1588)

* Fix X11 being searched for on macOS

* Add ability to switch audio backends

* Fix issues with c arrays of std dynamic size items

* Fix old uses of sizeof()

* Remove current selected option from list

* Don’t show items if we only have one option
This commit is contained in:
David Chavez 2022-09-27 01:48:47 +02:00 committed by GitHub
commit dbc4d8199e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 116 additions and 40 deletions

View file

@ -502,6 +502,22 @@ namespace GameMenuBar {
UIWidgets::Spacer(0);
BindAudioSlider("Fanfare Volume: %d %%", "gFanfareVolume", 1.0f, SEQ_FANFARE);
ImGui::Text("Audio API (Needs reload)");
auto audioBackends = SohImGui::GetAvailableAudioBackends();
auto currentAudioBackend = SohImGui::GetCurrentAudioBackend();
if (ImGui::BeginCombo("##AApi", currentAudioBackend.second)) {
if (audioBackends.size() > 1) {
for (uint8_t i = 0; i < audioBackends.size(); i++) {
if (ImGui::Selectable(audioBackends[i].second, audioBackends[i] == currentAudioBackend)) {
SohImGui::SetCurrentAudioBackend(i, audioBackends[i]);
}
}
}
ImGui::EndCombo();
}
ImGui::EndMenu();
}
@ -609,13 +625,15 @@ namespace GameMenuBar {
}
ImGui::Text("Renderer API (Needs reload)");
auto backends = SohImGui::GetAvailableRenderingBackends();
auto currentBackend = SohImGui::GetCurrentRenderingBackend();
auto renderingBackends = SohImGui::GetAvailableRenderingBackends();
auto currentRenderingBackend = SohImGui::GetCurrentRenderingBackend();
if (ImGui::BeginCombo("##RApi", currentBackend.second)) {
for (uint8_t i = 0; i < sizeof(backends) / sizeof(backends[0]); i++) {
if (ImGui::Selectable(backends[i].second, backends[i] == currentBackend)) {
SohImGui::SetCurrentRenderingBackend(i, backends[i]);
if (ImGui::BeginCombo("##RApi", currentRenderingBackend.second)) {
if (renderingBackends.size() > 1) {
for (uint8_t i = 0; i < renderingBackends.size(); i++) {
if (ImGui::Selectable(renderingBackends[i].second, renderingBackends[i] == currentRenderingBackend)) {
SohImGui::SetCurrentRenderingBackend(i, renderingBackends[i]);
}
}
}