Commit e2bf3280 authored by Rémi Duraffort's avatar Rémi Duraffort

lua_input: grab the input lock only one time when reading the metas (do not...

lua_input: grab the input lock only one time when reading the metas (do not lock/unlock for each meta).
parent 7a725e89
......@@ -113,42 +113,44 @@ static int vlclua_input_metas_internal( lua_State *L, input_item_t *p_item )
}
lua_newtable( L );
char *psz_meta;
char *psz_name;
const char *psz_meta;
psz_meta = input_item_GetName( p_item );
lua_pushstring( L, psz_meta );
psz_name = input_item_GetName( p_item );
lua_pushstring( L, psz_name );
lua_setfield( L, -2, "filename" );
free( psz_meta );
free( psz_name );
#define PUSH_META( n, m ) \
psz_meta = input_item_GetMeta( p_item, vlc_meta_ ## n ); \
psz_meta = vlc_meta_Get( p_item->p_meta, vlc_meta_ ## n ); \
lua_pushstring( L, psz_meta ); \
lua_setfield( L, -2, m ); \
free( psz_meta )
PUSH_META( Title, "title" );
PUSH_META( Artist, "artist" );
PUSH_META( Genre, "genre" );
PUSH_META( Copyright, "copyright" );
PUSH_META( Album, "album" );
PUSH_META( TrackNumber, "track_number" );
PUSH_META( Description, "description" );
PUSH_META( Rating, "rating" );
PUSH_META( Date, "date" );
PUSH_META( Setting, "setting" );
PUSH_META( URL, "url" );
PUSH_META( Language, "language" );
PUSH_META( NowPlaying, "now_playing" );
PUSH_META( Publisher, "publisher" );
PUSH_META( EncodedBy, "encoded_by" );
PUSH_META( ArtworkURL, "artwork_url" );
PUSH_META( TrackID, "track_id" );
lua_setfield( L, -2, m )
vlc_mutex_lock(&p_item->lock);
if (p_item->p_meta)
{
PUSH_META( Title, "title" );
PUSH_META( Artist, "artist" );
PUSH_META( Genre, "genre" );
PUSH_META( Copyright, "copyright" );
PUSH_META( Album, "album" );
PUSH_META( TrackNumber, "track_number" );
PUSH_META( Description, "description" );
PUSH_META( Rating, "rating" );
PUSH_META( Date, "date" );
PUSH_META( Setting, "setting" );
PUSH_META( URL, "url" );
PUSH_META( Language, "language" );
PUSH_META( NowPlaying, "now_playing" );
PUSH_META( Publisher, "publisher" );
PUSH_META( EncodedBy, "encoded_by" );
PUSH_META( ArtworkURL, "artwork_url" );
PUSH_META( TrackID, "track_id" );
#undef PUSH_META
vlc_mutex_lock(&p_item->lock);
if (p_item->p_meta) {
char ** names = vlc_meta_CopyExtraNames(p_item->p_meta);
char **names = vlc_meta_CopyExtraNames(p_item->p_meta);
for(int i = 0; names[i]; i++)
{
const char *meta = vlc_meta_GetExtra(p_item->p_meta, names[i]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment