[vlc-commits] commit: lua_input: grab the input lock only one time when reading the metas (do not lock/ unlock for each meta). ( Rémi Duraffort )
git at videolan.org
git at videolan.org
Wed Oct 6 19:34:56 CEST 2010
vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Wed Oct 6 19:33:45 2010 +0200| [e2bf328095ae842c0d03f7aaee559e8757dbb976] | committer: Rémi Duraffort
lua_input: grab the input lock only one time when reading the metas (do not lock/unlock for each meta).
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e2bf328095ae842c0d03f7aaee559e8757dbb976
---
modules/misc/lua/libs/input.c | 58 +++++++++++++++++++++-------------------
1 files changed, 30 insertions(+), 28 deletions(-)
diff --git a/modules/misc/lua/libs/input.c b/modules/misc/lua/libs/input.c
index 1f38301..60211fd 100644
--- a/modules/misc/lua/libs/input.c
+++ b/modules/misc/lua/libs/input.c
@@ -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]);
More information about the vlc-commits
mailing list