static inline void input_item_SetMeta( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz_val )
{
vlc_event_t event;
+ vlc_mutex_lock( &p_i->p_lock );
if( !p_i->p_meta )
p_i->p_meta = vlc_meta_New();
vlc_meta_Set( p_i->p_meta, meta_type, psz_val );
+ vlc_mutex_unlock( &p_i->p_lock );
/* Notify interested third parties */
event.type = vlc_InputItemMetaChanged;
vlc_event_send( &p_i->event_manager, &event );
}
-static inline const char * input_item_GetMeta( input_item_t *p_i, vlc_meta_type_t meta_type )
+static inline char * input_item_GetMeta( input_item_t *p_i, vlc_meta_type_t meta_type )
{
+ vlc_mutex_lock( &p_i->p_lock );
if( !p_i->p_meta )
+ {
+ vlc_mutex_unlock( &p_i->p_lock );
return NULL;
- return vlc_meta_Get( p_i->p_meta, meta_type );
+ }
+ char *psz_s = strdup( vlc_meta_Get( p_i->p_meta, meta_type ) );
+ vlc_mutex_unlock( &p_i->p_lock );
+ return psz_s;
+}
+
+static inline char * input_item_GetName( input_item_t *p_i )
+{
+ vlc_mutex_lock( &p_i->p_lock );
+ char *psz_s = strdup( p_i->psz_name );
+ vlc_mutex_unlock( &p_i->p_lock );
+ return psz_s;
}
static inline void input_item_SetPreparsed( input_item_t *p_i, vlc_bool_t preparsed )
#define ADD_VLC_META_STRING( entry, item ) \
{ \
- const char * psz = input_item_Get##item( p_input );\
+ char * psz = input_item_Get##item( p_input );\
ADD_META( entry, DBUS_TYPE_STRING, \
psz ); \
+ free( psz ); \
}
static int GetInputMeta( input_item_t* p_input,
#define IF_EXTRACT(txt,var) \
if( !strncasecmp(psz, txt, strlen(txt)) ) \
{ \
- const char * oldval = vlc_meta_Get( p_sys->p_meta, vlc_meta_ ## var ); \
+ char * oldval = vlc_meta_Get( p_sys->p_meta, vlc_meta_ ## var ); \
if( oldval ) \
{ \
char * newval; \
} \
else \
vlc_meta_Set( p_sys->p_meta, vlc_meta_ ## var, &psz[strlen(txt)] ); \
+ free( oldval ); \
}
IF_EXTRACT("TITLE=", Title )
else IF_EXTRACT("ALBUM=", Album )
if( [[o_tc identifier] isEqualToString:@"1"] )
{
/* sanity check to prevent the NSString class from crashing */
- if( !EMPTY_STR( input_item_GetTitle( p_item->p_input ) ) )
+ char *psz_title = input_item_GetTitle( p_item->p_input );
+ if( !EMPTY_STR( psz_title ) ) )
{
- o_value = [NSString stringWithUTF8String: input_item_GetTitle( p_item->p_input )];
+ o_value = [NSString stringWithUTF8String: psz_title )];
if( o_value == NULL )
- o_value = [NSString stringWithCString: input_item_GetTitle( p_item->p_input )];
+ o_value = [NSString stringWithCString: psz_title )];
}
- else if( p_item->p_input->psz_name != NULL )
+ else
{
- o_value = [NSString stringWithUTF8String: p_item->p_input->psz_name];
- if( o_value == NULL )
- o_value = [NSString stringWithCString: p_item->p_input->psz_name];
+ char *psz_name = input_item_GetName( p_item->p_input );
+ if( psz_name != NULL )
+ {
+ o_value = [NSString stringWithUTF8String: psz_name];
+ if( o_value == NULL )
+ o_value = [NSString stringWithCString: psz_name];
+ }
}
+ free( psz_title );
+ free( psz_name );
}
- else if( [[o_tc identifier] isEqualToString:@"2"] && !EMPTY_STR( input_item_GetArtist( p_item->p_input ) ) )
- {
- o_value = [NSString stringWithUTF8String: input_item_GetArtist( p_item->p_input )];
- if( o_value == NULL )
- o_value = [NSString stringWithCString: input_item_GetArtist( p_item->p_input )];
- }
- else if( [[o_tc identifier] isEqualToString:@"3"] )
+ else
{
- char psz_duration[MSTRTIME_MAX_SIZE];
- mtime_t dur = p_item->p_input->i_duration;
- if( dur != -1 )
+ char *psz_artist = input_item_GetArtist( p_item->p_input );
+ if( [[o_tc identifier] isEqualToString:@"2"] && !EMPTY_STR( psz_artist ) )
{
- secstotimestr( psz_duration, dur/1000000 );
- o_value = [NSString stringWithUTF8String: psz_duration];
+ o_value = [NSString stringWithUTF8String: psz_artist )];
+ if( o_value == NULL )
+ o_value = [NSString stringWithCString: psz_artist )];
}
- else
+ else if( [[o_tc identifier] isEqualToString:@"3"] )
{
- o_value = @"-:--:--";
+ char psz_duration[MSTRTIME_MAX_SIZE];
+ mtime_t dur = p_item->p_input->i_duration;
+ if( dur != -1 )
+ {
+ secstotimestr( psz_duration, dur/1000000 );
+ o_value = [NSString stringWithUTF8String: psz_duration];
+ }
+ else
+ {
+ o_value = @"-:--:--";
+ }
}
+ free( psz_artist );
}
return( o_value );
**/
void MetaPanel::update( input_item_t *p_item )
{
- const char *psz_meta;
+ char *psz_meta;
#define UPDATE_META( meta, widget ) { \
psz_meta = input_item_Get##meta( p_item ); \
if( !EMPTY_STR( psz_meta ) ) \
widget->setText( qfu( psz_meta ) ); \
else \
- widget->setText( "" ); }
+ widget->setText( "" ); } \
+ free( psz_meta );
#define UPDATE_META_INT( meta, widget ) { \
psz_meta = input_item_Get##meta( p_item ); \
if( !EMPTY_STR( psz_meta ) ) \
- widget->setValue( atoi( psz_meta ) ); }
+ widget->setValue( atoi( psz_meta ) ); } \
+ free( psz_meta );
+
/* Name / Title */
psz_meta = input_item_GetTitle( p_item );
else if( !EMPTY_STR( p_item->psz_name ) )
title_text->setText( qfu( p_item->psz_name ) );
else title_text->setText( "" );
+ free( psz_meta );
/* URL / URI */
psz_meta = input_item_GetURL( p_item );
emit uriSet( QString( psz_meta ) );
else if( !EMPTY_STR( p_item->psz_uri ) )
emit uriSet( QString( p_item->psz_uri ) );
+ free( psz_meta );
/* Other classic though */
UPDATE_META( Artist, artist_text );
}
else
art_cover->setPixmap( QPixmap( ":/noart.png" ) );
+ free( psz_meta );
}
/*
/* Update text */
QString text;
- if( !EMPTY_STR(input_item_GetNowPlaying( input_GetItem(p_input) )) )
+ char *psz_name = input_GetName( input_GetItem( p_input ) );
+ char *psz_nowplaying = input_item_GetNowPlaying( input_GetItem( p_input );
+ char *psz_artist = input_item_GetArtist( input_GetItem( p_input ) );
+ if( !EMPTY_STR( psz_nowplaying ) )
{
- text.sprintf( "%s - %s",
- input_item_GetNowPlaying( input_GetItem(p_input) ),
- input_GetItem(p_input)->psz_name );
+ text.sprintf( "%s - %s", psz_now_playing, psz_name );
}
- else if( !EMPTY_STR(input_item_GetArtist( input_GetItem(p_input) )) )
+ else if( !EMPTY_STR( psz_artist ) )
{
- text.sprintf( "%s - %s",
- input_item_GetArtist( input_GetItem(p_input) ),
- input_GetItem(p_input)->psz_name );
+ text.sprintf( "%s - %s", psz_artist, psz_name );
}
else
{
- text.sprintf( "%s", input_GetItem(p_input)->psz_name );
+ text.sprintf( "%s", psz_name );
}
+ free( psz_name );
+ free( psz_nowplaying );
+ free( psz_artist );
if( old_name != text )
{
emit nameChanged( text );
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#define PLI_NAME( p ) p ? p->p_input->psz_name : "null"
#include <assert.h>
#include <QIcon>
type = p_item->p_input->i_type;
current = iscurrent;
- if( current && input_item_GetArtURL( p_item->p_input ) &&
- !strncmp( input_item_GetArtURL( p_item->p_input ), "file://", 7 ) )
- model->sendArt( qfu( input_item_GetArtURL( p_item->p_input ) ) );
+ char *psz_arturl = input_item_GetArtURL( p_item->p_input );
+ if( current && psz_arturl ) &&
+ !strncmp( psz_arturl, "file://", 7 ) )
+ model->sendArt( qfu( psz_arturl ) ) );
else if( current )
model->removeArt();
+ free( psz_arturl );
strings.clear();
return;
}
-
+ char *psz_meta;
#define ADD_META( item, meta ) \
- strings.append( qfu( input_item_Get ## meta ( item->p_input ) ) )
+ psz_meta = input_item_Get ## meta ( item->p_input ); \
+ strings.append( qfu( psz_meta ) ); \
+ free( psz_meta );
for( int i_index=1; i_index <= VLC_META_ENGINE_MB_TRM_ID; i_index = i_index * 2 )
{
ADD_META( p_item, Artist );
break;
case VLC_META_ENGINE_TITLE:
- if( input_item_GetTitle( p_item->p_input ) )
+ char *psz_title;
+ psz_title = input_item_GetTile( p_item->p_input );
+ psz_name = input_item_GetName( p_item->p_input );
+ if( psz_title )
{
ADD_META( p_item, Title );
} else {
- strings.append( qfu( p_item->p_input->psz_name ) );
+ strings.append( qfu( psz_name ) );
}
+ free( psz_title );
+ free( psz_name );
break;
case VLC_META_ENGINE_DESCRIPTION:
ADD_META( p_item, Description );
name_text->SetValue( wxU( p_item->psz_name ) );
#define UPDATE_META( meta, widget ) { \
- const char *psz_meta = input_item_Get##meta( p_item ); \
+ char *psz_meta = input_item_Get##meta( p_item ); \
if( psz_meta != NULL && *psz_meta) \
{ \
widget->SetLabel( wxU( psz_meta ) ); \
} \
else { widget->SetLabel( wxU( "-" ) ); } \
- }
+ } \
+ free( psz_meta );
UPDATE_META( Artist, artist_text );
UPDATE_META( Genre, genre_text );
wxString duration = wxU( "" );
char *psz_artist;
- psz_artist = input_item_GetArtist( p_item->p_input ) ?
- strdup( input_item_GetArtist( p_item->p_input ) ) :
- strdup("");
+ psz_artist = input_item_GetArtist( p_item->p_input );
char psz_duration[MSTRTIME_MAX_SIZE];
mtime_t dur = p_item->p_input->i_duration;
void InputManager::UpdateNowPlaying()
{
- const char *psz_now_playing = input_item_GetNowPlaying( input_GetItem(p_input) );
+ char *psz_now_playing = input_item_GetNowPlaying( input_GetItem(p_input) );
if( psz_now_playing && *psz_now_playing )
{
p_main_intf->statusbar->SetStatusText(
p_main_intf->statusbar->SetStatusText(
wxU(input_GetItem(p_input)->psz_name), 2 );
}
+ free( psz_now_playing );
}
void InputManager::UpdateButtons( vlc_bool_t b_play )
wxString msg;
wxString duration = wxU( "" );
- const char *psz_artist = input_item_GetArtist( p_item->p_input );
+ char *psz_artist = input_item_GetArtist( p_item->p_input );
if( ! psz_artist )
{
psz_artist = "";
msg = wxString(wxU( psz_artist )) + wxT(" - ") +
wxString(wxU(p_item->p_input->psz_name)) + duration;
}
+ free( psz_artist );
treectrl->SetItemText( item , msg );
treectrl->SetItemImage( item, p_item->p_input->i_type );
msg_Err( p_this, "Could not create new Lua State" );
return NULL;
}
+ char *psz_meta;
/* Load Lua libraries */
luaL_openlibs( p_state ); /* XXX: Don't open all the libs? */
lua_pushlightuserdata( p_state, p_this );
lua_setfield( p_state, lua_gettop( p_state ) - 1, "private" );
-
- lua_pushstring( p_state, p_item->psz_name );
+
+ psz_meta = input_item_GetName( p_item );
+ lua_pushstring( p_state, psz_meta );
lua_setfield( p_state, lua_gettop( p_state ) - 1, "name" );
-
- lua_pushstring( p_state, input_item_GetTitle( p_item ) );
+ free( psz_meta );
+
+ psz_meta = input_item_GetTitle( p_item ) ;
+ lua_pushstring( p_state, psz_meta );
lua_setfield( p_state, lua_gettop( p_state ) - 1, "title" );
-
- lua_pushstring( p_state, input_item_GetAlbum( p_item ) );
+ free( psz_meta );
+
+ psz_meta = input_item_GetAlbum( p_item );
+ lua_pushstring( p_state, psz_meta );
lua_setfield( p_state, lua_gettop( p_state ) - 1, "album" );
+ free( psz_meta );
- lua_pushstring( p_state, input_item_GetArtURL( p_item ) );
+ psz_meta = input_item_GetArtURL( p_item );
+ lua_pushstring( p_state, psz_meta );
lua_setfield( p_state, lua_gettop( p_state ) - 1, "arturl" );
- /* XXX: all should be passed */
+ free( psz_meta );
+ /* XXX: all should be passed ( could use macro ) */
return p_state;
}
char i_album_count, i;
char *ppsz_args[4];
- char *psz_title;
char *psz_artist;
char *psz_album;
psz_artist = input_item_GetArtist( p_item );
psz_album = input_item_GetAlbum( p_item );
- psz_title = p_item->psz_name;
if( !psz_artist || !psz_album )
+ {
+ free( psz_artist );
+ free( psz_album );
return VLC_EGENERIC;
+ }
+ free( psz_artist );
+ free( psz_album );
musicbrainz_t p_mb;
if( !b_art )
return VLC_SUCCESS;
else
- return EMPTY_STR( input_item_GetArtURL( p_item ) ) ?
- VLC_SUCCESS : VLC_EGENERIC;
+ {
+ char *psz_arturl;
+ psz_arturl = input_item_GetArtURL( p_item );
+ int i_ret;
+ i_ret = EMPTY_STR( psz_arturl ) ? VLC_SUCCESS : VLC_EGENERIC ;
+ free( psz_arturl );
+ return i_ret;
}
static int FindMetaMBId( vlc_object_t *p_this )
TagLib::Tag *tag = f.tag();
- SET( Artist, input_item_GetArtist( p_item ) );
+ char *psz_meta;
- const char *psz_titlec = ( input_item_GetTitle( p_item ) ?
- input_item_GetTitle( p_item ) : p_item->psz_name );
- TagLib::String *psz_title = new TagLib::String( psz_titlec,
+ psz_meta = input_item_GetArtist( p_item );
+ SET( Artist, psz_meta );
+ free( psz_meta );
+
+ psz_meta = input_item_GetTitle( p_item );
+ if( !psz_meta ) psz_meta = input_item_GetName( p_item );
+ TagLib::String *psz_title = new TagLib::String( psz_meta,
TagLib::String::UTF8 );
tag->setTitle( *psz_title );
delete psz_title;
+ free( psz_meta );
+
+ psz_meta = input_item_GetAlbum( p_item );
+ SET( Album, psz_meta );
+ free( psz_meta );
+
+ psz_meta = input_item_GetGenre( p_item );
+ SET( Genre, psz_meta );
+ free( psz_meta );
- SET( Album, input_item_GetAlbum( p_item ) );
- SET( Genre, input_item_GetGenre( p_item ) );
+ psz_meta = input_item_GetDate( p_item );
+ if( psz_meta ) tag->setYear( atoi( psz_meta ) );
+ free( psz_meta );
- if( input_item_GetDate( p_item ) )
- tag->setYear( atoi( input_item_GetDate( p_item ) ) );
- if( input_item_GetTrackNum( p_item ) )
- tag->setTrack( atoi( input_item_GetTrackNum( p_item ) ) );
+ psz_meta = input_item_GetTrackNum( p_item );
+ if( psz_meta ) tag->setTrack( atoi( psz_meta ) );
+ free( psz_meta );
f.save();
return VLC_SUCCESS;
p_sys->p_current_song->psz_i = encode_URI_component( psz_date );
p_sys->p_current_song->time_playing = epoch;
- p_sys->b_paused = ( p_input->b_dead || !input_GetItem(p_input)->psz_name )
+ char *psz_name = input_item_GetName( input_GetItem( p_input ) );
+ p_sys->b_paused = ( p_input->b_dead || !psz_name )
? VLC_TRUE : VLC_FALSE;
+ free( psz_name );
vlc_mutex_unlock( &p_sys->lock );
var_Change( p_input, "video-es", VLC_VAR_CHOICESCOUNT, &video_val, NULL );
if( ( video_val.i_int > 0 ) || \
- ( input_GetItem(p_input)->i_type == ITEM_TYPE_NET ) )
+ ( input_GetItem( p_input )->i_type == ITEM_TYPE_NET ) )
{
msg_Dbg( p_this, "Not an audio only local file -> no submission");
vlc_object_release( p_input );
return VLC_SUCCESS; \
}
+ char *psz_meta;
#define ALLOC_ITEM_META( a, b ) \
- if ( input_item_Get##b( input_GetItem(p_input) ) ) \
+ psz_meta = input_item_Get##b( input_GetItem( p_input ) ) \
+ if( psz_meta ) \
{ \
- a = encode_URI_component( \
- input_item_Get##b( input_GetItem(p_input) )); \
+ a = encode_URI_component( psz_meta ); \
if( !a ) \
{ \
+ free( psz_meta ); \
FREE_INPUT_AND_CHARS \
return VLC_ENOMEM; \
} \
+ free( psz_meta ); \
}
i_status = input_GetItem(p_input)->p_meta->i_status;
msg_Dbg( p_this, "No artist.." );
WAIT_METADATA_FETCHING( psz_artist )
}
-
- if( input_GetItem(p_input)->psz_name )
+ psz_meta = input_item_GetName( input_GetItem( p_input ) );
+ if( psz_meta )
{
- psz_title = encode_URI_component( input_GetItem(p_input)->psz_name );
+ psz_title = encode_URI_component( psz_meta );
if( !psz_title )
{
+ free( psz_meta );
FREE_INPUT_AND_CHARS
return VLC_ENOMEM;
}
+ free( psz_meta );
}
else
{
libvlc_meta_t e_meta,
libvlc_exception_t *p_e )
{
- const char * psz_meta;
+ char * psz_meta;
/* XXX: locking */
/* Should be integrated in core */
if( !psz_meta && e_meta == libvlc_meta_Title && p_md->p_input_item->psz_name )
+ {
+ free( psz_meta );
return strdup( p_md->p_input_item->psz_name );
+ }
if( !psz_meta )
- return NULL;
+ {
+ free( psz_meta );
+ return NULL
+ }
- return strdup( psz_meta );
+ return psz_meta;
}
{
playlist_LiveSearchUpdate( p_playlist, p_item, psz_string );
}
-#define META_MATCHES( field ) ( input_item_GetMeta( p_item->p_input, vlc_meta_##field ) && \
- strcasestr( input_item_GetMeta( p_item->p_input, vlc_meta_##field ), psz_string ) )
else
{
- if( strcasestr( p_item->p_input->psz_name, psz_string ) ||
- META_MATCHES( Artist ) || META_MATCHES( Album ) )
+ char *psz_name_matches, *psz_artist_matches, *psz_album_matches;
+ char *psz_field, *psz_field_case;
+
+ psz_field = input_item_GetName( p_i );
+ psz_name_matches = strcasestr( psz_field, psz_string );
+ free( psz_field );
+
+ psz_field = input_item_GetMeta( p_item->p_input, vlc_meta_Artist );
+ psz_field_case = strcasestr( input_item_GetMeta( p_item->p_input, vlc_meta_Artist ), psz_string );
+ psz_artist_matches = ( psz_field && psz_field_case );
+ free( psz_field );
+ free( psz_field_case );
+
+
+ psz_field = input_item_GetMeta( p_item->p_input, vlc_meta_Album );
+ psz_field_case = strcasestr( input_item_GetMeta( p_item->p_input, vlc_meta_Album ), psz_string );
+ psz_album_matches = ( psz_field && psz_field_case );
+ free( psz_field );
+ free( psz_field_case );
+
+ if( psz_name_matches || psz_artist_matches || psz_album_matches )
p_item->i_flags &= ~PLAYLIST_DBL_FLAG;
else
p_item->i_flags |= PLAYLIST_DBL_FLAG;
}
#define DO_META_SORT( node ) { \
- const char *psz_a = input_item_GetMeta( pp_items[i]->p_input, vlc_meta_##node ); \
- const char *psz_b = input_item_GetMeta( pp_items[i_small]->p_input, vlc_meta_##node ); \
+ char *psz_a = input_item_GetMeta( pp_items[i]->p_input, vlc_meta_##node ); \
+ char *psz_b = input_item_GetMeta( pp_items[i_small]->p_input, vlc_meta_##node ); \
/* Nodes go first */ \
if( pp_items[i]->i_children == -1 && pp_items[i_small]->i_children >= 0 ) \
i_test = 1;\
pp_items[i_position] = pp_items[i_small];
pp_items[i_small] = p_temp;
}
+ free( psz_a );
+ free( psz_b );
return VLC_SUCCESS;
}