From 892da25cf0dd1483a9fc02718ff6d58ad939896c Mon Sep 17 00:00:00 2001 From: Megamouse Date: Tue, 10 Mar 2026 07:34:45 +0100 Subject: [PATCH] overlays: support playing audio with video_view --- .../Emu/RSX/Overlays/overlay_save_dialog.cpp | 7 ++++--- rpcs3/Emu/RSX/Overlays/overlay_video.cpp | 19 +++++++++---------- rpcs3/Emu/RSX/Overlays/overlay_video.h | 8 ++++---- rpcs3/rpcs3qt/qt_video_source.cpp | 14 ++++++++++++-- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp b/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp index 604dee7fc4..2847db969c 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp @@ -9,10 +9,11 @@ namespace rsx { save_dialog::save_dialog_entry::save_dialog_entry(const std::string& text1, const std::string& text2, const std::string& text3, u8 resource_id, const std::vector& icon_buf, const std::string& video_path) { + const std::string audio_path; // no audio here std::unique_ptr image = resource_id != image_resource_id::raw_image - ? std::make_unique(video_path, resource_id) - : !icon_buf.empty() ? std::make_unique(video_path, icon_buf) - : std::make_unique(video_path, resource_config::standard_image_resource::save); // Fallback + ? std::make_unique(video_path, audio_path, resource_id) + : !icon_buf.empty() ? std::make_unique(video_path, audio_path, icon_buf) + : std::make_unique(video_path, audio_path, resource_config::standard_image_resource::save); // Fallback image->set_size(160, 110); image->set_padding(36, 36, 11, 11); // Square image, 88x88 diff --git a/rpcs3/Emu/RSX/Overlays/overlay_video.cpp b/rpcs3/Emu/RSX/Overlays/overlay_video.cpp index ac6017d35f..44ca1f53ef 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_video.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_video.cpp @@ -6,9 +6,9 @@ namespace rsx { namespace overlays { - video_view::video_view(const std::string& video_path, const std::string& thumbnail_path) + video_view::video_view(const std::string& video_path, const std::string& audio_path, const std::string& thumbnail_path) { - init_video(video_path); + init_video(video_path, audio_path); if (!thumbnail_path.empty()) { @@ -17,9 +17,9 @@ namespace rsx } } - video_view::video_view(const std::string& video_path, const std::vector& thumbnail_buf) + video_view::video_view(const std::string& video_path, const std::string& audio_path, const std::vector& thumbnail_buf) { - init_video(video_path); + init_video(video_path, audio_path); if (!thumbnail_buf.empty()) { @@ -28,10 +28,10 @@ namespace rsx } } - video_view::video_view(const std::string& video_path, u8 thumbnail_id) + video_view::video_view(const std::string& video_path, const std::string& audio_path, u8 thumbnail_id) : m_thumbnail_id(thumbnail_id) { - init_video(video_path); + init_video(video_path, audio_path); set_image_resource(thumbnail_id); } @@ -39,13 +39,11 @@ namespace rsx { } - void video_view::init_video(const std::string& video_path) + void video_view::init_video(const std::string& video_path, const std::string& audio_path) { if (video_path.empty()) return; - m_video_source = Emu.GetCallbacks().make_video_source(); - ensure(!!m_video_source); - + m_video_source = ensure(Emu.GetCallbacks().make_video_source()); m_video_source->set_update_callback([this]() { if (m_video_active) @@ -54,6 +52,7 @@ namespace rsx } }); m_video_source->set_video_path(video_path); + m_video_source->set_audio_path(audio_path); } void video_view::set_active(bool active) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_video.h b/rpcs3/Emu/RSX/Overlays/overlay_video.h index 92297dee42..ab148c508d 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_video.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_video.h @@ -19,9 +19,9 @@ namespace rsx class video_view final : public image_view { public: - video_view(const std::string& video_path, const std::string& thumbnail_path); - video_view(const std::string& video_path, const std::vector& thumbnail_buf); - video_view(const std::string& video_path, u8 thumbnail_id); + video_view(const std::string& video_path, const std::string& audio_path, const std::string& thumbnail_path); + video_view(const std::string& video_path, const std::string& audio_path, const std::vector& thumbnail_buf); + video_view(const std::string& video_path, const std::string& audio_path, u8 thumbnail_id); virtual ~video_view(); void set_active(bool active); @@ -30,7 +30,7 @@ namespace rsx compiled_resource& get_compiled() override; private: - void init_video(const std::string& video_path); + void init_video(const std::string& video_path, const std::string& audio_path); usz m_buffer_index = 0; std::array, 2> m_video_info; // double buffer diff --git a/rpcs3/rpcs3qt/qt_video_source.cpp b/rpcs3/rpcs3qt/qt_video_source.cpp index 2d4ce34aa3..8877e00c0c 100644 --- a/rpcs3/rpcs3qt/qt_video_source.cpp +++ b/rpcs3/rpcs3qt/qt_video_source.cpp @@ -335,7 +335,11 @@ void qt_video_source_wrapper::set_video_path(const std::string& video_path) { Emu.CallFromMainThread([this, path = video_path]() { - m_qt_video_source = std::make_unique(); + if (!m_qt_video_source) + { + m_qt_video_source = std::make_unique(); + } + m_qt_video_source->m_image_change_callback = [this](const QVideoFrame& frame) { std::unique_lock lock(m_qt_video_source->m_image_mutex); @@ -371,7 +375,12 @@ void qt_video_source_wrapper::set_audio_path(const std::string& audio_path) { Emu.CallFromMainThread([this, path = audio_path]() { - // TODO + if (!m_qt_video_source) + { + m_qt_video_source = std::make_unique(); + } + + m_qt_video_source->set_audio_path(path); }); } @@ -379,6 +388,7 @@ void qt_video_source_wrapper::set_active(bool active) { Emu.CallFromMainThread([this, active]() { + ensure(m_qt_video_source); m_qt_video_source->set_active(true); }); }