[vlc-devel] [PATCH 3/3] medialib: factorise history retrieval calls
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Wed Dec 9 17:30:34 CET 2020
On Wed, Dec 9, 2020, at 12:52 PM, Pierre Lamot wrote:
> ---
> modules/misc/medialibrary/medialib.cpp | 63 +++++++++++---------------
> 1 file changed, 26 insertions(+), 37 deletions(-)
>
> diff --git a/modules/misc/medialibrary/medialib.cpp
> b/modules/misc/medialibrary/medialib.cpp
> index 3cd342f833..2db89a39cc 100644
> --- a/modules/misc/medialibrary/medialib.cpp
> +++ b/modules/misc/medialibrary/medialib.cpp
> @@ -861,69 +861,58 @@ int MediaLibrary::List( int listQuery, const
> vlc_ml_query_params_t* params, va_l
> case VLC_ML_LIST_PLAYLISTS:
> case VLC_ML_COUNT_PLAYLISTS:
> return listPlaylist( listQuery, paramsPtr, psz_pattern,
> nbItems, offset, args );
> - case VLC_ML_LIST_HISTORY:
> case VLC_ML_COUNT_HISTORY:
> + case VLC_ML_LIST_HISTORY:
> + case VLC_ML_COUNT_HISTORY_BY_TYPE:
> + case VLC_ML_LIST_HISTORY_BY_TYPE:
> + case VLC_ML_COUNT_STREAM_HISTORY:
> + case VLC_ML_LIST_STREAM_HISTORY:
> {
> - auto query = m_ml->history();
> - if ( query == nullptr )
> - return VLC_EGENERIC;
> + medialibrary::Query<medialibrary::IMedia> query;
>
> 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;
> + case VLC_ML_LIST_HISTORY:
> + query = m_ml->history();
> + break;
> + case VLC_ML_COUNT_HISTORY_BY_TYPE:
> + case VLC_ML_LIST_HISTORY_BY_TYPE:
> + {
> + auto type = va_arg(args, int);
> + query =
> m_ml->history(static_cast<medialibrary::IMedia::Type>( type ));
> + break;
> + }
> + case VLC_ML_COUNT_STREAM_HISTORY:
> + case VLC_ML_LIST_STREAM_HISTORY:
> + query = m_ml->streamHistory();
> + break;
> default:
> vlc_assert_unreachable();
> }
> - }
> - case VLC_ML_COUNT_HISTORY_BY_TYPE:
> - case VLC_ML_LIST_HISTORY_BY_TYPE:
> - {
> - auto type = va_arg(args, int);
> - auto query =
> m_ml->history(static_cast<medialibrary::IMedia::Type>( type ));
> +
> if ( query == nullptr )
> return VLC_EGENERIC;
>
> switch ( listQuery )
> {
> + case VLC_ML_LIST_HISTORY:
> case VLC_ML_LIST_HISTORY_BY_TYPE:
> + case VLC_ML_LIST_STREAM_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:
> case VLC_ML_COUNT_HISTORY_BY_TYPE:
> + case VLC_ML_COUNT_STREAM_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:
> - {
> - auto query = m_ml->streamHistory();
> - if ( query == nullptr )
> - return VLC_EGENERIC;
> - switch ( listQuery )
> - {
> - case VLC_ML_LIST_STREAM_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_STREAM_HISTORY:
> - *va_arg( args, size_t* ) = query->count();
> - return VLC_SUCCESS;
> - default:
> - vlc_assert_unreachable();
> - }
> - }
> +
> }
> return VLC_SUCCESS;
> }
> --
> 2.25.1
>
Set LGTM
--
Hugo Beauzée-Luyssen
hugo at beauzee.fr
More information about the vlc-devel
mailing list