[vlc-commits] medialibrary: Use va_list for Get parameters
Hugo Beauzée-Luyssen
git at videolan.org
Wed Jun 26 18:25:39 CEST 2019
vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Thu Mar 21 15:52:15 2019 +0100| [980aa49905c70c7181948b8d70fa253d90f55f30] | committer: Hugo Beauzée-Luyssen
medialibrary: Use va_list for Get parameters
Since we soon will need something else than int64
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=980aa49905c70c7181948b8d70fa253d90f55f30
---
include/vlc_media_library.h | 6 +++---
modules/misc/medialibrary/medialib.cpp | 13 ++++++++++---
modules/misc/medialibrary/medialibrary.h | 2 +-
src/misc/medialibrary.c | 8 ++++++--
4 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/include/vlc_media_library.h b/include/vlc_media_library.h
index 1abbf5049d..b9e7c96c24 100644
--- a/include/vlc_media_library.h
+++ b/include/vlc_media_library.h
@@ -688,13 +688,13 @@ struct vlc_medialibrary_module_t
const vlc_ml_query_params_t* p_params, va_list args );
/**
- * Get a specific entity by its id.
+ * Get a specific entity by its id or another unique value
*
* \return The required entity, or a NULL pointer if couldn't be found.
*
* Refer to the list of queries for the specific return type
*/
- void* (*pf_get)( struct vlc_medialibrary_module_t* p_ml, int i_query, int64_t i_id );
+ void* (*pf_get)( struct vlc_medialibrary_module_t* p_ml, int i_query, va_list args );
const vlc_medialibrary_callbacks_t* cbs;
};
@@ -705,7 +705,7 @@ void libvlc_MlRelease( vlc_medialibrary_t* p_ml );
VLC_API vlc_medialibrary_t* vlc_ml_instance_get( vlc_object_t* p_obj ) VLC_USED;
#define vlc_ml_instance_get(x) vlc_ml_instance_get( VLC_OBJECT(x) )
-VLC_API void* vlc_ml_get( vlc_medialibrary_t* p_ml, int i_query, int64_t i_id ) VLC_USED;
+VLC_API void* vlc_ml_get( vlc_medialibrary_t* p_ml, int i_query, ... ) VLC_USED;
VLC_API int vlc_ml_control( vlc_medialibrary_t* p_ml, int i_query, ... ) VLC_USED;
VLC_API int vlc_ml_list( vlc_medialibrary_t* p_ml, int i_query,
const vlc_ml_query_params_t* p_params, ... );
diff --git a/modules/misc/medialibrary/medialib.cpp b/modules/misc/medialibrary/medialib.cpp
index a66c0e1f09..cc96da7f82 100644
--- a/modules/misc/medialibrary/medialib.cpp
+++ b/modules/misc/medialibrary/medialib.cpp
@@ -762,7 +762,7 @@ int MediaLibrary::List( int listQuery, const vlc_ml_query_params_t* params, va_l
return VLC_SUCCESS;
}
-void* MediaLibrary::Get( int query, int64_t id )
+void* MediaLibrary::Get( int query, va_list args )
{
if ( Start() == false )
return nullptr;
@@ -771,36 +771,43 @@ void* MediaLibrary::Get( int query, int64_t id )
{
case VLC_ML_GET_MEDIA:
{
+ auto id = va_arg( args, int64_t );
auto media = m_ml->media( id );
return CreateAndConvert<vlc_ml_media_t>( media.get() );
}
case VLC_ML_GET_INPUT_ITEM:
{
+ auto id = va_arg( args, int64_t );
auto media = m_ml->media( id );
return MediaToInputItem( media.get() );
}
case VLC_ML_GET_ALBUM:
{
+ auto id = va_arg( args, int64_t );
auto album = m_ml->album( id );
return CreateAndConvert<vlc_ml_album_t>( album.get() );
}
case VLC_ML_GET_ARTIST:
{
+ auto id = va_arg( args, int64_t );
auto artist = m_ml->artist( id );
return CreateAndConvert<vlc_ml_artist_t>( artist.get() );
}
case VLC_ML_GET_GENRE:
{
+ auto id = va_arg( args, int64_t );
auto genre = m_ml->genre( id );
return CreateAndConvert<vlc_ml_genre_t>( genre.get() );
}
case VLC_ML_GET_SHOW:
{
+ auto id = va_arg( args, int64_t );
auto show = m_ml->show( id );
return CreateAndConvert<vlc_ml_show_t>( show.get() );
}
case VLC_ML_GET_PLAYLIST:
{
+ auto id = va_arg( args, int64_t );
auto playlist = m_ml->playlist( id );
return CreateAndConvert<vlc_ml_playlist_t>( playlist.get() );
}
@@ -1332,10 +1339,10 @@ int MediaLibrary::listPlaylist( int listQuery, const medialibrary::QueryParamete
}
}
-static void* Get( vlc_medialibrary_module_t* module, int query, int64_t id )
+static void* Get( vlc_medialibrary_module_t* module, int query, va_list args )
{
auto ml = static_cast<MediaLibrary*>( module->p_sys );
- return ml->Get( query, id );
+ return ml->Get( query, args );
}
static int List( vlc_medialibrary_module_t* module, int query,
diff --git a/modules/misc/medialibrary/medialibrary.h b/modules/misc/medialibrary/medialibrary.h
index ce3462874d..42cda31c35 100644
--- a/modules/misc/medialibrary/medialibrary.h
+++ b/modules/misc/medialibrary/medialibrary.h
@@ -116,7 +116,7 @@ public:
bool Start();
int Control( int query, va_list args );
int List( int query, const vlc_ml_query_params_t* params, va_list args );
- void* Get( int query, int64_t id );
+ void* Get( int query, va_list args );
private:
int controlMedia( int query, va_list args );
diff --git a/src/misc/medialibrary.c b/src/misc/medialibrary.c
index 45c86782d1..436a5b226f 100644
--- a/src/misc/medialibrary.c
+++ b/src/misc/medialibrary.c
@@ -333,10 +333,14 @@ void vlc_ml_entry_point_list_release( vlc_ml_entry_point_list_t* p_list )
free( p_list );
}
-void* vlc_ml_get( vlc_medialibrary_t* p_ml, int i_query, int64_t i_id )
+void* vlc_ml_get( vlc_medialibrary_t* p_ml, int i_query, ... )
{
assert( p_ml != NULL );
- return p_ml->m.pf_get( &p_ml->m, i_query, i_id );
+ va_list args;
+ va_start( args, i_query );
+ void* res = p_ml->m.pf_get( &p_ml->m, i_query, args );
+ va_end( args );
+ return res;
}
int vlc_ml_control( vlc_medialibrary_t* p_ml, int i_query, ... )
More information about the vlc-commits
mailing list