Browse Source

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@gllm.fr>
pull/80/head
Romain Vimont 8 years ago
committed by Thomas Guillem
parent
commit
34bc82b42c
  1. 1
      include/vlc_input_item.h
  2. 20
      src/input/item.c
  3. 1
      src/libvlccore.sym

1
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;

20
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;
}

1
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

Loading…
Cancel
Save