[vlc-commits] input item: add a locked version of GetMeta()
Romain Vimont
git at videolan.org
Thu Nov 15 17:29:06 CET 2018
vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Tue Sep 25 16:43:23 2018 +0200| [34bc82b42c7546246ec9c5d3e257171847d4cf40] | committer: Thomas Guillem
input item: add a locked version of GetMeta()
Expose a function which does not lock internally so that we can retrieve
several meta values in a row without locking/unlocking.
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=34bc82b42c7546246ec9c5d3e257171847d4cf40
---
include/vlc_input_item.h | 1 +
src/input/item.c | 20 +++++++++++---------
src/libvlccore.sym | 1 +
3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/include/vlc_input_item.h b/include/vlc_input_item.h
index 787f99a78b..94760663d4 100644
--- a/include/vlc_input_item.h
+++ b/include/vlc_input_item.h
@@ -271,6 +271,7 @@ VLC_API bool input_item_HasErrorWhenReading( input_item_t * );
VLC_API void input_item_SetMeta( input_item_t *, vlc_meta_type_t meta_type, const char *psz_val );
VLC_API bool input_item_MetaMatch( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz );
VLC_API char * input_item_GetMeta( input_item_t *p_i, vlc_meta_type_t meta_type ) VLC_USED;
+VLC_API const char *input_item_GetMetaLocked(input_item_t *, vlc_meta_type_t meta_type);
VLC_API char * input_item_GetName( input_item_t * p_i ) VLC_USED;
VLC_API char * input_item_GetTitleFbName( input_item_t * p_i ) VLC_USED;
VLC_API char * input_item_GetURI( input_item_t * p_i ) VLC_USED;
diff --git a/src/input/item.c b/src/input/item.c
index 1b3f54340d..c5c2bd5d82 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -251,20 +251,22 @@ bool input_item_MetaMatch( input_item_t *p_i,
return b_ret;
}
-char *input_item_GetMeta( input_item_t *p_i, vlc_meta_type_t meta_type )
+const char *input_item_GetMetaLocked(input_item_t *item,
+ vlc_meta_type_t meta_type)
{
- vlc_mutex_lock( &p_i->lock );
+ vlc_mutex_assert(&item->lock);
- if( !p_i->p_meta )
- {
- vlc_mutex_unlock( &p_i->lock );
+ if (!item->p_meta)
return NULL;
- }
- char *psz = NULL;
- if( vlc_meta_Get( p_i->p_meta, meta_type ) )
- psz = strdup( vlc_meta_Get( p_i->p_meta, meta_type ) );
+ return vlc_meta_Get(item->p_meta, meta_type);
+}
+char *input_item_GetMeta( input_item_t *p_i, vlc_meta_type_t meta_type )
+{
+ vlc_mutex_lock( &p_i->lock );
+ const char *value = input_item_GetMetaLocked( p_i, meta_type );
+ char *psz = value ? strdup( value ) : NULL;
vlc_mutex_unlock( &p_i->lock );
return psz;
}
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 3fea6e122f..b82272d019 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -173,6 +173,7 @@ input_item_DelInfo
input_item_GetDuration
input_item_GetInfo
input_item_GetMeta
+input_item_GetMetaLocked
input_item_GetName
input_item_GetNowPlayingFb
input_item_GetTitleFbName
More information about the vlc-commits
mailing list