Add audio device menu button
Some checks failed
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linux32 flags:32 name:Linux GCC 32 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linux64 flags:64 name:Linux GCC x64 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linuxarm32 flags:arm32 name:Linux GCC ARM 32 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linuxarm64 flags:arm64 name:Linux GCC ARM 64 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:macos name:macOS Apple Silicon os:macos-14]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:win32 flags:-A Win32 name:Windows VS2022 Win32 os:windows-2022]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:win64 flags:-A x64 name:Windows VS2022 x64 os:windows-2022]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:winarm64 flags:-A ARM64 name:Windows VS2022 ARM os:windows-2022]) (push) Has been cancelled
CD / Create Pi Mono Setup (push) Has been cancelled
CD / Publishing (push) Has been cancelled

Adds a basic button that cycles through the available audio output devices.
This commit is contained in:
Neptune
2025-01-30 00:12:14 -07:00
committed by Lorenzooone
parent 981acaa420
commit 7288cf163a
3 changed files with 37 additions and 0 deletions

View File

@@ -1,4 +1,7 @@
#include <iostream>
#include "frontend.hpp"
#include "SFML/Audio/PlaybackDevice.hpp"
#define FPS_WINDOW_SIZE 64
@@ -1371,6 +1374,25 @@ void WindowScreen::poll(bool do_everything) {
case AUDIO_MENU_RESTART:
this->audio_data->request_audio_restart();
break;
case AUDIO_MENU_NEXT_DEVICE:
if (std::optional<std::string> cur_dev = sf::PlaybackDevice::getDevice()) {
std::cout << *cur_dev << std::endl;
int idx = 0;
auto audio_devices = sf::PlaybackDevice::getAvailableDevices();
for (const std::string& device : audio_devices) {
if (device == *cur_dev) {
break;
}
idx++;
}
idx = std::max((idx + 1) % static_cast<int>(audio_devices.size()), 0);
std::cout << "next device: " << audio_devices.at(idx) << std::endl;
if (sf::PlaybackDevice::setDevice(audio_devices.at(idx))) {
std::cout << "Device selected: " << audio_devices.at(idx) << std::endl;
// this->audio_data->request_audio_restart();
}
}
break;
default:
break;
}