[vlc-commits] [Git][videolan/vlc][master] medialib: acquire priority access

Romain Vimont gitlab at videolan.org
Wed Jun 9 07:16:47 UTC 2021



Romain Vimont pushed to branch master at VideoLAN / VLC


Commits:
7ef4e1ef by Romain Vimont at 2021-06-09T06:38:22+00:00
medialib: acquire priority access

During indexation, the medialibrary executes a lot of write SQL queries
from a background thread. As a consequence, requests initiated by VLC to
retrieve data to show in the UI are excessively delayed (see [1]).

These requests are not executed on the UI thread anymore (since [2]),
but it is still not acceptable to wait tens of seconds just to display
local data.

Therefore, a new priority access mechanism has been implemented in
medialibrary ([3]). Acquire this priority access for all Get and List
requests initiated from VLC.

[1]: https://code.videolan.org/videolan/vlc/-/issues/22687#note_259820
[2]: https://mailman.videolan.org/pipermail/vlc-devel/2020-November/140488.html
[3]: https://code.videolan.org/videolan/medialibrary/-/merge_requests/375

- - - - -


2 changed files:

- modules/misc/medialibrary/medialibrary.cpp
- modules/misc/medialibrary/medialibrary.h


Changes:

=====================================
modules/misc/medialibrary/medialibrary.cpp
=====================================
@@ -687,6 +687,8 @@ int MediaLibrary::List( int listQuery, const vlc_ml_query_params_t* params, va_l
     if ( Init() == false )
         return VLC_EGENERIC;
 
+    auto priorityAccess = m_ml->acquirePriorityAccess();
+
     medialibrary::QueryParameters p{};
     medialibrary::QueryParameters* paramsPtr = nullptr;
     uint32_t nbItems = 0;
@@ -1073,6 +1075,8 @@ void* MediaLibrary::Get( int query, va_list args )
     if ( Init() == false )
         return nullptr;
 
+    auto priorityAccess = m_ml->acquirePriorityAccess();
+
     switch ( query )
     {
         case VLC_ML_GET_MEDIA:
@@ -1929,6 +1933,11 @@ int MediaLibrary::listMedia( int listQuery, const medialibrary::QueryParameters
     }
 }
 
+medialibrary::PriorityAccess MediaLibrary::acquirePriorityAccess()
+{
+    return m_ml->acquirePriorityAccess();
+}
+
 static void* Get( vlc_medialibrary_module_t* module, int query, va_list args )
 {
     auto ml = static_cast<MediaLibrary*>( module->p_sys );


=====================================
modules/misc/medialibrary/medialibrary.h
=====================================
@@ -177,6 +177,8 @@ private:
     int listMedia( int listQuery, const medialibrary::QueryParameters* paramsPtr,
                    const char* pattern, uint32_t nbItems, uint32_t offset, va_list args );
 
+    medialibrary::PriorityAccess acquirePriorityAccess();
+
     static medialibrary::IMedia::MetadataType metadataType( int meta );
     static medialibrary::SortingCriteria sortingCriteria( int sort );
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/7ef4e1effe76ef9b33db0ca8f740c1b93cc6c8d9

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/7ef4e1effe76ef9b33db0ca8f740c1b93cc6c8d9
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list