medialibrary: Use va_list for Get parameters

Since we soon will need something else than int64
This commit is contained in:
Hugo Beauzée-Luyssen 2019-03-21 15:52:15 +01:00
parent 303cbe6c89
commit 980aa49905
4 changed files with 20 additions and 9 deletions

View File

@ -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, ... );

View File

@ -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,

View File

@ -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 );

View File

@ -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, ... )