step: GameMode

This commit is contained in:
Jakob Gegeniger committed 2026-10-15 00:36:49 +02:00
1 parent c1e8f2a7a4
commit 313e097a53
8 files changed
+251 -46

No files matched your search

+20 -12
View File
@@ -197,20 +197,14 @@ struct SwordConfig {
class MediaPlayer {
public:
static void playWavFile(const string& filePath) {
if (filePath.empty()) {
fmt::println(stderr, "ERROR: Empty file path");
return;
}
thread audioThread([filePath]() {
auto cmd = fmt::format("aplay '{}'", filePath);
auto result = system(cmd.c_str());
if (result != 0) {
fmt::println(stderr, "ERROR: Failed to play audio file: '{}'", filePath);
}
});
static void playWavFileAsync(const string& filePath) {
auto audioThread = playWavFileThread(filePath);
audioThread.detach();
}
static void playWavFileSync(const string& filePath) {
auto audioThread = playWavFileThread(filePath);
audioThread.join();
}
static void setVolume(int volume) {
if (volume < 0) {
@@ -241,4 +235,18 @@ class MediaPlayer {
}
return {};
}
static thread playWavFileThread(const string& filePath) {
if (filePath.empty()) {
fmt::println(stderr, "ERROR: Empty file path");
thread([](){});
}
return thread([filePath]() {
auto cmd = fmt::format("aplay '{}'", filePath);
auto result = system(cmd.c_str());
if (result != 0) {
fmt::println(stderr, "ERROR: Failed to play audio file: '{}'", filePath);
}
});
}
};