diff options
author | dec05eba <dec05eba@protonmail.com> | 2025-02-10 18:22:21 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2025-02-10 18:22:21 +0100 |
commit | f4e44cbef5dbbc2a2b71e7b9b70ee72d30b7c6a6 (patch) | |
tree | fba7a409ad73abc4b233c9dfd960f014c2df6b69 /include | |
parent | 3d6354c642244cde272c328a31c72a0adba54999 (diff) |
Prepare for sound. Fix game name being gsr-ui on wayland in some cases when saving video when the ui is open
Diffstat (limited to 'include')
-rw-r--r-- | include/AudioPlayer.hpp | 22 | ||||
-rw-r--r-- | include/Overlay.hpp | 3 | ||||
-rw-r--r-- | include/WindowUtils.hpp | 2 |
3 files changed, 27 insertions, 0 deletions
diff --git a/include/AudioPlayer.hpp b/include/AudioPlayer.hpp new file mode 100644 index 0000000..22c3be8 --- /dev/null +++ b/include/AudioPlayer.hpp @@ -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; + }; +}
\ No newline at end of file diff --git a/include/Overlay.hpp b/include/Overlay.hpp index 4fbf54e..f3025b2 100644 --- a/include/Overlay.hpp +++ b/include/Overlay.hpp @@ -8,6 +8,7 @@ #include "WindowUtils.hpp" #include "GlobalHotkeysLinux.hpp" #include "GlobalHotkeysJoystick.hpp" +#include "AudioPlayer.hpp" #include <mglpp/window/Window.hpp> #include <mglpp/window/Event.hpp> @@ -189,5 +190,7 @@ namespace gsr { mgl::Clock replay_save_clock; bool replay_save_show_notification = false; + + AudioPlayer audio_player; }; }
\ No newline at end of file diff --git a/include/WindowUtils.hpp b/include/WindowUtils.hpp index c8806df..ddecaea 100644 --- a/include/WindowUtils.hpp +++ b/include/WindowUtils.hpp @@ -18,6 +18,8 @@ namespace gsr { Window get_focused_window(Display *dpy, WindowCaptureType cap_type); std::string get_focused_window_name(Display *dpy, WindowCaptureType window_capture_type); + std::string get_window_name_at_position(Display *dpy, mgl::vec2i position, Window ignore_window); + std::string get_window_name_at_cursor_position(Display *dpy, Window ignore_window); mgl::vec2i get_cursor_position(Display *dpy, Window *window); mgl::vec2i create_window_get_center_position(Display *display); std::string get_window_manager_name(Display *display); |