overlays: support playing audio with video_view
This commit is contained in:
@@ -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<u8>& icon_buf, const std::string& video_path)
|
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)
|
||||||
{
|
{
|
||||||
|
const std::string audio_path; // no audio here
|
||||||
std::unique_ptr<overlay_element> image = resource_id != image_resource_id::raw_image
|
std::unique_ptr<overlay_element> image = resource_id != image_resource_id::raw_image
|
||||||
? std::make_unique<video_view>(video_path, resource_id)
|
? std::make_unique<video_view>(video_path, audio_path, resource_id)
|
||||||
: !icon_buf.empty() ? std::make_unique<video_view>(video_path, icon_buf)
|
: !icon_buf.empty() ? std::make_unique<video_view>(video_path, audio_path, icon_buf)
|
||||||
: std::make_unique<video_view>(video_path, resource_config::standard_image_resource::save); // Fallback
|
: std::make_unique<video_view>(video_path, audio_path, resource_config::standard_image_resource::save); // Fallback
|
||||||
image->set_size(160, 110);
|
image->set_size(160, 110);
|
||||||
image->set_padding(36, 36, 11, 11); // Square image, 88x88
|
image->set_padding(36, 36, 11, 11); // Square image, 88x88
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ namespace rsx
|
|||||||
{
|
{
|
||||||
namespace overlays
|
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())
|
if (!thumbnail_path.empty())
|
||||||
{
|
{
|
||||||
@@ -17,9 +17,9 @@ namespace rsx
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
video_view::video_view(const std::string& video_path, const std::vector<u8>& thumbnail_buf)
|
video_view::video_view(const std::string& video_path, const std::string& audio_path, const std::vector<u8>& thumbnail_buf)
|
||||||
{
|
{
|
||||||
init_video(video_path);
|
init_video(video_path, audio_path);
|
||||||
|
|
||||||
if (!thumbnail_buf.empty())
|
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)
|
: m_thumbnail_id(thumbnail_id)
|
||||||
{
|
{
|
||||||
init_video(video_path);
|
init_video(video_path, audio_path);
|
||||||
set_image_resource(thumbnail_id);
|
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;
|
if (video_path.empty()) return;
|
||||||
|
|
||||||
m_video_source = Emu.GetCallbacks().make_video_source();
|
m_video_source = ensure(Emu.GetCallbacks().make_video_source());
|
||||||
ensure(!!m_video_source);
|
|
||||||
|
|
||||||
m_video_source->set_update_callback([this]()
|
m_video_source->set_update_callback([this]()
|
||||||
{
|
{
|
||||||
if (m_video_active)
|
if (m_video_active)
|
||||||
@@ -54,6 +52,7 @@ namespace rsx
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
m_video_source->set_video_path(video_path);
|
m_video_source->set_video_path(video_path);
|
||||||
|
m_video_source->set_audio_path(audio_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void video_view::set_active(bool active)
|
void video_view::set_active(bool active)
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ namespace rsx
|
|||||||
class video_view final : public image_view
|
class video_view final : public image_view
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
video_view(const std::string& video_path, const std::string& thumbnail_path);
|
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::vector<u8>& thumbnail_buf);
|
video_view(const std::string& video_path, const std::string& audio_path, const std::vector<u8>& thumbnail_buf);
|
||||||
video_view(const std::string& video_path, u8 thumbnail_id);
|
video_view(const std::string& video_path, const std::string& audio_path, u8 thumbnail_id);
|
||||||
virtual ~video_view();
|
virtual ~video_view();
|
||||||
|
|
||||||
void set_active(bool active);
|
void set_active(bool active);
|
||||||
@@ -30,7 +30,7 @@ namespace rsx
|
|||||||
compiled_resource& get_compiled() override;
|
compiled_resource& get_compiled() override;
|
||||||
|
|
||||||
private:
|
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;
|
usz m_buffer_index = 0;
|
||||||
std::array<std::unique_ptr<video_info>, 2> m_video_info; // double buffer
|
std::array<std::unique_ptr<video_info>, 2> m_video_info; // double buffer
|
||||||
|
|||||||
@@ -335,7 +335,11 @@ void qt_video_source_wrapper::set_video_path(const std::string& video_path)
|
|||||||
{
|
{
|
||||||
Emu.CallFromMainThread([this, path = video_path]()
|
Emu.CallFromMainThread([this, path = video_path]()
|
||||||
{
|
{
|
||||||
m_qt_video_source = std::make_unique<qt_video_source>();
|
if (!m_qt_video_source)
|
||||||
|
{
|
||||||
|
m_qt_video_source = std::make_unique<qt_video_source>();
|
||||||
|
}
|
||||||
|
|
||||||
m_qt_video_source->m_image_change_callback = [this](const QVideoFrame& frame)
|
m_qt_video_source->m_image_change_callback = [this](const QVideoFrame& frame)
|
||||||
{
|
{
|
||||||
std::unique_lock lock(m_qt_video_source->m_image_mutex);
|
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]()
|
Emu.CallFromMainThread([this, path = audio_path]()
|
||||||
{
|
{
|
||||||
// TODO
|
if (!m_qt_video_source)
|
||||||
|
{
|
||||||
|
m_qt_video_source = std::make_unique<qt_video_source>();
|
||||||
|
}
|
||||||
|
|
||||||
|
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]()
|
Emu.CallFromMainThread([this, active]()
|
||||||
{
|
{
|
||||||
|
ensure(m_qt_video_source);
|
||||||
m_qt_video_source->set_active(true);
|
m_qt_video_source->set_active(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user