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,19 +113,23 @@ 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 )
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" );
......@@ -146,9 +150,7 @@ static int vlclua_input_metas_internal( lua_State *L, input_item_t *p_item )
#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