[vlc-devel] [PATCH 6/7] medialib: Only start the media library when required

Hugo Beauzée-Luyssen hugo at beauzee.fr
Thu Dec 12 15:10:55 CET 2019


---
 modules/misc/medialibrary/medialib.cpp | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/modules/misc/medialibrary/medialib.cpp b/modules/misc/medialibrary/medialib.cpp
index e71b843570..09940d8e55 100644
--- a/modules/misc/medialibrary/medialib.cpp
+++ b/modules/misc/medialibrary/medialib.cpp
@@ -460,8 +460,25 @@ bool MediaLibrary::Start()
 
 int MediaLibrary::Control( int query, va_list args )
 {
-    if ( Start() == false )
-        return VLC_EGENERIC;
+    switch ( query )
+    {
+        case VLC_ML_ADD_FOLDER:
+        case VLC_ML_REMOVE_FOLDER:
+        case VLC_ML_BAN_FOLDER:
+        case VLC_ML_UNBAN_FOLDER:
+        case VLC_ML_RELOAD_FOLDER:
+        case VLC_ML_RESUME_BACKGROUND:
+        case VLC_ML_MEDIA_GENERATE_THUMBNAIL:
+        {
+            /* These operations require the media library to be started
+             * ie. that the background threads are started */
+            if ( Start() == false )
+                return VLC_EGENERIC;
+            break;
+        }
+        default:
+            break;
+    }
 
     switch ( query )
     {
-- 
2.20.1



More information about the vlc-devel mailing list