Commits on Source (28)
-
1b1a5e76
-
dee87f25
-
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
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"); ```cace21e2 -
162a474d
-
some models like the groupModel can contain heterogeneous MLItem
b8777f8b -
b1a42541
-
d3bf296f
-
e84a9ae0
-
21bc527e
-
c993641c
-
4cf2548b
-
9c081191
-
798597a0
-
b23b3c36
-
this allows not depending on vlc_medialibrary_t being present in MLBase
16d6631c -
7756812d
-
3f2fc9f4
-
af0f3e36
-
7b46cb34
-
4e4fe025
-
cache may have been invalidated before calling this function
a1bb320d -
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.
6fa56873 -
bfd9e6a2
-
0e3152c4
-
fddf52d5
-
this was here to mimic NetworkMediaModel::getItemsForIndexes, but it's never called
824cfae0 -
8b7d73d4
-
9958d3db
Showing
- modules/gui/qt/Makefile.am 6 additions, 3 deletionsmodules/gui/qt/Makefile.am
- modules/gui/qt/dialogs/bookmarks/bookmarks.cpp 11 additions, 11 deletionsmodules/gui/qt/dialogs/bookmarks/bookmarks.cpp
- modules/gui/qt/dialogs/bookmarks/bookmarks.hpp 2 additions, 3 deletionsmodules/gui/qt/dialogs/bookmarks/bookmarks.hpp
- modules/gui/qt/dialogs/playlists/playlists.cpp 2 additions, 5 deletionsmodules/gui/qt/dialogs/playlists/playlists.cpp
- modules/gui/qt/maininterface/mainctx.cpp 4 additions, 1 deletionmodules/gui/qt/maininterface/mainctx.cpp
- modules/gui/qt/medialibrary/medialib.cpp 315 additions, 101 deletionsmodules/gui/qt/medialibrary/medialib.cpp
- modules/gui/qt/medialibrary/medialib.hpp 201 additions, 7 deletionsmodules/gui/qt/medialibrary/medialib.hpp
- modules/gui/qt/medialibrary/mlalbum.cpp 1 addition, 3 deletionsmodules/gui/qt/medialibrary/mlalbum.cpp
- modules/gui/qt/medialibrary/mlalbum.hpp 1 addition, 3 deletionsmodules/gui/qt/medialibrary/mlalbum.hpp
- modules/gui/qt/medialibrary/mlalbummodel.cpp 7 additions, 12 deletionsmodules/gui/qt/medialibrary/mlalbummodel.cpp
- modules/gui/qt/medialibrary/mlalbummodel.hpp 2 additions, 3 deletionsmodules/gui/qt/medialibrary/mlalbummodel.hpp
- modules/gui/qt/medialibrary/mlalbumtrackmodel.cpp 7 additions, 7 deletionsmodules/gui/qt/medialibrary/mlalbumtrackmodel.cpp
- modules/gui/qt/medialibrary/mlalbumtrackmodel.hpp 2 additions, 2 deletionsmodules/gui/qt/medialibrary/mlalbumtrackmodel.hpp
- modules/gui/qt/medialibrary/mlartistmodel.cpp 6 additions, 11 deletionsmodules/gui/qt/medialibrary/mlartistmodel.cpp
- modules/gui/qt/medialibrary/mlartistmodel.hpp 2 additions, 3 deletionsmodules/gui/qt/medialibrary/mlartistmodel.hpp
- modules/gui/qt/medialibrary/mlbasemodel.cpp 84 additions, 164 deletionsmodules/gui/qt/medialibrary/mlbasemodel.cpp
- modules/gui/qt/medialibrary/mlbasemodel.hpp 6 additions, 16 deletionsmodules/gui/qt/medialibrary/mlbasemodel.hpp
- modules/gui/qt/medialibrary/mlbookmarkmodel.cpp 215 additions, 83 deletionsmodules/gui/qt/medialibrary/mlbookmarkmodel.cpp
- modules/gui/qt/medialibrary/mlbookmarkmodel.hpp 23 additions, 21 deletionsmodules/gui/qt/medialibrary/mlbookmarkmodel.hpp
- modules/gui/qt/medialibrary/mlevent.hpp 38 additions, 0 deletionsmodules/gui/qt/medialibrary/mlevent.hpp