Commit 662ed774 authored by Rafaël Carré's avatar Rafaël Carré

Input access locking, part 2.

Fix [21193]
parent a387a1ff
...@@ -26,6 +26,11 @@ ...@@ -26,6 +26,11 @@
#error You are not libvlc or one of its plugins. You cannot include this file #error You are not libvlc or one of its plugins. You cannot include this file
#endif #endif
#ifndef __USE_GNU
#define __USE_GNU
#endif
#include <string.h> /* strcasestr() */
/* __ is need because conflict with <vlc/input.h> */ /* __ is need because conflict with <vlc/input.h> */
#ifndef _VLC__INPUT_H #ifndef _VLC__INPUT_H
#define _VLC__INPUT_H 1 #define _VLC__INPUT_H 1
...@@ -222,11 +227,11 @@ static inline void input_item_SetMeta( input_item_t *p_i, vlc_meta_type_t meta_t ...@@ -222,11 +227,11 @@ static inline void input_item_SetMeta( input_item_t *p_i, vlc_meta_type_t meta_t
{ {
vlc_event_t event; vlc_event_t event;
//vlc_mutex_lock( &p_i->lock ); vlc_mutex_lock( &p_i->lock );
if( !p_i->p_meta ) if( !p_i->p_meta )
p_i->p_meta = vlc_meta_New(); p_i->p_meta = vlc_meta_New();
vlc_meta_Set( p_i->p_meta, meta_type, psz_val ); vlc_meta_Set( p_i->p_meta, meta_type, psz_val );
//vlc_mutex_unlock( &p_i->lock ); vlc_mutex_unlock( &p_i->lock );
/* Notify interested third parties */ /* Notify interested third parties */
event.type = vlc_InputItemMetaChanged; event.type = vlc_InputItemMetaChanged;
...@@ -236,10 +241,10 @@ static inline void input_item_SetMeta( input_item_t *p_i, vlc_meta_type_t meta_t ...@@ -236,10 +241,10 @@ static inline void input_item_SetMeta( input_item_t *p_i, vlc_meta_type_t meta_t
static inline vlc_bool_t input_item_MetaMatch( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz ) static inline vlc_bool_t input_item_MetaMatch( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz )
{ {
//vlc_mutex_lock( &p_i->lock ); vlc_mutex_lock( &p_i->lock );
const char * meta = vlc_meta_Get( p_i->p_meta, meta_type ); const char * meta = vlc_meta_Get( p_i->p_meta, meta_type );
vlc_bool_t ret = meta && strcasestr( meta, psz ); vlc_bool_t ret = meta && strcasestr( meta, psz );
//vlc_mutex_unlock( &p_i->lock ); vlc_mutex_unlock( &p_i->lock );
return ret; return ret;
} }
...@@ -247,26 +252,26 @@ static inline vlc_bool_t input_item_MetaMatch( input_item_t *p_i, vlc_meta_type_ ...@@ -247,26 +252,26 @@ static inline vlc_bool_t input_item_MetaMatch( input_item_t *p_i, vlc_meta_type_
static inline 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 )
{ {
char * psz = NULL; char * psz = NULL;
//vlc_mutex_lock( &p_i->lock ); vlc_mutex_lock( &p_i->lock );
if( !p_i->p_meta ) if( !p_i->p_meta )
{ {
//vlc_mutex_unlock( &p_i->lock ); vlc_mutex_unlock( &p_i->lock );
return NULL; return NULL;
} }
if( vlc_meta_Get( p_i->p_meta, meta_type ) ) if( vlc_meta_Get( p_i->p_meta, meta_type ) )
psz = strdup( vlc_meta_Get( p_i->p_meta, meta_type ) ); psz = strdup( vlc_meta_Get( p_i->p_meta, meta_type ) );
//vlc_mutex_unlock( &p_i->lock ); vlc_mutex_unlock( &p_i->lock );
return psz; return psz;
} }
static inline char * input_item_GetName( input_item_t * p_i ) static inline char * input_item_GetName( input_item_t * p_i )
{ {
//vlc_mutex_lock( &p_i->lock ); vlc_mutex_lock( &p_i->lock );
char *psz_s = p_i->psz_name ? strdup( p_i->psz_name ) : NULL; char *psz_s = p_i->psz_name ? strdup( p_i->psz_name ) : NULL;
//vlc_mutex_unlock( &p_i->lock ); vlc_mutex_unlock( &p_i->lock );
return psz_s; return psz_s;
} }
......
...@@ -124,21 +124,22 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, ...@@ -124,21 +124,22 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
if( !p_input ) return VLC_SUCCESS; if( !p_input ) return VLC_SUCCESS;
vlc_object_yield( p_input ); vlc_object_yield( p_input );
if( p_input->b_dead || !input_GetItem(p_input)->psz_name ) char *psz_name = input_item_GetName( input_GetItem( p_input ) );
if( p_input->b_dead || !psz_name )
{ {
/* Not playing anything ... */ /* Not playing anything ... */
free( psz_name );
vlc_object_release( p_input ); vlc_object_release( p_input );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
free( psz_name );
/* Playing something ... */ /* Playing something ... */
psz_artist = input_item_GetArtist( input_GetItem(p_input) ) ? psz_artist = input_item_GetArtist( input_GetItem( p_input ) );
strdup( input_item_GetArtist( input_GetItem(p_input) ) ) : if( psz_artist == NULL ) psz_artist = strdup( "" );
strdup( "" ); psz_album = input_item_GetAlbum( input_GetItem( p_input ) ) ;
psz_album = input_item_GetAlbum( input_GetItem(p_input) ) ? if( psz_album == NULL ) psz_album = strdup( "" );
strdup( input_item_GetAlbum( input_GetItem(p_input) ) ) : psz_title = input_item_GetName( input_GetItem( p_input ) );
strdup("" );
psz_title = strdup( input_GetItem(p_input)->psz_name );
if( psz_title == NULL ) psz_title = strdup( N_("(no title)") ); if( psz_title == NULL ) psz_title = strdup( N_("(no title)") );
snprintf( psz_tmp, GROWL_MAX_LENGTH, "%s %s %s", snprintf( psz_tmp, GROWL_MAX_LENGTH, "%s %s %s",
psz_title, psz_artist, psz_album ); psz_title, psz_artist, psz_album );
......
...@@ -150,13 +150,11 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, ...@@ -150,13 +150,11 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
} }
/* Playing something ... */ /* Playing something ... */
psz_artist = input_item_GetArtist( input_GetItem(p_input) ) ? psz_artist = input_item_GetArtist( input_GetItem( p_input ) );
strdup( input_item_GetArtist( input_GetItem(p_input) ) ) : if( psz_artist == NULL ) psz_artist = strdup( _("no artist") );
strdup( _("no artist") ); psz_album = input_item_GetAlbum( input_GetItem( p_input ) ) ;
psz_album = input_item_GetAlbum( input_GetItem(p_input) ) ? if( psz_album == NULL ) psz_album = strdup( _("no album") );
strdup( input_item_GetAlbum( input_GetItem(p_input) ) ) : psz_title = input_item_GetName( input_GetItem( p_input ) );
strdup( _("no album") );
psz_title = strdup( input_GetItem(p_input)->psz_name );
vlc_object_release( p_input ); vlc_object_release( p_input );
......
...@@ -65,13 +65,11 @@ static void DoChildren( playlist_t *p_playlist, playlist_export_t *p_export, ...@@ -65,13 +65,11 @@ static void DoChildren( playlist_t *p_playlist, playlist_export_t *p_export,
assert( p_current->p_input->psz_uri ); assert( p_current->p_input->psz_uri );
/* General info */ /* General info */
if( p_current->p_input->psz_name && char *psz_name = input_item_GetName( p_current->p_input );
strcmp( p_current->p_input->psz_uri, if( psz_name && strcmp( p_current->p_input->psz_uri, psz_name ) )
p_current->p_input->psz_name ) )
{ {
char *psz_artist = input_item_GetArtist( p_current->p_input ) ? char *psz_artist = input_item_GetArtist( p_current->p_input );
strdup( input_item_GetArtist( p_current->p_input ) ): if( psz_artist == NULL ) psz_artist = strdup( "" );
strdup( "" );
if( psz_artist && *psz_artist ) if( psz_artist && *psz_artist )
{ {
/* write EXTINF with artist */ /* write EXTINF with artist */
...@@ -87,9 +85,9 @@ static void DoChildren( playlist_t *p_playlist, playlist_export_t *p_export, ...@@ -87,9 +85,9 @@ static void DoChildren( playlist_t *p_playlist, playlist_export_t *p_export,
(int)( p_current->p_input->i_duration/1000000 ), (int)( p_current->p_input->i_duration/1000000 ),
p_current->p_input->psz_name); p_current->p_input->psz_name);
} }
if( psz_artist ) free( psz_artist );
free( psz_artist );
} }
free( psz_name );
/* VLC specific options */ /* VLC specific options */
for( j = 0; j < p_current->p_input->i_options; j++ ) for( j = 0; j < p_current->p_input->i_options; j++ )
......
...@@ -163,11 +163,10 @@ static void xspf_export_item( playlist_item_t *p_item, FILE *p_file, ...@@ -163,11 +163,10 @@ static void xspf_export_item( playlist_item_t *p_item, FILE *p_file,
} }
/* -> the artist/creator */ /* -> the artist/creator */
psz = input_item_GetArtist( p_item->p_input ) ? psz = input_item_GetArtist( p_item->p_input );
strdup( input_item_GetArtist( p_item->p_input ) ): if( psz == NULL ) psz = strdup( "" );
strdup( "" );
psz_temp = convert_xml_special_chars( psz ); psz_temp = convert_xml_special_chars( psz );
if( psz ) free( psz ); free( psz );
if( *psz_temp ) if( *psz_temp )
{ {
fprintf( p_file, "\t\t\t<creator>%s</creator>\n", psz_temp ); fprintf( p_file, "\t\t\t<creator>%s</creator>\n", psz_temp );
...@@ -175,11 +174,10 @@ static void xspf_export_item( playlist_item_t *p_item, FILE *p_file, ...@@ -175,11 +174,10 @@ static void xspf_export_item( playlist_item_t *p_item, FILE *p_file,
free( psz_temp ); free( psz_temp );
/* -> the album */ /* -> the album */
psz = input_item_GetAlbum( p_item->p_input ) ? psz = input_item_GetAlbum( p_item->p_input );
strdup( input_item_GetAlbum( p_item->p_input ) ): if( psz == NULL ) psz = strdup( "" );
strdup( "" );
psz_temp = convert_xml_special_chars( psz ); psz_temp = convert_xml_special_chars( psz );
if( psz ) free( psz ); free( psz );
if( *psz_temp ) if( *psz_temp )
{ {
fprintf( p_file, "\t\t\t<album>%s</album>\n", psz_temp ); fprintf( p_file, "\t\t\t<album>%s</album>\n", psz_temp );
...@@ -187,24 +185,22 @@ static void xspf_export_item( playlist_item_t *p_item, FILE *p_file, ...@@ -187,24 +185,22 @@ static void xspf_export_item( playlist_item_t *p_item, FILE *p_file,
free( psz_temp ); free( psz_temp );
/* -> the track number */ /* -> the track number */
psz = input_item_GetTrackNum( p_item->p_input ) ? psz = input_item_GetTrackNum( p_item->p_input );
strdup( input_item_GetTrackNum( p_item->p_input ) ): if( psz == NULL ) psz = strdup( "" );
strdup( "" );
if( psz ) if( psz )
{ {
if( *psz ) if( *psz )
{ {
fprintf( p_file, "\t\t\t<trackNum>%i</trackNum>\n", atoi( psz ) ); fprintf( p_file, "\t\t\t<trackNum>%i</trackNum>\n", atoi( psz ) );
} }
free( psz );
} }
free( psz );
/* -> the description */ /* -> the description */
psz = input_item_GetDescription( p_item->p_input ) ? psz = input_item_GetDescription( p_item->p_input );
strdup( input_item_GetDescription( p_item->p_input ) ): if( psz == NULL ) psz = strdup( "" );
strdup( "" );
psz_temp = convert_xml_special_chars( psz ); psz_temp = convert_xml_special_chars( psz );
if( psz ) free( psz ); free( psz );
if( *psz_temp ) if( *psz_temp )
{ {
fprintf( p_file, "\t\t\t<annotation>%s</annotation>\n", psz_temp ); fprintf( p_file, "\t\t\t<annotation>%s</annotation>\n", psz_temp );
......
...@@ -416,12 +416,10 @@ static char *TitleGet( vlc_object_t *p_this ) ...@@ -416,12 +416,10 @@ static char *TitleGet( vlc_object_t *p_this )
if( p_input ) if( p_input )
{ {
if( !EMPTY_STR( input_item_GetTitle( input_GetItem(p_input) ) ) ) psz_title = strdup( input_item_GetTitle( input_GetItem( p_input ) ) );
{ if( EMPTY_STR( psz_title ) )
psz_title = strdup( input_item_GetTitle( input_GetItem(p_input) ) );
}
else
{ {
free( psz_title );
char *psz = strrchr( input_GetItem(p_input)->psz_uri, '/' ); char *psz = strrchr( input_GetItem(p_input)->psz_uri, '/' );
if( psz ) if( psz )
......
...@@ -152,7 +152,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args ) ...@@ -152,7 +152,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
p_cat = malloc( sizeof( info_category_t ) ); p_cat = malloc( sizeof( info_category_t ) );
if( !p_cat ) if( !p_cat )
{ {
vlc_mutex_lock( &p_input->p->input.p_item->lock ); vlc_mutex_unlock( &p_input->p->input.p_item->lock );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_cat->psz_name = strdup( psz_cat ); p_cat->psz_name = strdup( psz_cat );
...@@ -180,7 +180,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args ) ...@@ -180,7 +180,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
p_info = malloc( sizeof( info_t ) ); p_info = malloc( sizeof( info_t ) );
if( !p_info ) if( !p_info )
{ {
vlc_mutex_lock( &p_input->p->input.p_item->lock ); vlc_mutex_unlock( &p_input->p->input.p_item->lock );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
......
...@@ -487,12 +487,10 @@ static void EsOutProgramSelect( es_out_t *out, es_out_pgrm_t *p_pgrm ) ...@@ -487,12 +487,10 @@ static void EsOutProgramSelect( es_out_t *out, es_out_pgrm_t *p_pgrm )
} }
/* Update now playing */ /* Update now playing */
vlc_mutex_lock( &p_input->p->input.p_item->lock );
input_item_SetNowPlaying( p_input->p->input.p_item, input_item_SetNowPlaying( p_input->p->input.p_item,
p_pgrm->psz_now_playing ); p_pgrm->psz_now_playing );
input_item_SetPublisher( p_input->p->input.p_item, input_item_SetPublisher( p_input->p->input.p_item,
p_pgrm->psz_publisher ); p_pgrm->psz_publisher );
vlc_mutex_unlock( &p_input->p->input.p_item->lock );
var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE ); var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE );
} }
...@@ -672,11 +670,7 @@ static void EsOutProgramMeta( es_out_t *out, int i_group, vlc_meta_t *p_meta ) ...@@ -672,11 +670,7 @@ static void EsOutProgramMeta( es_out_t *out, int i_group, vlc_meta_t *p_meta )
if( psz_provider ) if( psz_provider )
{ {
if( p_sys->p_pgrm == p_pgrm ) if( p_sys->p_pgrm == p_pgrm )
{
vlc_mutex_lock( &p_input->p->input.p_item->lock );
input_item_SetPublisher( p_input->p->input.p_item, psz_provider ); input_item_SetPublisher( p_input->p->input.p_item, psz_provider );
vlc_mutex_unlock( &p_input->p->input.p_item->lock );
}
input_Control( p_input, INPUT_ADD_INFO, psz_cat, input_MetaTypeToLocalizedString(vlc_meta_Publisher), psz_provider ); input_Control( p_input, INPUT_ADD_INFO, psz_cat, input_MetaTypeToLocalizedString(vlc_meta_Publisher), psz_provider );
} }
char ** ppsz_all_keys = vlc_dictionary_all_keys( &p_meta->extra_tags ); char ** ppsz_all_keys = vlc_dictionary_all_keys( &p_meta->extra_tags );
...@@ -798,10 +792,8 @@ static void EsOutProgramEpg( es_out_t *out, int i_group, vlc_epg_t *p_epg ) ...@@ -798,10 +792,8 @@ static void EsOutProgramEpg( es_out_t *out, int i_group, vlc_epg_t *p_epg )
if( p_epg->p_current && p_epg->p_current->psz_name && *p_epg->p_current->psz_name ) if( p_epg->p_current && p_epg->p_current->psz_name && *p_epg->p_current->psz_name )
p_pgrm->psz_now_playing = strdup( p_epg->p_current->psz_name ); p_pgrm->psz_now_playing = strdup( p_epg->p_current->psz_name );
vlc_mutex_lock( &p_input->p->input.p_item->lock );
if( p_pgrm == p_sys->p_pgrm ) if( p_pgrm == p_sys->p_pgrm )
input_item_SetNowPlaying( p_input->p->input.p_item, p_pgrm->psz_now_playing ); input_item_SetNowPlaying( p_input->p->input.p_item, p_pgrm->psz_now_playing );
vlc_mutex_unlock( &p_input->p->input.p_item->lock );
if( p_pgrm->psz_now_playing ) if( p_pgrm->psz_now_playing )
{ {
......
...@@ -254,9 +254,7 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item, ...@@ -254,9 +254,7 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
input_Control( p_input, INPUT_DEL_INFO, input_Control( p_input, INPUT_DEL_INFO,
_(VLC_META_INFO_CAT), _(VLC_META_INFO_CAT),
_(VLC_META_NOW_PLAYING) ); _(VLC_META_NOW_PLAYING) );
vlc_mutex_lock( &p_item->lock );
input_item_SetNowPlaying( p_item, NULL ); input_item_SetNowPlaying( p_item, NULL );
vlc_mutex_unlock( &p_item->lock );
/* */ /* */
if( p_input->b_preparsing ) if( p_input->b_preparsing )
...@@ -2505,39 +2503,44 @@ static void InputMetaUser( input_thread_t *p_input, vlc_meta_t *p_meta ) ...@@ -2505,39 +2503,44 @@ static void InputMetaUser( input_thread_t *p_input, vlc_meta_t *p_meta )
static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta ) static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta )
{ {
input_item_t *p_item = p_input->p->input.p_item; input_item_t *p_item = p_input->p->input.p_item;
char * psz_saved_arturl = NULL; char * psz_arturl = NULL;
const char * psz_arturl = NULL;
char *psz_title = NULL; char *psz_title = NULL;
int i; int i;
int i_arturl_event = VLC_FALSE;
if( !p_meta ) if( !p_meta )
return; return;
psz_arturl = input_item_GetArtURL( p_item );
vlc_mutex_lock( &p_item->lock ); vlc_mutex_lock( &p_item->lock );
if( vlc_meta_Get( p_meta, vlc_meta_Title ) && !p_item->b_fixed_name ) if( vlc_meta_Get( p_meta, vlc_meta_Title ) && !p_item->b_fixed_name )
psz_title = strdup( vlc_meta_Get( p_meta, vlc_meta_Title ) ); psz_title = strdup( vlc_meta_Get( p_meta, vlc_meta_Title ) );
if( input_item_GetArtURL( p_item ) )
psz_saved_arturl = strdup( input_item_GetArtURL( p_item ) );
vlc_meta_Merge( p_item->p_meta, p_meta ); vlc_meta_Merge( p_item->p_meta, p_meta );
if( psz_saved_arturl && *psz_saved_arturl ) if( psz_arturl && *psz_arturl )
input_item_SetArtURL( p_item, psz_saved_arturl ); {
vlc_meta_Set( p_item->p_meta, vlc_meta_ArtworkURL, psz_arturl );
i_arturl_event = VLC_TRUE;
}
free( psz_saved_arturl );
vlc_meta_Delete( p_meta ); vlc_meta_Delete( p_meta );
psz_arturl = input_item_GetArtURL( p_item );
if( psz_arturl && !strncmp( psz_arturl, "attachment://", strlen("attachment") ) ) if( psz_arturl && !strncmp( psz_arturl, "attachment://", strlen("attachment") ) )
{ {
/* Don't look for art cover if sout /* Don't look for art cover if sout
* XXX It can change when sout has meta data support */ * XXX It can change when sout has meta data support */
if( p_input->p->p_sout && !p_input->b_preparsing ) if( p_input->p->p_sout && !p_input->b_preparsing )
input_item_SetArtURL( p_item, "" ); {
vlc_meta_Set( p_item->p_meta, vlc_meta_ArtworkURL, "" );
i_arturl_event = VLC_TRUE;
}
else else
input_ExtractAttachmentAndCacheArt( p_input ); input_ExtractAttachmentAndCacheArt( p_input );
} }
free( psz_arturl );
input_item_SetPreparsed( p_item, VLC_TRUE ); input_item_SetPreparsed( p_item, VLC_TRUE );
...@@ -2550,6 +2553,16 @@ static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta ) ...@@ -2550,6 +2553,16 @@ static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta )
} }
vlc_mutex_unlock( &p_item->lock ); vlc_mutex_unlock( &p_item->lock );
if( i_arturl_event == VLC_TRUE )
{
vlc_event_t event;
/* Notify interested third parties */
event.type = vlc_InputItemMetaChanged;
event.u.input_item_meta_changed.meta_type = vlc_meta_ArtworkURL;
vlc_event_send( &p_item->event_manager, &event );
}
if( psz_title ) if( psz_title )
{ {
input_Control( p_input, INPUT_SET_NAME, psz_title ); input_Control( p_input, INPUT_SET_NAME, psz_title );
......
...@@ -119,24 +119,33 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item ) ...@@ -119,24 +119,33 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item )
{ {
int i_ret = VLC_EGENERIC; int i_ret = VLC_EGENERIC;
module_t *p_module; module_t *p_module;
char *psz_name, *psz_title, *psz_artist, *psz_album;
if( !p_item->p_meta ) if( !p_item->p_meta )
return VLC_EGENERIC; return VLC_EGENERIC;
if( !p_item->psz_name && !input_item_GetTitle( p_item ) && psz_name = input_item_GetName( p_item );
(!input_item_GetArtist( p_item ) || !input_item_GetAlbum( p_item )) ) psz_title = input_item_GetTitle( p_item );
psz_artist = input_item_GetArtist( p_item );
psz_album = input_item_GetAlbum( p_item );
if( !psz_name && !psz_title && !psz_artist && !psz_album )
return VLC_EGENERIC; return VLC_EGENERIC;
free( psz_name );
free( psz_title );
/* If we already checked this album in this session, skip */ /* If we already checked this album in this session, skip */
if( input_item_GetArtist( p_item ) && input_item_GetAlbum( p_item ) ) if( psz_artist && psz_album )
{ {
FOREACH_ARRAY( playlist_album_t album, p_playlist->p_fetcher->albums ) FOREACH_ARRAY( playlist_album_t album, p_playlist->p_fetcher->albums )
if( !strcmp( album.psz_artist, input_item_GetArtist( p_item ) ) && if( !strcmp( album.psz_artist, psz_artist ) &&
!strcmp( album.psz_album, input_item_GetAlbum( p_item ) ) ) !strcmp( album.psz_album, psz_album ) )
{ {
msg_Dbg( p_playlist, " %s - %s has already been searched", msg_Dbg( p_playlist, " %s - %s has already been searched",
input_item_GetArtist( p_item ), input_item_GetAlbum( p_item ) ); psz_artist, psz_album );
/* TODO-fenrir if we cache art filename too, we can go faster */ /* TODO-fenrir if we cache art filename too, we can go faster */
free( psz_artist );
free( psz_album );
if( album.b_found ) if( album.b_found )
{ {
/* Actually get URL from cache */ /* Actually get URL from cache */
...@@ -150,23 +159,36 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item ) ...@@ -150,23 +159,36 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item )
} }
FOREACH_END(); FOREACH_END();
} }
free( psz_artist );
free( psz_album );
char *psz_arturl = input_item_GetArtURL( p_item );
input_FindArtInCache( p_playlist, p_item ); input_FindArtInCache( p_playlist, p_item );
if( !EMPTY_STR(input_item_GetArtURL( p_item )) ) if( !EMPTY_STR( psz_arturl ) )
{
free( psz_arturl );
return 0; return 0;
}
free( psz_arturl );
PL_LOCK; PL_LOCK;
p_playlist->p_private = p_item; p_playlist->p_private = p_item;
if( input_item_GetAlbum( p_item ) && input_item_GetArtist( p_item ) ) psz_album = input_item_GetAlbum( p_item );
psz_artist = input_item_GetArtist( p_item );
psz_name = input_item_GetName( p_item );
psz_title = input_item_GetTitle( p_item );
if( psz_album && psz_artist )
{ {
msg_Dbg( p_playlist, "searching art for %s - %s", msg_Dbg( p_playlist, "searching art for %s - %s",
input_item_GetArtist( p_item ), input_item_GetAlbum( p_item ) ); psz_artist, psz_album );
} }
else else
{ {
msg_Dbg( p_playlist, "searching art for %s", msg_Dbg( p_playlist, "searching art for %s",
input_item_GetTitle( p_item ) ? input_item_GetTitle( p_item ) : p_item->psz_name ); psz_title ? psz_title : psz_name );
} }
free( psz_title );
free( psz_name );
p_module = module_Need( p_playlist, "art finder", 0, VLC_FALSE ); p_module = module_Need( p_playlist, "art finder", 0, VLC_FALSE );
...@@ -176,14 +198,19 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item ) ...@@ -176,14 +198,19 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item )
msg_Dbg( p_playlist, "unable to find art" ); msg_Dbg( p_playlist, "unable to find art" );
/* Record this album */ /* Record this album */
if( input_item_GetArtist( p_item ) && input_item_GetAlbum( p_item ) ) if( psz_artist && psz_album )
{ {
playlist_album_t a; playlist_album_t a;
a.psz_artist = strdup( input_item_GetArtist(