Skip to content

Commit 892da25

Browse files
committed
overlays: support playing audio with video_view
1 parent 0603d24 commit 892da25

File tree

4 files changed

+29
-19
lines changed

4 files changed

+29
-19
lines changed

rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ namespace rsx
99
{
1010
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<u8>& icon_buf, const std::string& video_path)
1111
{
12+
const std::string audio_path; // no audio here
1213
std::unique_ptr<overlay_element> image = resource_id != image_resource_id::raw_image
13-
? std::make_unique<video_view>(video_path, resource_id)
14-
: !icon_buf.empty() ? std::make_unique<video_view>(video_path, icon_buf)
15-
: std::make_unique<video_view>(video_path, resource_config::standard_image_resource::save); // Fallback
14+
? std::make_unique<video_view>(video_path, audio_path, resource_id)
15+
: !icon_buf.empty() ? std::make_unique<video_view>(video_path, audio_path, icon_buf)
16+
: std::make_unique<video_view>(video_path, audio_path, resource_config::standard_image_resource::save); // Fallback
1617
image->set_size(160, 110);
1718
image->set_padding(36, 36, 11, 11); // Square image, 88x88
1819

rpcs3/Emu/RSX/Overlays/overlay_video.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ namespace rsx
66
{
77
namespace overlays
88
{
9-
video_view::video_view(const std::string& video_path, const std::string& thumbnail_path)
9+
video_view::video_view(const std::string& video_path, const std::string& audio_path, const std::string& thumbnail_path)
1010
{
11-
init_video(video_path);
11+
init_video(video_path, audio_path);
1212

1313
if (!thumbnail_path.empty())
1414
{
@@ -17,9 +17,9 @@ namespace rsx
1717
}
1818
}
1919

20-
video_view::video_view(const std::string& video_path, const std::vector<u8>& thumbnail_buf)
20+
video_view::video_view(const std::string& video_path, const std::string& audio_path, const std::vector<u8>& thumbnail_buf)
2121
{
22-
init_video(video_path);
22+
init_video(video_path, audio_path);
2323

2424
if (!thumbnail_buf.empty())
2525
{
@@ -28,24 +28,22 @@ namespace rsx
2828
}
2929
}
3030

31-
video_view::video_view(const std::string& video_path, u8 thumbnail_id)
31+
video_view::video_view(const std::string& video_path, const std::string& audio_path, u8 thumbnail_id)
3232
: m_thumbnail_id(thumbnail_id)
3333
{
34-
init_video(video_path);
34+
init_video(video_path, audio_path);
3535
set_image_resource(thumbnail_id);
3636
}
3737

3838
video_view::~video_view()
3939
{
4040
}
4141

42-
void video_view::init_video(const std::string& video_path)
42+
void video_view::init_video(const std::string& video_path, const std::string& audio_path)
4343
{
4444
if (video_path.empty()) return;
4545

46-
m_video_source = Emu.GetCallbacks().make_video_source();
47-
ensure(!!m_video_source);
48-
46+
m_video_source = ensure(Emu.GetCallbacks().make_video_source());
4947
m_video_source->set_update_callback([this]()
5048
{
5149
if (m_video_active)
@@ -54,6 +52,7 @@ namespace rsx
5452
}
5553
});
5654
m_video_source->set_video_path(video_path);
55+
m_video_source->set_audio_path(audio_path);
5756
}
5857

5958
void video_view::set_active(bool active)

rpcs3/Emu/RSX/Overlays/overlay_video.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ namespace rsx
1919
class video_view final : public image_view
2020
{
2121
public:
22-
video_view(const std::string& video_path, const std::string& thumbnail_path);
23-
video_view(const std::string& video_path, const std::vector<u8>& thumbnail_buf);
24-
video_view(const std::string& video_path, u8 thumbnail_id);
22+
video_view(const std::string& video_path, const std::string& audio_path, const std::string& thumbnail_path);
23+
video_view(const std::string& video_path, const std::string& audio_path, const std::vector<u8>& thumbnail_buf);
24+
video_view(const std::string& video_path, const std::string& audio_path, u8 thumbnail_id);
2525
virtual ~video_view();
2626

2727
void set_active(bool active);
@@ -30,7 +30,7 @@ namespace rsx
3030
compiled_resource& get_compiled() override;
3131

3232
private:
33-
void init_video(const std::string& video_path);
33+
void init_video(const std::string& video_path, const std::string& audio_path);
3434

3535
usz m_buffer_index = 0;
3636
std::array<std::unique_ptr<video_info>, 2> m_video_info; // double buffer

rpcs3/rpcs3qt/qt_video_source.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,11 @@ void qt_video_source_wrapper::set_video_path(const std::string& video_path)
335335
{
336336
Emu.CallFromMainThread([this, path = video_path]()
337337
{
338-
m_qt_video_source = std::make_unique<qt_video_source>();
338+
if (!m_qt_video_source)
339+
{
340+
m_qt_video_source = std::make_unique<qt_video_source>();
341+
}
342+
339343
m_qt_video_source->m_image_change_callback = [this](const QVideoFrame& frame)
340344
{
341345
std::unique_lock lock(m_qt_video_source->m_image_mutex);
@@ -371,14 +375,20 @@ void qt_video_source_wrapper::set_audio_path(const std::string& audio_path)
371375
{
372376
Emu.CallFromMainThread([this, path = audio_path]()
373377
{
374-
// TODO
378+
if (!m_qt_video_source)
379+
{
380+
m_qt_video_source = std::make_unique<qt_video_source>();
381+
}
382+
383+
m_qt_video_source->set_audio_path(path);
375384
});
376385
}
377386

378387
void qt_video_source_wrapper::set_active(bool active)
379388
{
380389
Emu.CallFromMainThread([this, active]()
381390
{
391+
ensure(m_qt_video_source);
382392
m_qt_video_source->set_active(true);
383393
});
384394
}

0 commit comments

Comments
 (0)