[vlc-devel] [PATCH 1/3] medialibrary: rename vlc_ml_entry_point_t to vlc_ml_folder_t

Alaric Senat dev.asenat at posteo.net
Mon Mar 8 13:34:58 UTC 2021


This better reflects the medialibrary internals while also allowing more
flexible medialibrary folder listing as vlc_ml_folder_t is now available
through a more generic name.
---
 include/vlc_media_library.h                   | 34 +++++++++++--------
 .../gui/macosx/library/VLCLibraryDataTypes.h  |  2 +-
 .../gui/macosx/library/VLCLibraryDataTypes.m  |  2 +-
 modules/gui/macosx/library/VLCLibraryModel.m  |  4 +--
 .../gui/qt/medialibrary/mlfoldersmodel.cpp    | 10 +++---
 .../gui/qt/medialibrary/mlfoldersmodel.hpp    |  2 +-
 modules/misc/medialibrary/entities.cpp        |  5 +--
 modules/misc/medialibrary/medialibrary.cpp    |  7 ++--
 modules/misc/medialibrary/medialibrary.h      |  2 +-
 src/libvlccore.sym                            |  3 +-
 src/misc/medialibrary.c                       | 13 +++++--
 11 files changed, 50 insertions(+), 34 deletions(-)

diff --git a/include/vlc_media_library.h b/include/vlc_media_library.h
index ab8bcf14d8..aa995b1deb 100644
--- a/include/vlc_media_library.h
+++ b/include/vlc_media_library.h
@@ -302,18 +302,19 @@ typedef struct vlc_ml_playlist_list_t
     vlc_ml_playlist_t p_items[];
 } vlc_ml_playlist_list_t;
 
-typedef struct vlc_ml_entry_point_t
+typedef struct vlc_ml_folder_t
 {
-    char* psz_mrl; /**< This entrypoint's MRL. Will be NULL if b_present is false */
-    bool b_present; /**< The presence state for this entrypoint. */
-    bool b_banned; /**< Will be true if the user required this entrypoint to be excluded */
-} vlc_ml_entry_point_t;
+    int64_t i_id; /**< This folder's MRL. Will be NULL if b_present is false */
+    char* psz_mrl; /**< This folder's MRL. Will be NULL if b_present is false */
+    bool b_present; /**< The presence state for this folder. */
+    bool b_banned; /**< Will be true if the user required this folder to be excluded */
+} vlc_ml_folder_t;
 
-typedef struct vlc_ml_entry_point_list_t
+typedef struct vlc_ml_folder_list_t
 {
     size_t i_nb_items;
-    vlc_ml_entry_point_t p_items[];
-} vlc_ml_entry_point_list_t;
+    vlc_ml_folder_t p_items[];
+} vlc_ml_folder_list_t;
 
 typedef struct vlc_ml_bookmark_t
 {
@@ -464,8 +465,8 @@ enum vlc_ml_control
     VLC_ML_REMOVE_FOLDER,           /**< arg1: mrl (const char*)  res: can't fail */
     VLC_ML_BAN_FOLDER,              /**< arg1: mrl (const char*)  res: can't fail */
     VLC_ML_UNBAN_FOLDER,            /**< arg1: mrl (const char*)  res: can't fail */
-    VLC_ML_LIST_FOLDERS,            /**< arg1: entrypoints (vlc_ml_entry_point_list_t**); res: can fail */
-    VLC_ML_LIST_BANNED_FOLDERS,     /**< arg1: entrypoints (vlc_ml_entry_point_list_t**); res: can fail */
+    VLC_ML_LIST_FOLDERS,            /**< arg1: entrypoints (vlc_ml_folder_list_t**); res: can fail */
+    VLC_ML_LIST_BANNED_FOLDERS,     /**< arg1: entrypoints (vlc_ml_folder_list_t**); res: can fail */
     VLC_ML_IS_INDEXED,              /**< arg1: mrl (const char*) arg2 (out): bool*;       res: can fail */
     /**
      * Reload a specific folder, or all.
@@ -857,6 +858,7 @@ VLC_API void vlc_ml_genre_release( vlc_ml_genre_t* p_genre );
 VLC_API void vlc_ml_media_release( vlc_ml_media_t* p_media );
 VLC_API void vlc_ml_album_release( vlc_ml_album_t* p_album );
 VLC_API void vlc_ml_playlist_release( vlc_ml_playlist_t* p_playlist );
+VLC_API void vlc_ml_folder_release( vlc_ml_folder_t* p_folder );
 
 VLC_API void vlc_ml_label_list_release( vlc_ml_label_list_t* p_list );
 VLC_API void vlc_ml_file_list_release( vlc_ml_file_list_t* p_list );
@@ -866,7 +868,7 @@ VLC_API void vlc_ml_album_list_release( vlc_ml_album_list_t* p_list );
 VLC_API void vlc_ml_show_list_release( vlc_ml_show_list_t* p_list );
 VLC_API void vlc_ml_genre_list_release( vlc_ml_genre_list_t* p_list );
 VLC_API void vlc_ml_playlist_list_release( vlc_ml_playlist_list_t* p_list );
-VLC_API void vlc_ml_entry_point_list_release( vlc_ml_entry_point_list_t* p_list );
+VLC_API void vlc_ml_folder_list_release( vlc_ml_folder_list_t* p_list );
 VLC_API void vlc_ml_playback_states_all_release( vlc_ml_playback_states_all* prefs );
 VLC_API void vlc_ml_bookmark_release( vlc_ml_bookmark_t* p_bookmark );
 VLC_API void vlc_ml_bookmark_list_release( vlc_ml_bookmark_list_t* p_list );
@@ -903,13 +905,13 @@ static inline int vlc_ml_unban_folder( vlc_medialibrary_t* p_ml, const char* psz
 }
 
 static inline int vlc_ml_list_folder( vlc_medialibrary_t* p_ml,
-                                      vlc_ml_entry_point_list_t** pp_entrypoints )
+                                      vlc_ml_folder_list_t** pp_entrypoints )
 {
     return vlc_ml_control( p_ml, VLC_ML_LIST_FOLDERS, pp_entrypoints );
 }
 
 static inline int vlc_ml_list_banned_folder( vlc_medialibrary_t* p_ml,
-                                             vlc_ml_entry_point_list_t** pp_entrypoints )
+                                             vlc_ml_folder_list_t** pp_entrypoints )
 {
     return vlc_ml_control( p_ml, VLC_ML_LIST_BANNED_FOLDERS, pp_entrypoints );
 }
@@ -1567,6 +1569,7 @@ static inline size_t vlc_ml_count_playlist_media( vlc_medialibrary_t* p_ml, cons
     vlc_ml_album_t*: vlc_ml_album_release, \
     vlc_ml_genre_t*: vlc_ml_genre_release, \
     vlc_ml_media_t*: vlc_ml_media_release, \
+    vlc_ml_folder_t*: vlc_ml_folder_release, \
     vlc_ml_playlist_t*: vlc_ml_playlist_release, \
     vlc_ml_label_list_t*: vlc_ml_label_list_release, \
     vlc_ml_file_list_t*: vlc_ml_file_list_release, \
@@ -1576,7 +1579,7 @@ static inline size_t vlc_ml_count_playlist_media( vlc_medialibrary_t* p_ml, cons
     vlc_ml_show_list_t*: vlc_ml_show_list_release, \
     vlc_ml_genre_list_t*: vlc_ml_genre_list_release, \
     vlc_ml_playlist_list_t*: vlc_ml_playlist_list_release, \
-    vlc_ml_entry_point_list_t*: vlc_ml_entry_point_list_release, \
+    vlc_ml_folder_list_t*: vlc_ml_folder_list_release, \
     vlc_ml_playback_states_all*: vlc_ml_playback_states_all_release, \
     vlc_ml_bookmark_t*: vlc_ml_bookmark_release, \
     vlc_ml_bookmark_list_t*: vlc_ml_bookmark_list_release \
@@ -1587,6 +1590,7 @@ static inline void vlc_ml_release( vlc_ml_artist_t* artist ) { vlc_ml_artist_rel
 static inline void vlc_ml_release( vlc_ml_album_t* album ) { vlc_ml_album_release( album ); }
 static inline void vlc_ml_release( vlc_ml_genre_t* genre ) { vlc_ml_genre_release( genre ); }
 static inline void vlc_ml_release( vlc_ml_media_t* media ) { vlc_ml_media_release( media ); }
+static inline void vlc_ml_release( vlc_ml_folder_t* folder ) { vlc_ml_folder_release( folder ); }
 static inline void vlc_ml_release( vlc_ml_playlist_t* playlist ) { vlc_ml_playlist_release( playlist ); }
 static inline void vlc_ml_release( vlc_ml_label_list_t* list ) { vlc_ml_label_list_release( list ); }
 static inline void vlc_ml_release( vlc_ml_file_list_t* list ) { vlc_ml_file_list_release( list ); }
@@ -1596,7 +1600,7 @@ static inline void vlc_ml_release( vlc_ml_album_list_t* list ) { vlc_ml_album_li
 static inline void vlc_ml_release( vlc_ml_show_list_t* list ) { vlc_ml_show_list_release( list ); }
 static inline void vlc_ml_release( vlc_ml_genre_list_t* list ) { vlc_ml_genre_list_release( list ); }
 static inline void vlc_ml_release( vlc_ml_playlist_list_t* list ) { vlc_ml_playlist_list_release( list ); }
-static inline void vlc_ml_release( vlc_ml_entry_point_list_t* list ) { vlc_ml_entry_point_list_release( list ); }
+static inline void vlc_ml_release( vlc_ml_folder_list_t* list ) { vlc_ml_folder_list_release( list ); }
 static inline void vlc_ml_release( vlc_ml_playback_states_all* prefs ) { vlc_ml_playback_states_all_release( prefs ); }
 static inline void vlc_ml_release( vlc_ml_bookmark_t* bookmark ) { vlc_ml_bookmark_release( bookmark ); }
 static inline void vlc_ml_release( vlc_ml_bookmark_list_t* list ) { vlc_ml_bookmark_list_release( list ); }
diff --git a/modules/gui/macosx/library/VLCLibraryDataTypes.h b/modules/gui/macosx/library/VLCLibraryDataTypes.h
index b61dfde6a6..ad0af0c2ea 100644
--- a/modules/gui/macosx/library/VLCLibraryDataTypes.h
+++ b/modules/gui/macosx/library/VLCLibraryDataTypes.h
@@ -207,7 +207,7 @@ extern const long long int VLCMediaLibraryMediaItemDurationDenominator;
 
 @interface VLCMediaLibraryEntryPoint : NSObject
 
-- (instancetype)initWithEntryPoint:(struct vlc_ml_entry_point_t *)p_entryPoint;
+- (instancetype)initWithEntryPoint:(struct vlc_ml_folder_t *)p_entryPoint;
 
 @property (readonly) NSString *MRL;
 @property (readonly) NSString *decodedMRL;
diff --git a/modules/gui/macosx/library/VLCLibraryDataTypes.m b/modules/gui/macosx/library/VLCLibraryDataTypes.m
index b9c0520050..0ed3489e2f 100644
--- a/modules/gui/macosx/library/VLCLibraryDataTypes.m
+++ b/modules/gui/macosx/library/VLCLibraryDataTypes.m
@@ -763,7 +763,7 @@ NSString *VLCMediaLibraryMediaItemLibraryID = @"VLCMediaLibraryMediaItemLibraryI
 
 @implementation VLCMediaLibraryEntryPoint
 
-- (instancetype)initWithEntryPoint:(struct vlc_ml_entry_point_t *)p_entryPoint
+- (instancetype)initWithEntryPoint:(struct vlc_ml_folder_t *)p_entryPoint
 {
     self = [super init];
     if (self && p_entryPoint != NULL) {
diff --git a/modules/gui/macosx/library/VLCLibraryModel.m b/modules/gui/macosx/library/VLCLibraryModel.m
index d46ec3a6fb..8e797ced85 100644
--- a/modules/gui/macosx/library/VLCLibraryModel.m
+++ b/modules/gui/macosx/library/VLCLibraryModel.m
@@ -364,7 +364,7 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
 
 - (NSArray<VLCMediaLibraryEntryPoint *> *)listOfMonitoredFolders
 {
-    vlc_ml_entry_point_list_t *pp_entrypoints;
+    vlc_ml_folder_list_t *pp_entrypoints;
     int ret = vlc_ml_list_folder(_p_mediaLibrary, &pp_entrypoints);
     if (ret != VLC_SUCCESS) {
         msg_Err(getIntf(), "failed to retrieve list of monitored library folders (%i)", ret);
@@ -379,7 +379,7 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
         }
     }
 
-    vlc_ml_entry_point_list_release(pp_entrypoints);
+    vlc_ml_folder_list_release(pp_entrypoints);
     return [mutableArray copy];
 }
 
diff --git a/modules/gui/qt/medialibrary/mlfoldersmodel.cpp b/modules/gui/qt/medialibrary/mlfoldersmodel.cpp
index 56fcb2fb64..03d49bf2d3 100644
--- a/modules/gui/qt/medialibrary/mlfoldersmodel.cpp
+++ b/modules/gui/qt/medialibrary/mlfoldersmodel.cpp
@@ -29,7 +29,7 @@ MLFoldersBaseModel::MLFoldersBaseModel( QObject *parent )
     connect( this , &MLFoldersBaseModel::onMLEntryPointModified , this , &MLFoldersBaseModel::update );
 }
 
-MLFoldersBaseModel::EntryPoint::EntryPoint( const vlc_ml_entry_point_t& entryPoint)
+MLFoldersBaseModel::EntryPoint::EntryPoint( const vlc_ml_folder_t& entryPoint)
     : mrl(entryPoint.psz_mrl)
     , banned(entryPoint.b_banned)
 {
@@ -118,11 +118,11 @@ std::vector<MLFoldersBaseModel::EntryPoint> MLFoldersModel::entryPoints() const
 {
     std::vector<MLFoldersBaseModel::EntryPoint> r;
 
-    vlc_ml_entry_point_list_t * entrypoints = nullptr;
+    vlc_ml_folder_list_t * entrypoints = nullptr;
     vlc_ml_list_folder( ml() , &entrypoints );
     for ( unsigned int i=0 ; i<entrypoints->i_nb_items ; i++ )
         r.emplace_back( entrypoints->p_items[i] );
-    vlc_ml_release(entrypoints);
+    vlc_ml_release( entrypoints );
 
     return r;
 }
@@ -159,11 +159,11 @@ std::vector<MLFoldersBaseModel::EntryPoint> MLBannedFoldersModel::entryPoints()
 {
     std::vector<MLFoldersBaseModel::EntryPoint> r;
 
-    vlc_ml_entry_point_list_t * entrypoints = nullptr;
+    vlc_ml_folder_list_t * entrypoints = nullptr;
     vlc_ml_list_banned_folder( ml() , &entrypoints );
     for ( unsigned int i=0 ; i<entrypoints->i_nb_items ; i++ )
         r.emplace_back( entrypoints->p_items[i] );
-    vlc_ml_release(entrypoints);
+    vlc_ml_release( entrypoints );
 
     return r;
 }
diff --git a/modules/gui/qt/medialibrary/mlfoldersmodel.hpp b/modules/gui/qt/medialibrary/mlfoldersmodel.hpp
index 941e379f7c..f472c9a684 100644
--- a/modules/gui/qt/medialibrary/mlfoldersmodel.hpp
+++ b/modules/gui/qt/medialibrary/mlfoldersmodel.hpp
@@ -69,7 +69,7 @@ signals:
 protected:
     struct EntryPoint
     {
-        EntryPoint(const vlc_ml_entry_point_t &entryPoint );
+        EntryPoint(const vlc_ml_folder_t &entryPoint );
         QString mrl;
         bool banned;
     };
diff --git a/modules/misc/medialibrary/entities.cpp b/modules/misc/medialibrary/entities.cpp
index 02c106e4e1..a42d1e0727 100644
--- a/modules/misc/medialibrary/entities.cpp
+++ b/modules/misc/medialibrary/entities.cpp
@@ -416,8 +416,10 @@ bool Convert( const medialibrary::IPlaylist* input, vlc_ml_playlist_t& output )
     return true;
 }
 
-bool Convert( const medialibrary::IFolder* input, vlc_ml_entry_point_t& output )
+bool Convert( const medialibrary::IFolder* input, vlc_ml_folder_t& output )
 {
+    output.i_id = input->id();
+    output.b_banned = input->isBanned();
     try
     {
         if ( strdup_helper( input->mrl(), output.psz_mrl ) == false )
@@ -429,7 +431,6 @@ bool Convert( const medialibrary::IFolder* input, vlc_ml_entry_point_t& output )
         output.psz_mrl = nullptr;
         output.b_present = false;
     }
-    output.b_banned = input->isBanned();
     return true;
 }
 
diff --git a/modules/misc/medialibrary/medialibrary.cpp b/modules/misc/medialibrary/medialibrary.cpp
index fb3d158706..fd1ec59cb7 100644
--- a/modules/misc/medialibrary/medialibrary.cpp
+++ b/modules/misc/medialibrary/medialibrary.cpp
@@ -40,6 +40,7 @@
 #include <medialibrary/IShow.h>
 #include <medialibrary/IPlaylist.h>
 #include <medialibrary/IBookmark.h>
+#include <medialibrary/IFolder.h>
 
 #include <sstream>
 #include <initializer_list>
@@ -553,9 +554,9 @@ int MediaLibrary::Control( int query, va_list args )
             auto entryPoints = ( query == VLC_ML_LIST_FOLDERS )
                     ? m_ml->entryPoints()->all()
                     : m_ml->bannedEntryPoints()->all();
-            auto res = ml_convert_list<vlc_ml_entry_point_list_t,
-                                         vlc_ml_entry_point_t>( entryPoints );
-            *(va_arg( args, vlc_ml_entry_point_list_t**) ) = res;
+            auto res = ml_convert_list<vlc_ml_folder_list_t,
+                                         vlc_ml_folder_t>( entryPoints );
+            *(va_arg( args, vlc_ml_folder_list_t**) ) = res;
             break;
         }
         case VLC_ML_IS_INDEXED:
diff --git a/modules/misc/medialibrary/medialibrary.h b/modules/misc/medialibrary/medialibrary.h
index 8ba8d5c108..d4287c7965 100644
--- a/modules/misc/medialibrary/medialibrary.h
+++ b/modules/misc/medialibrary/medialibrary.h
@@ -224,7 +224,7 @@ bool Convert( const medialibrary::IGenre* input, vlc_ml_genre_t& output );
 bool Convert( const medialibrary::IShow* input, vlc_ml_show_t& output );
 bool Convert( const medialibrary::ILabel* input, vlc_ml_label_t& output );
 bool Convert( const medialibrary::IPlaylist* input, vlc_ml_playlist_t& output );
-bool Convert( const medialibrary::IFolder* input, vlc_ml_entry_point_t& output );
+bool Convert( const medialibrary::IFolder* input, vlc_ml_folder_t& output );
 bool Convert( const medialibrary::IBookmark* input, vlc_ml_bookmark_t& output );
 input_item_t* MediaToInputItem( const medialibrary::IMedia* media );
 
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 0c130543e5..1b4f2dfbcc 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -583,6 +583,7 @@ vlc_ml_genre_release
 vlc_ml_media_release
 vlc_ml_album_release
 vlc_ml_playlist_release
+vlc_ml_folder_release
 vlc_ml_label_list_release
 vlc_ml_file_list_release
 vlc_ml_artist_list_release
@@ -591,7 +592,7 @@ vlc_ml_album_list_release
 vlc_ml_show_list_release
 vlc_ml_genre_list_release
 vlc_ml_playlist_list_release
-vlc_ml_entry_point_list_release
+vlc_ml_folder_list_release
 vlc_ml_bookmark_release
 vlc_ml_bookmark_list_release
 vlc_poll_i11e
diff --git a/src/misc/medialibrary.c b/src/misc/medialibrary.c
index 140f055b5f..ad9c10316e 100644
--- a/src/misc/medialibrary.c
+++ b/src/misc/medialibrary.c
@@ -245,7 +245,6 @@ void vlc_ml_playlist_release( vlc_ml_playlist_t* p_playlist )
     free( p_playlist );
 }
 
-/* Lists release */
 
 void vlc_ml_media_release( vlc_ml_media_t* p_media )
 {
@@ -255,6 +254,16 @@ void vlc_ml_media_release( vlc_ml_media_t* p_media )
     free( p_media );
 }
 
+void vlc_ml_folder_release( vlc_ml_folder_t* p_folder )
+{
+    if ( p_folder == NULL )
+        return;
+    free( p_folder->psz_mrl );
+    free( p_folder );
+}
+
+/* Lists release */
+
 void vlc_ml_label_list_release( vlc_ml_label_list_t* p_list )
 {
     if ( p_list == NULL )
@@ -328,7 +337,7 @@ void vlc_ml_playlist_list_release( vlc_ml_playlist_list_t* p_list )
     free( p_list );
 }
 
-void vlc_ml_entry_point_list_release( vlc_ml_entry_point_list_t* p_list )
+void vlc_ml_folder_list_release( vlc_ml_folder_list_t* p_list )
 {
     if ( p_list == NULL )
         return;
-- 
2.29.2



More information about the vlc-devel mailing list