[vlc-commits] Qt: on demand art fetch is now async
Francois Cartegnie
git at videolan.org
Fri May 31 15:24:09 CEST 2019
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri May 31 11:21:26 2019 +0200| [e06b5ca35308ff9b56ff132bc76e1e579e08797d] | committer: Francois Cartegnie
Qt: on demand art fetch is now async
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e06b5ca35308ff9b56ff132bc76e1e579e08797d
---
modules/gui/qt/components/player_controller.cpp | 36 +++++++++++++++++--------
modules/gui/qt/components/player_controller.hpp | 5 ++++
2 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/modules/gui/qt/components/player_controller.cpp b/modules/gui/qt/components/player_controller.cpp
index 37580926f3..111a2407e0 100644
--- a/modules/gui/qt/components/player_controller.cpp
+++ b/modules/gui/qt/components/player_controller.cpp
@@ -886,6 +886,8 @@ PlayerController::PlayerController( intf_thread_t *_p_intf )
/* Audio Menu */
menusAudioMapper = new QSignalMapper(this);
CONNECT( menusAudioMapper, mapped(const QString&), this, menusUpdateAudio(const QString&) );
+
+ input_fetcher_cbs.on_art_fetch_ended = onArtFetchEnded_callback;
}
PlayerController::~PlayerController()
@@ -1351,16 +1353,13 @@ void PlayerController::snapshot()
void PlayerController::requestArtUpdate( input_item_t *p_item, bool b_forced )
{
Q_D(PlayerController);
- bool b_current_item = false;
+
if ( !p_item )
{
/* default to current item */
vlc_player_locker lock{ d->m_player };
if ( vlc_player_IsStarted( d->m_player ) )
- {
p_item = vlc_player_GetCurrentMedia( d->m_player );
- b_current_item = true;
- }
}
if ( p_item )
@@ -1375,16 +1374,31 @@ void PlayerController::requestArtUpdate( input_item_t *p_item, bool b_forced )
libvlc_ArtRequest( vlc_object_instance(d->p_intf), p_item,
(b_forced) ? META_REQUEST_OPTION_SCOPE_ANY
: META_REQUEST_OPTION_NONE,
- NULL, NULL );
- /* No input will signal the cover art to update,
- * let's do it ourself */
- if ( b_current_item )
- d->UpdateArt( p_item );
- else
- emit artChanged( p_item );
+ &input_fetcher_cbs, this );
}
}
+void PlayerController::onArtFetchEnded_callback(input_item_t *p_item, bool fetched,
+ void *userdata)
+{
+ PlayerController *me = reinterpret_cast<PlayerController *>(userdata);
+ me->onArtFetchEnded(p_item, fetched);
+}
+
+void PlayerController::onArtFetchEnded(input_item_t *p_item, bool)
+{
+ Q_D(PlayerController);
+
+ vlc_player_locker lock{ d->m_player };
+ bool b_current_item = (p_item == vlc_player_GetCurrentMedia( d->m_player ));
+ /* No input will signal the cover art to update,
+ * let's do it ourself */
+ if ( b_current_item )
+ d->UpdateArt( p_item );
+ else
+ emit artChanged( p_item );
+}
+
const QString PlayerController::decodeArtURL( input_item_t *p_item )
{
assert( p_item );
diff --git a/modules/gui/qt/components/player_controller.hpp b/modules/gui/qt/components/player_controller.hpp
index cdf7c8129d..2b20bcab20 100644
--- a/modules/gui/qt/components/player_controller.hpp
+++ b/modules/gui/qt/components/player_controller.hpp
@@ -411,6 +411,11 @@ private:
Q_DECLARE_PRIVATE(PlayerController)
QScopedPointer<PlayerControllerPrivate> d_ptr;
QSignalMapper *menusAudioMapper; //used by VLCMenuBar
+
+ /* updateArt gui request */
+ input_fetcher_callbacks_t input_fetcher_cbs;
+ static void onArtFetchEnded_callback(input_item_t *, bool fetched, void *userdata);
+ void onArtFetchEnded(input_item_t *, bool fetched);
};
#endif
More information about the vlc-commits
mailing list