vlc | branch: master | Pierre Lamot <[email protected]> | Wed Oct 14 15:42:50 2020 +0200| [d91ce0b082efbf2839965b3fbf2e3d8c5317bf37] | committer: Pierre Lamot
medialib: add function to get history count > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d91ce0b082efbf2839965b3fbf2e3d8c5317bf37 --- include/vlc_media_library.h | 11 +++++++++++ modules/misc/medialibrary/medialib.cpp | 19 +++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/include/vlc_media_library.h b/include/vlc_media_library.h index 39d41efac1..fbc8ff8676 100644 --- a/include/vlc_media_library.h +++ b/include/vlc_media_library.h @@ -399,6 +399,7 @@ enum vlc_ml_list_queries VLC_ML_LIST_PLAYLISTS, /**< arg1 (out): vlc_ml_playlist_list_t** */ VLC_ML_COUNT_PLAYLISTS, /**< arg1 (out): size_t* */ VLC_ML_LIST_HISTORY, /**< arg1 (out): vlc_ml_media_list_t** */ + VLC_ML_COUNT_HISTORY, /**< arg1 (out): size_t* */ VLC_ML_LIST_STREAM_HISTORY, /**< arg1 (out): vlc_ml_media_list_t** */ VLC_ML_COUNT_STREAM_HISTORY, /**< arg1 (out): size_t* */ @@ -1428,6 +1429,16 @@ static inline vlc_ml_media_list_t* vlc_ml_list_history( vlc_medialibrary_t* p_ml return res; } +static inline size_t vlc_ml_count_history( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params ) +{ + vlc_assert( p_ml != NULL ); + size_t count; + if ( vlc_ml_list( p_ml, VLC_ML_COUNT_HISTORY, params, &count ) != VLC_SUCCESS ) + return 0; + return count; +} + + static inline vlc_ml_media_list_t* vlc_ml_list_stream_history( vlc_medialibrary_t* p_ml, const vlc_ml_query_params_t* params ) { vlc_assert( p_ml != NULL ); diff --git a/modules/misc/medialibrary/medialib.cpp b/modules/misc/medialibrary/medialib.cpp index 056f6be4a0..5f3c2fc493 100644 --- a/modules/misc/medialibrary/medialib.cpp +++ b/modules/misc/medialibrary/medialib.cpp @@ -862,14 +862,25 @@ int MediaLibrary::List( int listQuery, const vlc_ml_query_params_t* params, va_l case VLC_ML_COUNT_PLAYLISTS: return listPlaylist( listQuery, paramsPtr, psz_pattern, nbItems, offset, args ); case VLC_ML_LIST_HISTORY: + case VLC_ML_COUNT_HISTORY: { auto query = m_ml->history(); if ( query == nullptr ) return VLC_EGENERIC; - *va_arg( args, vlc_ml_media_list_t**) = - ml_convert_list<vlc_ml_media_list_t, vlc_ml_media_t>( - query->items( nbItems, offset ) ); - return VLC_SUCCESS; + + switch ( listQuery ) + { + case VLC_ML_LIST_HISTORY: + *va_arg( args, vlc_ml_media_list_t**) = + ml_convert_list<vlc_ml_media_list_t, vlc_ml_media_t>( + query->items( nbItems, offset ) ); + return VLC_SUCCESS; + case VLC_ML_COUNT_HISTORY: + *va_arg( args, size_t* ) = query->count(); + return VLC_SUCCESS; + default: + vlc_assert_unreachable(); + } } case VLC_ML_LIST_STREAM_HISTORY: case VLC_ML_COUNT_STREAM_HISTORY: _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
