Prepare for sound. Fix game name being gsr-ui on wayland in some cases when saving video when the ui is open

This commit is contained in:
dec05eba
2025-02-10 18:22:21 +01:00
parent 3d6354c642
commit f4e44cbef5
10 changed files with 163 additions and 4 deletions

22
include/AudioPlayer.hpp Normal file
View File

@@ -0,0 +1,22 @@
#pragma once
#include <thread>
namespace gsr {
// Only plays raw stereo PCM audio in 48000hz in s16le format.
// Use this command to convert an audio file (input.wav) to a format playable by this class (output.pcm):
// ffmpeg -i input.wav -f s16le -acodec pcm_s16le -ar 48000 output.pcm
class AudioPlayer {
public:
AudioPlayer() = default;
~AudioPlayer();
AudioPlayer(const AudioPlayer&) = delete;
AudioPlayer& operator=(const AudioPlayer&) = delete;
bool play(const char *filepath);
private:
std::thread thread;
bool stop_playing_audio = false;
int audio_file_fd = -1;
};
}