[vlc-commits] [Git][videolan/vlc][master] 28 commits: qt: allow to register ml event callback on MediaLib instance
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Thu Dec 23 19:35:55 UTC 2021
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
1b1a5e76 by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: allow to register ml event callback on MediaLib instance
- - - - -
dee87f25 by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: register to ML events using MediaLib instance
- - - - -
cace21e2 by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: provide runOnMLThread function
this function allows to run lambdas on the ML thread, this should be used to
perform operation that requires to call vlc_ml_xxx functions as vlc_ml_xxx
should *not* be called from the UI thread
obj: this is the instance of the calling QObject, we ensure that this object is
still live when calling the ui callback, if this object gets destroyed the task
is canceled
mlCb: this callback is executed in a background thread (thread pool), it takes
as arguments the instance of the medialibrary, and a context, the context can be
modified to pass data to the UI callback
uiCB: this callback is executed on the Qt thread, it takes as first argument the
id of the tasks, and as second argument the context that was created for the ML
callback
queue: this allow the task to be ran on a specific thread, when this parameter
isn't provided, the task can be scheduled on any thread.
Ctx is the type of context, this context is created by the runner and passed
sequentially to the ML callback then to UI callback, the ML callback may modify
its properties as a way to pass data to the UI callback
:warning: the ml callback **SHOULD NOT** capture the obj object or point to its
properties by reference, as the obj object may potentially be destroyed when the
function is called
the ui callback **MAY** capture the object obj as we will ensure that the object
still exists before calling the callback
the uiCb **MAY NOT** be called if the object obj is released earlier
anything stored int the context Ctx **MUST** auto release when the context is
destroyed
sample usage:
```
//structure used to pass data from the ML thread to the UI thread
struct Ctx {
bool success;
};
m_mediaLib->runOnMLThread<Ctx>(
//reference to the object making the call, this is used to ensure that
//the caller still exists before calling the UI callback
this,
//ML thread, data needed from the caller are passed in the capture of the lambda
//capturing this or any of its member is not allowed here
//the callback have in parametters the ml instance and a context that will be shared with
//the UI callback
[url, indexed](vlc_medialibrary_t* ml, Ctx& ctx)
{
int res;
if ( indexed )
res = vlc_ml_add_folder( ml, qtu( url ) );
else
res = vlc_ml_remove_folder( ml, qtu( url ) );
ctx.success = (res == VLC_SUCCESS);
},
//UI callback, capturing this is allowed, (runOnMLThread will ensure that `this`
//still exists at this point
//the callback has as parametters the request id and the shared context
[this, indexed](quint64, Ctx& ctx){
if (ctx.success)
{
m_indexed = indexed;
emit isIndexedChanged();
}
},
//allow to specify if the task should be run on a specific thread, null (default) will run on any thread
"ML_FOLDER_ADD_QUEUE");
```
- - - - -
162a474d by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: run ml playlist insertion on ML thread
- - - - -
b8777f8b by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: add a findInCache MLBaseModel helper that takes a MLItemId
some models like the groupModel can contain heterogeneous MLItem
- - - - -
b1a42541 by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: use runOnMLThread to generate covers
- - - - -
d3bf296f by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: remove CoverGenerator inheriance from QObject
- - - - -
e84a9ae0 by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: run ML operations in background thread in MLRecentsModel
- - - - -
21bc527e by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: fetch medialib media from url on ML thread
- - - - -
c993641c by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: run ML operations in background thread in MLFolderModel
- - - - -
4cf2548b by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: run ML operations in background thread in NetworkMediaModel
- - - - -
9c081191 by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: run ML operations in background thread in BookmarkModel
- - - - -
798597a0 by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: use modern connection syntax in Bookmark dialog
- - - - -
b23b3c36 by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: remove unused constructors in medialib models
- - - - -
16d6631c by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: use runOnMLThread to count and load data
this allows not depending on vlc_medialibrary_t being present in MLBase
- - - - -
7756812d by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: remove unused QThreadPool in MediaLib
- - - - -
3f2fc9f4 by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: run ML operations in background thread in MLPlaylistListModel
- - - - -
af0f3e36 by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: run ML operations in background thread in MLPlaylistModel
- - - - -
7b46cb34 by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: make MLEvent non-copiable
- - - - -
4e4fe025 by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: add more informations regarding thumbnails in MLEvent
- - - - -
a1bb320d by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: don't assert in MLListCache::find when cache is empty
cache may have been invalidated before calling this function
- - - - -
6fa56873 by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: pass the updated item along with the new data to the thumbnailUpdated cb
Note that models that use vlc_ml_media_generate_thumbnail loose the notification
at this very commit, this will be reinstated in the following commits.
The former form of the signal was a bit inconsistent as the MLVideo item (for
instance) was updating itself (in an unsafe manner) with its own callback but
the model was notified through this mechanism. This could have potentially led
to data inconsistency.
- - - - -
bfd9e6a2 by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: generate video thumbnail in MLXXXVideoModel instead of MLVideo
- - - - -
0e3152c4 by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: generate playlist thumbnail in MLPlaylistModel instead of MLPlaylist
- - - - -
fddf52d5 by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: remove unused medialib reference
- - - - -
824cfae0 by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: remove unused getItemsForIndexes function
this was here to mimic NetworkMediaModel::getItemsForIndexes, but it's never
called
- - - - -
8b7d73d4 by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: remove direct accessor to vlc_medialibrary_t instance
- - - - -
9958d3db by Pierre Lamot at 2021-12-23T19:19:03+00:00
qt: move mlitem function on the ML thread
- - - - -
30 changed files:
- modules/gui/qt/Makefile.am
- modules/gui/qt/dialogs/bookmarks/bookmarks.cpp
- modules/gui/qt/dialogs/bookmarks/bookmarks.hpp
- modules/gui/qt/dialogs/playlists/playlists.cpp
- modules/gui/qt/maininterface/mainctx.cpp
- modules/gui/qt/medialibrary/medialib.cpp
- modules/gui/qt/medialibrary/medialib.hpp
- modules/gui/qt/medialibrary/mlalbum.cpp
- modules/gui/qt/medialibrary/mlalbum.hpp
- modules/gui/qt/medialibrary/mlalbummodel.cpp
- modules/gui/qt/medialibrary/mlalbummodel.hpp
- modules/gui/qt/medialibrary/mlalbumtrackmodel.cpp
- modules/gui/qt/medialibrary/mlalbumtrackmodel.hpp
- modules/gui/qt/medialibrary/mlartistmodel.cpp
- modules/gui/qt/medialibrary/mlartistmodel.hpp
- modules/gui/qt/medialibrary/mlbasemodel.cpp
- modules/gui/qt/medialibrary/mlbasemodel.hpp
- modules/gui/qt/medialibrary/mlbookmarkmodel.cpp
- modules/gui/qt/medialibrary/mlbookmarkmodel.hpp
- modules/gui/qt/medialibrary/mlevent.hpp
- modules/gui/qt/medialibrary/mlfoldersmodel.cpp
- modules/gui/qt/medialibrary/mlfoldersmodel.hpp
- modules/gui/qt/medialibrary/mlgenre.cpp
- modules/gui/qt/medialibrary/mlgenre.hpp
- modules/gui/qt/medialibrary/mlgenremodel.cpp
- modules/gui/qt/medialibrary/mlgenremodel.hpp
- modules/gui/qt/medialibrary/mlgroup.cpp
- modules/gui/qt/medialibrary/mlgroup.hpp
- modules/gui/qt/medialibrary/mlgrouplistmodel.cpp
- modules/gui/qt/medialibrary/mlgrouplistmodel.hpp
The diff was not included because it is too large.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9221f7899116aa062614a77916a05ffe8f7b76b7...9958d3dbda2977b85dd3504851d0cb429035b0ea
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9221f7899116aa062614a77916a05ffe8f7b76b7...9958d3dbda2977b85dd3504851d0cb429035b0ea
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list