]> git.sesse.net Git - vlc/commitdiff
Input access locking, part 2.
authorRafaël Carré <funman@videolan.org>
Sat, 18 Aug 2007 14:59:31 +0000 (14:59 +0000)
committerRafaël Carré <funman@videolan.org>
Sat, 18 Aug 2007 14:59:31 +0000 (14:59 +0000)
Fix [21193]

15 files changed:
include/vlc_input.h
modules/misc/notify/growl.c
modules/misc/notify/notify.c
modules/misc/playlist/m3u.c
modules/misc/playlist/xspf.c
modules/visualization/goom.c
src/input/control.c
src/input/es_out.c
src/input/input.c
src/input/meta.c
src/playlist/control.c
src/playlist/engine.c
src/playlist/item.c
src/text/strings.c
src/video_output/video_output.c

index 474cadd434406f2b145e4f925caabe4bc8fbf489..ee219660b5d8b545a98c688358d9db0552482d76 100644 (file)
   #error You are not libvlc or one of its plugins. You cannot include this file
 #endif
 
+#ifndef __USE_GNU
+#define __USE_GNU
+#endif
+#include <string.h>                                     /* strcasestr() */
+
 /* __ is need because conflict with <vlc/input.h> */
 #ifndef _VLC__INPUT_H
 #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
 {
     vlc_event_t event;
 
-    //vlc_mutex_lock( &p_i->lock );
+    vlc_mutex_lock( &p_i->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->lock ); 
+    vlc_mutex_unlock( &p_i->lock ); 
 
     /* Notify interested third parties */
     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
 
 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 );
     vlc_bool_t ret = meta && strcasestr( meta, psz );
-    //vlc_mutex_unlock( &p_i->lock );
+    vlc_mutex_unlock( &p_i->lock );
 
     return ret;
 }
@@ -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 )
 {
     char * psz = NULL;
-    //vlc_mutex_lock( &p_i->lock );
+    vlc_mutex_lock( &p_i->lock );
 
     if( !p_i->p_meta )
     {
-        //vlc_mutex_unlock( &p_i->lock );
+        vlc_mutex_unlock( &p_i->lock );
         return NULL;
     }
 
     if( 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;
 }
 
 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;
-    //vlc_mutex_unlock( &p_i->lock );
+    vlc_mutex_unlock( &p_i->lock );
     return psz_s;
 }
 
index a4629c46771eab2dab422f4ffa273d6ac638dbf9..c021b199e53852bb51e91b7db17e3f54ca8fcc4a 100644 (file)
@@ -124,21 +124,22 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
     if( !p_input ) return VLC_SUCCESS;
     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 ... */
+        free( psz_name );
         vlc_object_release( p_input );
         return VLC_SUCCESS;
     }
+    free( psz_name );
 
     /* Playing something ... */
-    psz_artist = input_item_GetArtist( input_GetItem(p_input) ) ?
-                  strdup( input_item_GetArtist( input_GetItem(p_input) ) ) :
-                  strdup( "" );
-    psz_album = input_item_GetAlbum( input_GetItem(p_input) ) ?
-                  strdup( input_item_GetAlbum( input_GetItem(p_input) ) ) :
-                  strdup("" );
-    psz_title = strdup( input_GetItem(p_input)->psz_name );
+    psz_artist = input_item_GetArtist( input_GetItem( p_input ) );
+    if( psz_artist == NULL ) psz_artist = strdup( "" );
+    psz_album = input_item_GetAlbum( input_GetItem( p_input ) ) ;
+    if( psz_album == NULL ) psz_album = strdup( "" );
+    psz_title = input_item_GetName( input_GetItem( p_input ) );
     if( psz_title == NULL ) psz_title = strdup( N_("(no title)") );
     snprintf( psz_tmp, GROWL_MAX_LENGTH, "%s %s %s",
               psz_title, psz_artist, psz_album );
index ff1d09e8ae0603dc85cf4d0816d6bc253bda715e..35651343fb64de44d8b27489fe8e24a03da0bba5 100644 (file)
@@ -150,13 +150,11 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
     }
 
     /* Playing something ... */
-    psz_artist = input_item_GetArtist( input_GetItem(p_input) ) ?
-                  strdup( input_item_GetArtist( input_GetItem(p_input) ) ) :
-                  strdup( _("no artist") );
-    psz_album = input_item_GetAlbum( input_GetItem(p_input) ) ?
-                  strdup( input_item_GetAlbum( input_GetItem(p_input) ) ) :
-                  strdup( _("no album") );
-    psz_title = strdup( input_GetItem(p_input)->psz_name );
+    psz_artist = input_item_GetArtist( input_GetItem( p_input ) );
+    if( psz_artist == NULL ) psz_artist = strdup( _("no artist") );
+    psz_album = input_item_GetAlbum( input_GetItem( p_input ) ) ;
+    if( psz_album == NULL ) psz_album = strdup( _("no album") );
+    psz_title = input_item_GetName( input_GetItem( p_input ) );
 
     vlc_object_release( p_input );
 
index eb7071af8a493a761cda34a9717bc0cfb316caa0..5d00746448e91f034b7f403a890fe8e4bf3c2afc 100644 (file)
@@ -65,13 +65,11 @@ static void DoChildren( playlist_t *p_playlist, playlist_export_t *p_export,
         assert( p_current->p_input->psz_uri );
 
         /* General info */
-        if( p_current->p_input->psz_name &&
-             strcmp( p_current->p_input->psz_uri,
-                     p_current->p_input->psz_name ) )
+        char *psz_name = input_item_GetName( p_current->p_input );
+        if( psz_name && strcmp( p_current->p_input->psz_uri, psz_name ) )
         {
-            char *psz_artist = input_item_GetArtist( p_current->p_input ) ?
-                               strdup( input_item_GetArtist( p_current->p_input ) ):
-                               strdup( "" );
+            char *psz_artist = input_item_GetArtist( p_current->p_input );
+            if( psz_artist == NULL ) psz_artist = strdup( "" );
             if( psz_artist && *psz_artist )
             {
                 /* write EXTINF with artist */
@@ -87,9 +85,9 @@ static void DoChildren( playlist_t *p_playlist, playlist_export_t *p_export,
                          (int)( p_current->p_input->i_duration/1000000 ),
                           p_current->p_input->psz_name);
             }
-            if( psz_artist )
-                free( psz_artist );
+            free( psz_artist );
         }
+        free( psz_name );
 
         /* VLC specific options */
         for( j = 0; j < p_current->p_input->i_options; j++ )
index 1c8a2016504fbff929e0ea16792fc8bef34a6963..2f078da8922456d828e8ad7d026478067ae09c49 100644 (file)
@@ -163,11 +163,10 @@ static void xspf_export_item( playlist_item_t *p_item, FILE *p_file,
     }
 
     /* -> the artist/creator */
-    psz = input_item_GetArtist( p_item->p_input ) ?
-                        strdup( input_item_GetArtist( p_item->p_input ) ):
-                        strdup( "" );
+    psz = input_item_GetArtist( p_item->p_input );
+    if( psz == NULL ) psz = strdup( "" );
     psz_temp = convert_xml_special_chars( psz );
-    if( psz ) free( psz );
+    free( psz );
     if( *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,
     free( psz_temp );
 
     /* -> the album */
-    psz = input_item_GetAlbum( p_item->p_input ) ?
-                        strdup( input_item_GetAlbum( p_item->p_input ) ):
-                        strdup( "" );
+    psz = input_item_GetAlbum( p_item->p_input );
+    if( psz == NULL ) psz = strdup( "" );
     psz_temp = convert_xml_special_chars( psz );
-    if( psz ) free( psz );
+    free( psz );
     if( *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,
     free( psz_temp );
 
     /* -> the track number */
-    psz = input_item_GetTrackNum( p_item->p_input ) ?
-                        strdup( input_item_GetTrackNum( p_item->p_input ) ):
-                        strdup( "" );
+    psz = input_item_GetTrackNum( p_item->p_input );
+    if( psz == NULL ) psz = strdup( "" );
     if( psz )
     {
         if( *psz )
         {
             fprintf( p_file, "\t\t\t<trackNum>%i</trackNum>\n", atoi( psz ) );
         }
-        free( psz );
     }
+    free( psz );
 
     /* -> the description */
-    psz = input_item_GetDescription( p_item->p_input ) ?
-                        strdup( input_item_GetDescription( p_item->p_input ) ):
-                        strdup( "" );
+    psz = input_item_GetDescription( p_item->p_input );
+    if( psz == NULL ) psz = strdup( "" );
     psz_temp = convert_xml_special_chars( psz );
-    if( psz ) free( psz );
+    free( psz );
     if( *psz_temp )
     {
         fprintf( p_file, "\t\t\t<annotation>%s</annotation>\n", psz_temp );
index 06481d7ca6dc2ea8d2af4873ccbc3c911024ac6d..1d9a859a1c4dd44b03c06c5322be01d5aeaf18c9 100644 (file)
@@ -416,12 +416,10 @@ static char *TitleGet( vlc_object_t *p_this )
 
     if( p_input )
     {
-        if( !EMPTY_STR( input_item_GetTitle( input_GetItem(p_input) ) ) )
-        {
-            psz_title = strdup( input_item_GetTitle( input_GetItem(p_input) ) );
-        }
-        else
+        psz_title = strdup( input_item_GetTitle( input_GetItem( p_input ) ) );
+        if( EMPTY_STR( psz_title ) )
         {
+            free( psz_title );
             char *psz = strrchr( input_GetItem(p_input)->psz_uri, '/' );
 
             if( psz )
index 47d5335679783395edcf8f2ecf8a40ce03af10f9..2e77f7cd8d4f1c94ce13118e889abca0a471cfcd 100644 (file)
@@ -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 ) );
                 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;
                 }
                 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 )
                 p_info = malloc( sizeof( info_t ) );
                 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;
                 }
 
index 04dd3f245011d6df4e40b165dff32bd3d2f50255..517a3787565d61f6703978f0431af9cef2baacd9 100644 (file)
@@ -487,12 +487,10 @@ static void EsOutProgramSelect( es_out_t *out, es_out_pgrm_t *p_pgrm )
     }
 
     /* Update now playing */
-    vlc_mutex_lock( &p_input->p->input.p_item->lock );
     input_item_SetNowPlaying( p_input->p->input.p_item,
                               p_pgrm->psz_now_playing );
     input_item_SetPublisher( p_input->p->input.p_item,
                              p_pgrm->psz_publisher );
-    vlc_mutex_unlock( &p_input->p->input.p_item->lock );
 
     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 )
     if( psz_provider )
     {
         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 );
-            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 );
     }
     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 )
     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 );
 
-    vlc_mutex_lock( &p_input->p->input.p_item->lock );
     if( p_pgrm == p_sys->p_pgrm )
         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 )
     {
index 2a8a53746d6dd9aa3563b43c25b0b5959f6fde53..fa1ae7d0b9b6b43f160af521cca0aefd05cbf05f 100644 (file)
@@ -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,
         _(VLC_META_INFO_CAT),
         _(VLC_META_NOW_PLAYING) );
-    vlc_mutex_lock( &p_item->lock );
     input_item_SetNowPlaying( p_item, NULL );
-    vlc_mutex_unlock( &p_item->lock );
 
     /* */
     if( p_input->b_preparsing )
@@ -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 )
 {
     input_item_t *p_item = p_input->p->input.p_item;
-    char * psz_saved_arturl = NULL;
-    const char * psz_arturl = NULL;
+    char * psz_arturl = NULL;
     char *psz_title = NULL;
     int i;
+    int i_arturl_event = VLC_FALSE;
 
     if( !p_meta )
         return;
 
+    psz_arturl = input_item_GetArtURL( p_item );
+
     vlc_mutex_lock( &p_item->lock );
     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 ) );
 
-    if( input_item_GetArtURL( p_item ) )
-        psz_saved_arturl = strdup( input_item_GetArtURL( p_item ) );
-
     vlc_meta_Merge( p_item->p_meta, p_meta );
 
-    if( psz_saved_arturl && *psz_saved_arturl )
-        input_item_SetArtURL( p_item, psz_saved_arturl );
+    if( psz_arturl && *psz_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 );
 
-    psz_arturl = input_item_GetArtURL( p_item );
     if( psz_arturl && !strncmp( psz_arturl, "attachment://", strlen("attachment") ) )
     {
         /* Don't look for art cover if sout
          * XXX It can change when sout has meta data support */
         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
             input_ExtractAttachmentAndCacheArt( p_input );
     }
+    free( psz_arturl );
     
     input_item_SetPreparsed( p_item, VLC_TRUE );
 
@@ -2550,6 +2553,16 @@ static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta )
     }
     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 )
     {
         input_Control( p_input, INPUT_SET_NAME, psz_title );
index e2c73ba58c1d14272f560ce50ddb60ddf99ef283..c1b2f5845fe3cd54c607f40308ba9284d2c7f828 100644 (file)
@@ -119,24 +119,33 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item )
 {
     int i_ret = VLC_EGENERIC;
     module_t *p_module;
+    char *psz_name, *psz_title, *psz_artist, *psz_album;
 
     if( !p_item->p_meta )
         return VLC_EGENERIC;
 
-    if(  !p_item->psz_name && !input_item_GetTitle( p_item ) &&
-        (!input_item_GetArtist( p_item ) || !input_item_GetAlbum( p_item )) )
+    psz_name = input_item_GetName( 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;
+    free( psz_name );
+    free( psz_title );
 
     /* 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 )
-            if( !strcmp( album.psz_artist, input_item_GetArtist( p_item ) ) &&
-                !strcmp( album.psz_album, input_item_GetAlbum( p_item ) ) )
+            if( !strcmp( album.psz_artist, psz_artist ) &&
+                !strcmp( album.psz_album, psz_album ) )
             {
                 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 */
+                free( psz_artist );
+                free( psz_album );
                 if( album.b_found )
                 {
                     /* Actually get URL from cache */
@@ -150,23 +159,36 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item )
             }
         FOREACH_END();
     }
+    free( psz_artist );
+    free( psz_album );
 
+    char *psz_arturl = input_item_GetArtURL( 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;
+    }
+    free( psz_arturl );
 
     PL_LOCK;
     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",
-             input_item_GetArtist( p_item ),  input_item_GetAlbum( p_item ) );
+             psz_artist, psz_album );
     }
     else
     {
         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 );
 
@@ -176,14 +198,19 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item )
         msg_Dbg( p_playlist, "unable to find art" );
 
     /* Record this album */
-    if( input_item_GetArtist( p_item ) && input_item_GetAlbum( p_item ) )
+    if( psz_artist && psz_album )
     {
         playlist_album_t a;
-        a.psz_artist = strdup( input_item_GetArtist( p_item ) );
-        a.psz_album = strdup( input_item_GetAlbum( p_item ) );
+        a.psz_artist = psz_artist;
+        a.psz_album = psz_album;
         a.b_found = (i_ret == VLC_EGENERIC ? VLC_FALSE : VLC_TRUE );
         ARRAY_APPEND( p_playlist->p_fetcher->albums, a );
     }
+    else
+    {
+        free( psz_artist );
+        free( psz_album );
+    }
 
     if( p_module )
         module_Unneed( p_playlist, p_module );
@@ -280,9 +307,9 @@ static char *ArtCacheCreateString( const char *psz )
 
 static int __input_FindArtInCache( vlc_object_t *p_obj, input_item_t *p_item )
 {
-    const char *psz_artist;
-    const char *psz_album;
-    const char *psz_title;
+    char *psz_artist;
+    char *psz_album;
+    char *psz_title;
     char psz_filename[MAX_PATH+1];
     int i;
     struct stat a;
@@ -293,9 +320,16 @@ static int __input_FindArtInCache( vlc_object_t *p_obj, input_item_t *p_item )
     psz_artist = input_item_GetArtist( p_item );
     psz_album = input_item_GetAlbum( p_item );
     psz_title = input_item_GetTitle( p_item );
-    if( !psz_title ) psz_title = p_item->psz_name;
+    if( !psz_title ) psz_title = input_item_GetName( p_item );
 
-    if( (!psz_artist || !psz_album) && !psz_title ) return VLC_EGENERIC;
+    if( !psz_title && ( !psz_album || !psz_artist ) )
+    {
+        free( psz_artist );
+        free( psz_album );
+        free( psz_title );
+        return VLC_EGENERIC;
+    }
+    free( psz_title );
 
     for( i = 0; i < 5; i++ )
     {
@@ -306,9 +340,13 @@ static int __input_FindArtInCache( vlc_object_t *p_obj, input_item_t *p_item )
         if( utf8_stat( psz_filename+7, &a ) == 0 )
         {
             input_item_SetArtURL( p_item, psz_filename );
+            free( psz_artist );
+            free( psz_album );
             return VLC_SUCCESS;
         }
     }
+    free( psz_artist );
+    free( psz_album );
     return VLC_EGENERIC;
 }
 
@@ -324,15 +362,23 @@ int input_DownloadAndCacheArt( playlist_t *p_playlist, input_item_t *p_item )
     char *psz_artist = NULL;
     char *psz_album = NULL;
     char *psz_title = NULL;
+    char *psz_artist_m, *psz_album_m, *psz_title_m, *psz_name_m, *psz_arturl_m;
     char *psz_type;
-    if( input_item_GetArtist( p_item ) )
-        psz_artist = ArtCacheCreateString( input_item_GetArtist( p_item ) );
-    if( input_item_GetAlbum( p_item ) )
-        psz_album = ArtCacheCreateString( input_item_GetAlbum( p_item ) );
-    if( input_item_GetTitle( p_item ) )
-        psz_title = ArtCacheCreateString( input_item_GetTitle( p_item ) );
-    else if( p_item->psz_name )
-        psz_title = ArtCacheCreateString( p_item->psz_name );
+
+    psz_artist_m = input_item_GetArtist( p_item );
+    psz_album_m = input_item_GetAlbum( p_item );
+    psz_title_m = input_item_GetTitle( p_item );
+    psz_name_m = input_item_GetName( p_item );
+
+    if( psz_artist_m ) psz_artist = ArtCacheCreateString( psz_artist_m );
+    if( psz_album_m ) psz_album = ArtCacheCreateString( psz_album_m );
+    if( psz_title_m ) psz_title = ArtCacheCreateString( psz_title_m );
+    else if( psz_name_m ) psz_title = ArtCacheCreateString( psz_name_m );
+
+    free( psz_artist_m );
+    free( psz_album_m );
+    free( psz_title_m );
+    free( psz_name_m );
 
     if( !psz_title && (!psz_artist || !psz_album) )
     {
@@ -342,9 +388,10 @@ int input_DownloadAndCacheArt( playlist_t *p_playlist, input_item_t *p_item )
         return VLC_EGENERIC;
     }
 
-    assert( !EMPTY_STR(input_item_GetArtURL( p_item )) );
+    psz_arturl_m = input_item_GetArtURL( p_item );
+    assert( !EMPTY_STR( psz_arturl_m ) );
 
-    psz_type = strrchr( input_item_GetArtURL( p_item ), '.' );
+    psz_type = strrchr( psz_arturl_m, '.' );
 
     /* */
     ArtCacheCreateName( p_playlist, psz_filename, psz_title /* Used only if needed*/,
@@ -358,13 +405,14 @@ int input_DownloadAndCacheArt( playlist_t *p_playlist, input_item_t *p_item )
     free( psz_album );
     free( psz_title );
 
-    if( !strncmp( input_item_GetArtURL( p_item ) , "APIC", 4 ) )
+    if( !strncmp( psz_arturl_m , "APIC", 4 ) )
     {
         msg_Warn( p_playlist, "APIC fetch not supported yet" );
+        free( psz_arturl_m );
         return VLC_EGENERIC;
     }
 
-    p_stream = stream_UrlNew( p_playlist, input_item_GetArtURL( p_item ) );
+    p_stream = stream_UrlNew( p_playlist, psz_arturl_m );
     if( p_stream )
     {
         uint8_t p_buffer[65536];
@@ -391,6 +439,7 @@ int input_DownloadAndCacheArt( playlist_t *p_playlist, input_item_t *p_item )
         input_item_SetArtURL( p_item, psz_filename );
         i_status = VLC_SUCCESS;
     }
+    free( psz_arturl_m );
     return i_status;
 }
 
@@ -402,6 +451,7 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input )
     char *psz_album = NULL;
     char *psz_title = NULL;
     char *psz_type = NULL;
+    char *psz_artist_m, *psz_album_m, *psz_title_m, *psz_name_m;
     char psz_filename[MAX_PATH+1];
     FILE *f;
     input_attachment_t *p_attachment;
@@ -411,9 +461,10 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input )
     /* TODO-fenrir merge input_ArtFind with download and make it set the flags FETCH
      * and then set it here to to be faster */
 
-    psz_arturl = strdup( input_item_GetArtURL( p_item ) );
+    psz_arturl = input_item_GetArtURL( p_item );
     if( !psz_arturl || strncmp( psz_arturl, "attachment://", strlen("attachment://") ) )
     {
+        free( psz_arturl );
         msg_Err( p_input, "internal input error with input_ExtractAttachmentAndCacheArt" );
         return;
     }
@@ -445,14 +496,20 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input )
         goto end;
     }
 
-    if( input_item_GetArtist( p_item ) )
-        psz_artist = ArtCacheCreateString( input_item_GetArtist( p_item ) );
-    if( input_item_GetAlbum( p_item ) )
-        psz_album = ArtCacheCreateString( input_item_GetAlbum( p_item ) );
-    if( input_item_GetTitle( p_item ) )
-        psz_title = ArtCacheCreateString( input_item_GetTitle( p_item ) );
-    else if( p_item->psz_name )
-        psz_title = ArtCacheCreateString( p_item->psz_name );
+    psz_artist_m = input_item_GetArtist( p_item );
+    psz_album_m = input_item_GetAlbum( p_item );
+    psz_title_m = input_item_GetTitle( p_item );
+    psz_name_m = input_item_GetName( p_item );
+
+    if( psz_artist_m ) psz_artist = ArtCacheCreateString( psz_artist_m );
+    if( psz_album_m ) psz_album = ArtCacheCreateString( psz_album_m );
+    if( psz_title_m ) psz_title = ArtCacheCreateString( psz_title_m );
+    else if( psz_name_m ) psz_title = ArtCacheCreateString( psz_name_m );
+
+    free( psz_artist_m );
+    free( psz_album_m );
+    free( psz_title_m );
+    free( psz_name_m );
 
     if( (!psz_artist || !psz_album ) && !psz_title )
         goto end;
index fa476bd040c40a472265bb7c52c9af0e35eb3be3..ee0f1f095a4ddd3ce17be76f6029cdd3e719f298 100644 (file)
@@ -454,16 +454,20 @@ int playlist_PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
     {
         vlc_bool_t b_has_art;
 
-        vlc_mutex_lock( &p_input->lock );
-        /* p_input->p_meta should not be null after a successfull CreateThread */
-        b_has_art = !EMPTY_STR( input_item_GetArtURL( p_input ) );
-        vlc_mutex_unlock( &p_input->lock );
+        char *psz_arturl, *psz_name;
+        psz_arturl = input_item_GetArtURL( p_input );
+        psz_name = input_item_GetName( p_input );
+
+        /* p_input->p_meta should not be null after a successfull CreateThread*/
+        b_has_art = !EMPTY_STR( psz_arturl );
 
         if( !b_has_art )
         {
-            PL_DEBUG( "requesting art for %s", p_input->psz_name );
+            PL_DEBUG( "requesting art for %s", psz_name );
             playlist_AskForArtEnqueue( p_playlist, p_input );
         }
+        free( psz_arturl );
+        free( psz_name );
     }
 
     val.i_int = p_input->i_id;
index db58d19f413866213396f9968cb183a91e5fb465..4807abcaf9a0c0c19b0db1928de1d309a5bb7ba3 100644 (file)
@@ -527,6 +527,8 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
              * This only checks for meta, not for art
              * \todo don't do this for things we won't get meta for, like vids
              */
+            char *psz_arturl = input_item_GetArtURL( p_current );
+            char *psz_name = input_item_GetName( p_current );
             if( !input_MetaSatisfied( p_playlist, p_current, &i_m, &i_o ) )
             {
                 preparse_item_t p;
@@ -542,11 +544,10 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
             }
             /* We already have all needed meta, but we need art right now */
             else if( p_playlist->p_fetcher->i_art_policy == ALBUM_ART_ALL &&
-                     EMPTY_STR( input_item_GetArtURL( p_current ) ) )
+                     EMPTY_STR( psz_arturl ) )
             {
                 preparse_item_t p;
-                PL_DEBUG("meta ok for %s, need to fetch art",
-                                                         p_current->psz_name );
+                PL_DEBUG("meta ok for %s, need to fetch art", psz_name );
                 p.p_item = p_current;
                 p.b_fetch_art = VLC_TRUE;
                 vlc_mutex_lock( &p_playlist->p_fetcher->object_lock );
@@ -559,10 +560,11 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
             else
             {
                 PL_DEBUG( "no fetch required for %s (art currently %s)",
-                          p_current->psz_name,
-                          input_item_GetArtURL( p_current ));
+                          psz_name, psz_arturl );
                 vlc_gc_decref( p_current );
             }
+            free( psz_name );
+            free( psz_arturl );
             PL_UNLOCK;
         }
         else
index 1638a9d89f130939b634a922433945a16ee47a91..35086a4002e631fae4e9ccfae0a1b83e7fed93a5 100644 (file)
@@ -657,17 +657,19 @@ static void GoAndPreparse( playlist_t *p_playlist, int i_mode,
         vlc_cond_signal( &p_playlist->object_wait );
     }
     /* Preparse if PREPARSE or SPREPARSE & not enough meta */
+    char *psz_artist = input_item_GetArtist( p_item_cat->p_input );
+    char *psz_album = input_item_GetAlbum( p_item_cat->p_input );
     if( p_playlist->b_auto_preparse &&
           (i_mode & PLAYLIST_PREPARSE ||
           ( i_mode & PLAYLIST_SPREPARSE &&
-            ( EMPTY_STR( input_item_GetArtist( p_item_cat->p_input ) ) ||
-            ( EMPTY_STR( input_item_GetAlbum( p_item_cat->p_input ) ) ) )
+            ( EMPTY_STR( psz_artist ) || ( EMPTY_STR( psz_album ) ) )
           ) ) )
         playlist_PreparseEnqueue( p_playlist, p_item_cat->p_input );
     /* If we already have it, signal it */
-    else if( !EMPTY_STR( input_item_GetArtist( p_item_cat->p_input ) ) &&
-             !EMPTY_STR( input_item_GetAlbum( p_item_cat->p_input ) ) )
+    else if( !EMPTY_STR( psz_artist ) && !EMPTY_STR( psz_album ) )
         input_item_SetPreparsed( p_item_cat->p_input, VLC_TRUE );
+    free( psz_artist );
+    free( psz_album );
 }
 
 /* Add the playlist item to the requested node and fire a notification */
index 1f9aea3d99691e078ab2d6e9631f73e83ed24598..a63c2fb972cf7ff8d97657dadd2bc07660253da7 100644 (file)
@@ -638,18 +638,23 @@ char *str_format_time( const char *tformat )
 }
 
 #define INSERT_STRING( check, string )                              \
-                    if( check && string )                           \
+                    if( check )                                     \
                     {                                               \
-                        int len = strlen( string );                 \
-                        dst = realloc( dst,                         \
-                                       i_size = i_size + len + 1 ); \
-                        strncpy( d, string, len+1 );                \
-                        d += len;                                   \
-                    }                                               \
-                    else                                            \
-                    {                                               \
-                        *d = '-';                                   \
-                        d++;                                        \
+                        psz_meta = string;                          \
+                        if( string )                                \
+                        {                                           \
+                            int len = strlen( psz_meta );           \
+                            dst = realloc( dst,                     \
+                                   i_size = i_size + len + 1 );     \
+                            strncpy( d, psz_meta, len+1 );          \
+                            d += len;                               \
+                            free( psz_meta );                       \
+                        }                                           \
+                        else                                        \
+                        {                                           \
+                                *d = '-';                           \
+                                d++;                                \
+                        }                                           \
                     }
 char *__str_format_meta( vlc_object_t *p_object, const char *string )
 {
@@ -681,6 +686,7 @@ char *__str_format_meta( vlc_object_t *p_object, const char *string )
         {
             switch( *s )
             {
+                char *psz_meta; /* used by INSERT_STRING */
                 case 'a':
                     INSERT_STRING( p_item, input_item_GetArtist(p_item) );
                     break;
index 07d7f1ca9f17719cee1dd4d9683b6e1534e5a3dc..0c2d63a003149d3f569c522bfd75bcae2cc6020c 100644 (file)
@@ -1642,10 +1642,14 @@ static void DisplayTitleOnOSD( vout_thread_t *p_vout )
     {
         i_now = mdate();
         i_stop = i_now + (mtime_t)(p_vout->i_title_timeout * 1000);
-        if( !EMPTY_STR(input_item_GetNowPlaying(input_GetItem(p_input))) )
+        char *psz_nowplaying = 
+            input_item_GetNowPlaying( input_GetItem( p_input ) );
+        char *psz_artist = input_item_GetArtist( input_GetItem( p_input ) );
+        char *psz_name = input_item_GetName( input_GetItem( p_input ) );
+        if( !EMPTY_STR( psz_nowplaying ) )
         {
             vout_ShowTextAbsolute( p_vout, DEFAULT_CHAN,
-                                   input_item_GetNowPlaying(input_GetItem(p_input)), NULL,
+                                   psz_nowplaying, NULL,
                                    p_vout->i_title_position,
                                    30 + p_vout->fmt_in.i_width
                                       - p_vout->fmt_in.i_visible_width
@@ -1653,17 +1657,14 @@ static void DisplayTitleOnOSD( vout_thread_t *p_vout )
                                    20 + p_vout->fmt_in.i_y_offset,
                                    i_now, i_stop );
         }
-        else if( !EMPTY_STR(input_item_GetArtist(input_GetItem(p_input))) )
+        else if( !EMPTY_STR( psz_artist ) )
         {
             char *psz_string = NULL;
 
-            psz_string = malloc( strlen(input_GetItem(p_input)->psz_name) ) +
-                    strlen( input_item_GetArtist(input_GetItem(p_input)) );
+            psz_string = malloc( strlen( psz_name ) + strlen( psz_artist ) );
             if( psz_string )
             {
-                sprintf( psz_string, "%s - %s",
-                         input_GetItem(p_input)->psz_name,
-                         input_item_GetArtist(input_GetItem(p_input)) );
+                sprintf( psz_string, "%s - %s", psz_name, psz_artist );
 
                 vout_ShowTextAbsolute( p_vout, DEFAULT_CHAN,
                                        psz_string, NULL,
@@ -1679,7 +1680,7 @@ static void DisplayTitleOnOSD( vout_thread_t *p_vout )
         else
         {
             vout_ShowTextAbsolute( p_vout, DEFAULT_CHAN,
-                                   input_GetItem(p_input)->psz_name, NULL,
+                                   psz_name, NULL,
                                    p_vout->i_title_position,
                                    30 + p_vout->fmt_in.i_width
                                       - p_vout->fmt_in.i_visible_width
@@ -1688,5 +1689,8 @@ static void DisplayTitleOnOSD( vout_thread_t *p_vout )
                                    i_now, i_stop );
         }
         vlc_object_release( p_input );
+        free( psz_artist );
+        free( psz_name );
+        free( psz_nowplaying );
     }
 }