]> git.sesse.net Git - vlc/commitdiff
Input access locking, part 3 (final).
authorRafaël Carré <funman@videolan.org>
Wed, 22 Aug 2007 20:19:23 +0000 (20:19 +0000)
committerRafaël Carré <funman@videolan.org>
Wed, 22 Aug 2007 20:19:23 +0000 (20:19 +0000)
Enforce access to input_item_t through input_item_{G,S}et*()
Unlock mutexes before calling these functions
Free strings returned by input_item_Get*()

New functions added:

char * input_item_GetURI( input_item_t  * )
void input_item_SetURI( input_item_t * , char * )

mtime_t input_item_GetDuration( input_item_t * )
void input_item_SetDuration( input_item_t * , mtime_t )

to access input_item_t->psz_uri and input_item_t->i_duration

55 files changed:
include/vlc_input.h
modules/access/cdda.c
modules/access/cdda/info.c
modules/access/http.c
modules/access_output/http.c
modules/codec/cmml/history.c
modules/codec/cmml/intf.c
modules/control/dbus.c
modules/control/hotkeys.c
modules/control/http/macro.c
modules/control/http/rpn.c
modules/control/http/util.c
modules/control/rc.c
modules/demux/playlist/asx.c
modules/demux/playlist/b4s.c
modules/demux/playlist/podcast.c
modules/demux/playlist/xspf.c
modules/gui/macosx/bookmarks.m
modules/gui/macosx/playlist.m
modules/gui/macosx/playlistinfo.m
modules/gui/macosx/vout.m
modules/gui/macosx/wizard.m
modules/gui/ncurses.c
modules/gui/qt4/components/infopanels.cpp
modules/gui/qt4/input_manager.cpp
modules/gui/qt4/playlist_model.cpp
modules/gui/wince/iteminfo.cpp
modules/gui/wince/playlist.cpp
modules/gui/wxwidgets/dialogs/bookmarks.cpp
modules/gui/wxwidgets/dialogs/infopanels.cpp
modules/gui/wxwidgets/dialogs/iteminfo.cpp
modules/gui/wxwidgets/dialogs/playlist.cpp
modules/gui/wxwidgets/dialogs/wizard.cpp
modules/gui/wxwidgets/playlist_manager.cpp
modules/meta_engine/folder.c
modules/meta_engine/taglib.cpp
modules/misc/audioscrobbler.c
modules/misc/notify/growl.c
modules/misc/notify/msn.c
modules/misc/notify/notify.c
modules/misc/notify/xosd.c
modules/misc/playlist/m3u.c
modules/misc/playlist/xspf.c
modules/misc/rtsp.c
modules/services_discovery/sap.c
modules/visualization/galaktos/plugin.c
modules/visualization/goom.c
src/control/media_descriptor.c
src/control/mediacontrol_core.c
src/input/input.c
src/input/vlm.c
src/playlist/item.c
src/playlist/sort.c
src/text/strings.c
src/video_output/video_output.c

index 6f15034a605954414ad8aa12e13e1bc11be5e95f..508f063ae01ebfa62024559c6d4ce477395612ab 100644 (file)
@@ -138,7 +138,7 @@ static inline void input_ItemCopyOptions( input_item_t *p_parent,
     }
 }
 
-static inline void input_ItemSetName( input_item_t *p_item, const char *psz_name )
+static inline void input_item_SetName( input_item_t *p_item, const char *psz_name )
 {
     if( p_item->psz_name ) free( p_item->psz_name );
     p_item->psz_name = strdup( psz_name );
@@ -272,6 +272,38 @@ static inline char * input_item_GetName( input_item_t * p_i )
     return psz_s;
 }
 
+static inline char * input_item_GetURI( input_item_t * p_i )
+{
+    vlc_mutex_lock( &p_i->lock );
+    char *psz_s = p_i->psz_uri ? strdup( p_i->psz_uri ) : NULL;
+    vlc_mutex_unlock( &p_i->lock );
+    return psz_s;
+}
+
+static inline void input_item_SetURI( input_item_t * p_i, char * psz_uri )
+{
+    vlc_mutex_lock( &p_i->lock );
+    if( p_i->psz_uri ) free( p_i->psz_uri );
+        p_i->psz_uri = strdup( psz_uri );
+    vlc_mutex_unlock( &p_i->lock );
+}
+
+static inline mtime_t input_item_GetDuration( input_item_t * p_i )
+{
+    vlc_mutex_lock( &p_i->lock );
+    mtime_t i_duration = p_i->i_duration;
+    vlc_mutex_unlock( &p_i->lock );
+    return i_duration;
+}
+
+static inline void input_item_SetDuration( input_item_t * p_i, mtime_t i_duration )
+{
+    vlc_mutex_lock( &p_i->lock );
+    p_i->i_duration = i_duration;
+    vlc_mutex_unlock( &p_i->lock );
+    return;
+}
+
 static inline void input_item_SetPreparsed( input_item_t *p_i, vlc_bool_t preparsed )
 {
     if( !p_i->p_meta )
index 6c51cb234a1ceb53aecfb6bed262b5abe8255cbe..b246ad67c781a4dcbec171c16d4aa503f42b3a5b 100644 (file)
@@ -412,9 +412,7 @@ static int GetTracks( access_t *p_access,
     }
 
     p_item_in_category = playlist_ItemToNode( p_playlist, p_parent, VLC_FALSE );
-    vlc_mutex_lock( &p_playlist->object_lock );
     playlist_ItemSetName( p_parent, "Audio CD" );
-    vlc_mutex_unlock( &p_playlist->object_lock );
     var_SetInteger( p_playlist, "item-change", p_parent->p_input->i_id );
 
 #ifdef HAVE_LIBCDDB
@@ -424,9 +422,7 @@ static int GetTracks( access_t *p_access,
         if( cddb_disc_get_title( p_sys->p_disc ) )
         {
             const char *psz_name = cddb_disc_get_title( p_sys->p_disc );
-            vlc_mutex_lock( &p_playlist->object_lock );
             playlist_ItemSetName( p_parent, psz_name );
-            vlc_mutex_unlock( &p_playlist->object_lock );
             var_SetInteger( p_playlist, "item-change",
                             p_parent->p_input->i_id );
         }
index a3bc1779c2df5c43f5ab126aa23c1a20332be625..3ab6e0d0dcbe5d2dc350da5e59519907786c9320 100644 (file)
@@ -840,7 +840,8 @@ CDDACreatePlaylistItem( const access_t *p_access, cdda_data_t *p_cdda,
                psz_mrl, psz_title, (long int) i_mduration / 1000000 );
 
     p_child = playlist_ItemNew( p_playlist, psz_mrl, psz_title );
-    input_GetItem(p_child->p_input)->i_duration = (mtime_t) i_mduration;
+    input_item_SetDuration( input_GetItem( p_child->p_input ),
+            (mtime_t) i_mduration );
     free(psz_mrl);
     free(psz_title);
 
@@ -973,9 +974,10 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
        if( p_item ) 
        {
            CDDAAddMetaToItem( p_access, p_cdda, p_item, i_track, VLC_FALSE );
-           p_item->p_input->i_duration = (mtime_t) i_track_frames 
-             * (CLOCK_FREQ / CDIO_CD_FRAMES_PER_SEC);
-           p_item->p_input->psz_uri = CDDAFormatMRL( p_access, i_track );
+           input_item_SetDuration( p_item->p_input, (mtime_t) i_track_frames 
+             * (CLOCK_FREQ / CDIO_CD_FRAMES_PER_SEC) );
+            input_item_SetURI( p_item->p_input, 
+                    CDDAFormatMRL( p_access, i_track ) );
        }
        
         p_cdda->i_titles = 1;
@@ -1016,9 +1018,10 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
        p_access->info.i_update |= INPUT_UPDATE_TITLE|INPUT_UPDATE_SIZE;
        if( p_item )
         {
-           p_item->p_input->i_duration = (mtime_t)
-             p_access->info.i_size * (CLOCK_FREQ / CDIO_CD_FRAMES_PER_SEC) ;
-           p_item->p_input->psz_uri    = CDDAFormatMRL( p_access, p_cdda->i_track );
+           input_item_SetDuration( p_item->p_input, (mtime_t) p_access->info.i_size
+                    * (CLOCK_FREQ / CDIO_CD_FRAMES_PER_SEC) );
+            input_item_SetURI( p_item->p_input,
+                    CDDAFormatMRL( p_access, p_cdda->i_track ) );
        }
     }
     
index 33c15e8abedf0044282cb81573748a701d6fedef..040044e71e20c4b1b6bf8cdb02c877866e7123a3 100644 (file)
@@ -335,12 +335,9 @@ connect:
         PL_LOCK;
 
         p_input_item = p_playlist->status.p_item->p_input;
-        vlc_mutex_lock( &p_input_item->lock );
-        free( p_input_item->psz_uri );
+        input_item_SetURI( p_input_item, p_sys->psz_location );
         free( p_access->psz_path );
-        p_input_item->psz_uri = strdup( p_sys->psz_location );
         p_access->psz_path = strdup( p_sys->psz_location );
-        vlc_mutex_unlock( &p_input_item->lock );
 
         PL_UNLOCK;
         pl_Release( p_access );
index feb9f05a4683928877d4df36c4c00e68b06a600b..bf44c68633a9dbbaf8d28db98bbe120405351852 100644 (file)
@@ -298,12 +298,15 @@ static int Open( vlc_object_t *p_this )
         char                *psz_txt, *psz_name;
         playlist_t          *p_playlist = pl_Yield( p_access );
 
-        psz_name = strrchr( p_playlist->status.p_item->p_input->psz_uri,
-                            DIRECTORY_SEPARATOR );
+        char *psz_uri = input_item_GetURI( p_playlist->status.p_item->p_input );
+        char *psz_newuri = psz_uri;
+        psz_name = strrchr( psz_newuri, DIRECTORY_SEPARATOR );
         if( psz_name != NULL ) psz_name++;
-        else psz_name = p_playlist->status.p_item->p_input->psz_uri;
+        else psz_name = psz_newuri;
 
-        asprintf( &psz_txt, "path=%s", psz_file_name );
+        asprintf( &psz_txt, "path=%s", psz_name );
+
+        free( psz_uri );
 
         p_sys->p_bonjour = bonjour_start_service( (vlc_object_t *)p_access,
                                     strcmp( p_access->psz_access, "https" )
index f1cb6d735ed79b814243b40003de222b197659dc..25a8effbe2f4249ac67db77be9ab5a9ef80f45e7 100644 (file)
@@ -113,8 +113,12 @@ static void history_Dump( history_t *p_history )
         if( p_item == NULL )
             fprintf( stderr, "HISTORY: [%d] NULL\n", i );
         else
+        {
+            char *psz_uri = input_item_GetURI( p_item );
             fprintf( stderr, "HISTORY: [%d] %p (%p->%s)\n", i, p_item,
-                     p_item->psz_uri, p_item->psz_uri );
+                     psz_uri, psz_uri );
+            free( psz_uri );
+        }
     }
 }
 
index b9f583c3e420959066fb7c4736e5dd1da3ed9233..fa45e66d25d3ea5bca6b30a350b7e999f7848334 100644 (file)
@@ -460,13 +460,13 @@ static void FollowAnchor ( intf_thread_t *p_intf )
 
         /* Get new URL */
         p_current_item = p_playlist->status.p_item;
+        char *psz_uri = input_item_GetURI( p_current_item->p_input );
 #ifdef CMML_INTF_DEBUG
-        msg_Dbg( p_intf, "Current playlist item URL is \"%s\"",
-                p_current_item->input.psz_uri );
+        msg_Dbg( p_intf, "Current playlist item URL is \"%s\"", psz_uri );
 #endif
 
-        psz_uri_to_load = XURL_Concat( p_current_item->p_input->psz_uri,
-                                       psz_url );
+        psz_uri_to_load = XURL_Concat( psz_uri, psz_url );
+        free( psz_uri );
 
 #ifdef CMML_INTF_DEBUG
         msg_Dbg( p_intf, "URL to load is \"%s\"", psz_uri_to_load );
@@ -550,7 +550,9 @@ char *GetTimedURLFromPlaylistItem( intf_thread_t *p_intf,
     char *psz_seconds = NULL;
     int i_seconds;
 
-    psz_url = XURL_GetWithoutFragment( p_current_item->input->psz_uri );
+    char *psz_uri = input_item_GetURI( p_current_item->p_input );
+    psz_url = XURL_GetWithoutFragment( psz_uri );
+    free( psz_uri );
 
     /* Get current time as a string */
     if( XURL_IsFileURL( psz_url ) == VLC_TRUE )
@@ -576,7 +578,7 @@ char *GetTimedURLFromPlaylistItem( intf_thread_t *p_intf,
     p = GetTimedURIFragmentForTime; /* unused */
     p = GetCurrentTimeInSeconds;    /* unused */
 
-    return strdup( p_current_item->p_input->psz_uri );
+    return input_item_GetURI( p_current_item->p_input );
 #endif
 }
 
index 6ee354b3d42209fdfbdaa664aa242bff17187503..7dc1aa1a2e6b5c808e0a31c5266ce0bf8316bc5a 100644 (file)
@@ -877,8 +877,7 @@ static int GetInputMeta( input_item_t* p_input,
     DBusMessageIter dict, dict_entry, variant;
     /* We need the track length to be expressed in seconds
      * instead of milliseconds */
-    dbus_int64_t i_length = (p_input->i_duration / 1000);
-
+    dbus_int64_t i_length = ( input_item_GetDuration( p_input ) / 1000 );
 
     const char* ppsz_meta_items[] = 
     {
@@ -907,10 +906,13 @@ static int GetInputMeta( input_item_t* p_input,
     ADD_VLC_META_STRING( 13, Publisher );
     ADD_VLC_META_STRING( 14, EncodedBy );
     ADD_VLC_META_STRING( 15, ArtURL );
-    ADD_VLC_META_STRING( 16, TrackID ); 
+    ADD_VLC_META_STRING( 16, TrackID );
 
+    vlc_mutex_lock( &p_input->lock );
     ADD_META( 17, DBUS_TYPE_INT32, p_input->p_meta->i_status );
-    ADD_META( 18, DBUS_TYPE_STRING, p_input->psz_uri );
+    vlc_mutex_unlock( &p_input->lock );
+
+    ADD_VLC_META_STRING( 18, URI );
     ADD_META( 19, DBUS_TYPE_INT64, i_length );
 
     dbus_message_iter_close_container( args, &dict );
index f3a25c88ca3a9e2c91222f3753b3126c805e49f7..5e87f555a7e1bf14e13a69c588dfe5e22ed5a27c 100644 (file)
@@ -890,12 +890,16 @@ static void PlayBookmark( intf_thread_t *p_intf, int i_num )
     char *psz_bookmark = strdup( val.psz_string );
     PL_LOCK;
     FOREACH_ARRAY( playlist_item_t *p_item, p_playlist->items )
-        if( !strcmp( psz_bookmark, p_item->p_input->psz_uri ) )
+        char *psz_uri = input_item_GetURI( p_item->p_input );
+        if( !strcmp( psz_bookmark, psz_uri ) )
         {
+            free( psz_uri );
             playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE,
                               NULL, p_item );
             break;
         }
+        else
+            free( psz_uri );
     FOREACH_END();
     PL_UNLOCK;
     vlc_object_release( p_playlist );
@@ -910,10 +914,10 @@ static void SetBookmark( intf_thread_t *p_intf, int i_num )
                 VLC_VAR_STRING|VLC_VAR_DOINHERIT );
     if( p_playlist->status.p_item )
     {
-        config_PutPsz( p_intf, psz_bookmark_name,
-                       p_playlist->status.p_item->p_input->psz_uri);
-        msg_Info( p_intf, "setting playlist bookmark %i to %s", i_num,
-                  p_playlist->status.p_item->p_input->psz_uri);
+        char *psz_uri = input_item_GetURI( p_playlist->status.p_item->p_input );
+        config_PutPsz( p_intf, psz_bookmark_name, psz_uri);
+        msg_Info( p_intf, "setting playlist bookmark %i to %s", i_num, psz_uri);
+        free( psz_uri );
         config_SaveConfigFile( p_intf, "hotkeys" );
     }
     pl_Release( p_intf );
index d220c0ad113891f6c8eb2d16b5600b79380272a1..89ed3c102a114f8cfe113f0868376589d6d9860c 100644 (file)
@@ -335,8 +335,8 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
 
                     p_input = E_(MRLParse)( p_intf, mrl, psz_name );
 
-                    if( !p_input || !p_input->psz_uri ||
-                        !*p_input->psz_uri )
+                    char *psz_uri = input_item_GetURI( p_input );
+                    if( !p_input || !psz_uri || !*psz_uri )
                     {
                         msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );
                     }
@@ -347,6 +347,7 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
                                      VLC_FALSE);
                         msg_Dbg( p_intf, "requested mrl add: %s", mrl );
                     }
+                    free( psz_uri );
 
                     break;
                 }
index dc393e654cf169cc82ff65104190e85b6db6f261..389fd1d7297958584d380f1b4cfbf83024c56d24 100644 (file)
@@ -848,7 +848,8 @@ void E_(EvaluateRPN)( intf_thread_t *p_intf, mvar_t  *vars,
 
             p_input = E_(MRLParse)( p_intf, mrl, psz_name );
 
-            if( !p_input || !p_input->psz_uri || !*p_input->psz_uri )
+            char *psz_uri = input_item_GetURI( p_input );
+            if( !p_input || !psz_uri || !*psz_uri )
             {
                 i_ret = VLC_EGENERIC;
                 msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );
@@ -860,6 +861,7 @@ void E_(EvaluateRPN)( intf_thread_t *p_intf, mvar_t  *vars,
                                    VLC_FALSE);
                 msg_Dbg( p_intf, "requested mrl add: %s", mrl );
             }
+            free( psz_uri );
             E_(SSPushN)( st, i_ret );
 
             free( mrl );
index f1d315cff871e9a9cf23bbb901011e21b67f308c..908a4005688b23f74f2391fc62cc5f7b54bfb224 100644 (file)
@@ -420,7 +420,7 @@ void E_(PlaylistListNode)( intf_thread_t *p_intf, playlist_t *p_pl,
         if( p_node->i_children == -1 )
         {
             char value[512];
-            char *psz;
+            char *psz, psz_utf8;
             mvar_t *itm = E_(mvar_New)( name, "set" );
 
             if( p_pl->status.p_item && p_node &&
@@ -437,12 +437,16 @@ void E_(PlaylistListNode)( intf_thread_t *p_intf, playlist_t *p_pl,
             sprintf( value, "%d", p_node->i_id );
             E_(mvar_AppendNewVar)( itm, "index", value );
 
-            psz = E_(FromUTF8)( p_intf, p_node->p_input->psz_name );
+            psz_utf8 = input_item_GetName( p_node->p_input );
+            psz = E_(FromUTF8)( p_intf, psz_utf8 );
             E_(mvar_AppendNewVar)( itm, "name", psz );
+            free( psz_utf8 );
             free( psz );
 
-            psz = E_(FromUTF8)( p_intf, p_node->p_input->psz_uri );
+            psz_utf8 = input_item_GetURI( p_node->p_input );
+            psz = E_(FromUTF8)( p_intf, psz_utf8 );
             E_(mvar_AppendNewVar)( itm, "uri", psz );
+            free( psz_utf8 );
             free( psz );
 
             sprintf( value, "Item");
@@ -460,7 +464,8 @@ void E_(PlaylistListNode)( intf_thread_t *p_intf, playlist_t *p_pl,
                 E_(mvar_AppendNewVar)( itm, "ro", "rw" );
             }
 
-            sprintf( value, "%ld", (long)p_node->p_input->i_duration );
+            sprintf( value, "%ld",
+                    (long) input_item_GetDuration( p_node->p_input ) );
             E_(mvar_AppendNewVar)( itm, "duration", value );
 
             E_(mvar_AppendVar)( s, itm );
index 2866fc1662a2e7c61ca2a3b4cdcaa00d784bc527..194facb050a140f61a69cc8f69340b089165b92c 100644 (file)
@@ -497,8 +497,10 @@ static void Run( intf_thread_t *p_intf )
             {
                 if( !p_input->b_dead || !p_input->b_die )
                 {
-                    msg_rc( STATUS_CHANGE "( new input: %s )",
-                            input_GetItem(p_input)->psz_uri );
+                    char *psz_uri =
+                            input_item_Get_URI( input_GetItem( p_input ) );
+                    msg_rc( STATUS_CHANGE "( new input: %s )", psz_uri );
+                    free( psz_uri );
                     msg_rc( STATUS_CHANGE "( audio volume: %d )",
                             config_GetInt( p_intf, "volume" ));
                 }
@@ -1396,8 +1398,10 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
         if( p_playlist->p_input )
         {
             /* Replay the current state of the system. */
-            msg_rc( STATUS_CHANGE "( new input: %s )",
-                    input_GetItem(p_playlist->p_input)->psz_uri );
+            char *psz_uri =
+                    input_item_GetURI( input_GetItem( p_playlist->p_input ) );
+            msg_rc( STATUS_CHANGE "( new input: %s )", psz_uri );
+            free( psz_uri );
             msg_rc( STATUS_CHANGE "( audio volume: %d )",
                     config_GetInt( p_intf, "volume" ));
 
index 650f11cd8b050ebd0f991b74c8dd30f09739486f..789e54c7570dcea6d9e8c620b5a62f56e04e68fb 100644 (file)
@@ -665,13 +665,11 @@ static int Demux( demux_t *p_demux )
             }
             else if( !strncasecmp( psz_parse, "</ASX", 5 ) )
             {
-                vlc_mutex_lock( &p_current_input->lock );
                 if( psz_title_asx ) input_item_SetTitle( p_current_input, psz_title_asx );
                 if( psz_artist_asx ) input_item_SetArtist( p_current_input, psz_artist_asx );
                 if( psz_copyright_asx ) input_item_SetCopyright( p_current_input, psz_copyright_asx );
                 if( psz_moreinfo_asx ) input_item_SetURL( p_current_input, psz_moreinfo_asx );
                 if( psz_abstract_asx ) input_item_SetDescription( p_current_input, psz_abstract_asx );
-                vlc_mutex_unlock( &p_current_input->lock );
                 FREENULL( psz_base_asx );
                 FREENULL( psz_title_asx );
                 FREENULL( psz_artist_asx );
index 411006e24a9a6adbac31354fd006603befb8e3b9..fc5db9c9cb2add462ade6e3292d46cef19648b51 100644 (file)
@@ -155,7 +155,7 @@ static int Demux( demux_t *p_demux )
         }
         else if( !strcmp( psz_name, "label" ) )
         {
-            input_ItemSetName( p_current_input, psz_value );
+            input_item_SetName( p_current_input, psz_value );
         }
         else
         {
index f2541696b0f118917b22a9369ad258b191a19291..c74da0ecb4f0ba14b610b6eabe015fee2c47947d 100644 (file)
@@ -229,7 +229,7 @@ static int Demux( demux_t *p_demux )
                 else if( b_item == VLC_FALSE && b_image == VLC_FALSE
                          && !strcmp( psz_elname, "title" ) )
                 {
-                    input_ItemSetName( p_current_input, psz_text );
+                    input_item_SetName( p_current_input, psz_text );
                 }
 #define ADD_GINFO( info, name ) \
     else if( !b_item && !b_image && !strcmp( psz_elname, name ) ) \
index 3921e7f42cb687d18c4d090bd74417ad8503a52c..c33a4197ae40a613b36131d69f45aa8a01b29113 100644 (file)
@@ -628,7 +628,7 @@ static vlc_bool_t set_item_info SIMPLE_INTERFACE
     else if( !strcmp( psz_name, "duration" ) )
     {
         long i_num = atol( psz_value );
-        p_input->i_duration = i_num*1000;
+        input_item_SetDuration( p_input, (mtime_t) i_num*1000 );
     }
     else if( !strcmp( psz_name, "annotation" ) )
     {
index 589f79ea1a033b6fbf2db35b961d879afbb55ea3..07fd22bc81a7827fcf519df192ae60f30cb13d15 100644 (file)
@@ -342,13 +342,14 @@ static VLCBookmarks *_o_sharedInstance = nil;
     }
     msg_Dbg(p_intf, "calling wizard");
 
+    char *psz_uri = input_item_GetURI( input_GetItem( p_input ) );
     [[[VLCMain sharedInstance] getWizard] initWithExtractValuesFrom:
             [[NSNumber numberWithInt:
             (pp_bookmarks[i_first]->i_time_offset/1000000)] stringValue]
             to: [[NSNumber numberWithInt:
             (pp_bookmarks[i_second]->i_time_offset/1000000)] stringValue]
-            ofItem: [NSString stringWithUTF8String:
-            input_GetItem(p_input)->psz_uri]];
+            ofItem: [NSString stringWithUTF8String: psz_uri]];
+    free( psz_uri );
     vlc_object_release( p_input );
     msg_Dbg(p_intf, "released input");
 }
index 2d3bb978585f61ec1e98cb50f47aad9e726bc60d..115d3232d3368748787ba8d1abd42d1a174426fb 100644 (file)
         else if( [[o_tc identifier] isEqualToString:@"3"] )
         {
             char psz_duration[MSTRTIME_MAX_SIZE];
-            mtime_t dur = p_item->p_input->i_duration;
+            mtime_t dur = input_item_GetDuration( p_item->p_input );
             if( dur != -1 )
             {
                 secstotimestr( psz_duration, dur/1000000 );
index d777f87c1ca19b3c10adbab179ed358fc9ddf596..3bda2f7ba6cbcfa0e63e2babfbacbf0e30edbbc7 100644 (file)
     /* check whether our item is valid, because we would crash if not */
     if(! [self isItemInPlaylist: p_item] ) return;
 
-    vlc_mutex_lock( &p_item->p_input->lock );
-
     /* fill uri info */
-    if( p_item->p_input->psz_uri )
+    char *psz_uri = input_item_GetURI( p_item->p_input );
+    if( psz_uri )
     {
         [o_uri_txt setStringValue:
-            ([NSString stringWithUTF8String:p_item->p_input->psz_uri] == nil ) ?
-            [NSString stringWithCString:p_item->p_input->psz_uri] :
-            [NSString stringWithUTF8String:p_item->p_input->psz_uri]];
+            ([NSString stringWithUTF8String:psz_uri] == nil ) ?
+            [NSString stringWithCString:psz_uri] :
+            [NSString stringWithUTF8String:psz_uri]];
     }
+    free( psz_uri );
 
-    vlc_mutex_unlock( &p_item->p_input->lock );
+#define SET( foo, bar ) \
+    char *psz_##foo = input_item_Get##bar ( p_item->p_input ); \
+    [set setMeta: psz_##foo forlabel: o_##foo##_txt]; \
+    free( psz_foo );
 
     /* fill the other fields */
-    [self setMeta: input_item_GetTitle( p_item->p_input )      forLabel: o_title_txt];
-    [self setMeta: input_item_GetArtist( p_item->p_input )     forLabel: o_author_txt];
-    [self setMeta: input_item_GetAlbum( p_item->p_input )      forLabel: o_collection_txt];
-    [self setMeta: input_item_GetTrackNum( p_item->p_input )   forLabel: o_seqNum_txt];
-    [self setMeta: input_item_GetGenre( p_item->p_input )      forLabel: o_genre_txt];
-    [self setMeta: input_item_GetCopyright( p_item->p_input )  forLabel: o_copyright_txt];
-    [self setMeta: input_item_GetRating( p_item->p_input )     forLabel: o_rating_txt];
-    [self setMeta: input_item_GetPublisher( p_item->p_input )  forLabel: o_publisher_txt];
-    [self setMeta: input_item_GetNowPlaying( p_item->p_input ) forLabel: o_nowPlaying_txt];
-    [self setMeta: input_item_GetLanguage( p_item->p_input )   forLabel: o_language_txt];
-    [self setMeta: input_item_GetDate( p_item->p_input )       forLabel: o_date_txt];
+    SET( title, Title );
+    SET( author, Artist );
+    SET( collection, Album );
+    SET( seqNum, TrackNum );
+    SET( genre, Genre );
+    SET( copyright, Copyright );
+    SET( rating, Rating );
+    SET( publisher, Publisher );
+    SET( nowPlaying, NowPlaying );
+    SET( language, Language );
+    SET( date, Date );
+
+#undef SET
 
     /* reload the advanced table */
     [[VLCInfoTreeItem rootItem] refresh];
 
     if( [self isItemInPlaylist: p_item] )
     {
-        vlc_mutex_lock( &p_item->p_input->lock );
-
-        p_item->p_input->psz_uri = strdup( [[o_uri_txt stringValue] UTF8String] );
-        p_item->p_input->psz_name = strdup( [[o_title_txt stringValue] UTF8String] );
-        vlc_mutex_unlock( &p_item->p_input->lock );
-        input_item_SetArtist( p_item->p_input, [[o_author_txt stringValue] UTF8String] );
+        input_item_SetName( p_item->p_input,
+                [[o_title_txt stringValue] UTF8String] );
+        input_item_SetURI( p_item->p_input,
+                [[o_uri_txt stringValue] UTF8String] );
+        input_item_SetArtist( p_item->p_input,
+                [[o_author_txt stringValue] UTF8String] );
 
         val.b_bool = VLC_TRUE;
         var_Set( p_playlist, "intf-change", val );
index 78e04a5daabafcb91b840f3bcab22b257d726d63..3d7330e4d221f320b871b580793bdc3e1f3a67b8 100644 (file)
@@ -285,12 +285,14 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
         return;
     }
 
-    if( input_GetItem(p_input)->psz_name != NULL )
-        o_title = [NSMutableString stringWithUTF8String:
-            input_GetItem(p_input)->psz_name];
-    if( input_GetItem(p_input)->psz_uri != NULL )
-        o_mrl = [NSMutableString stringWithUTF8String:
-            input_GetItem(p_input)->psz_uri];
+    char *psz_name = input_item_GetName( input_GetItem( p_input ) );
+    char *psz_uri = input_item_GetURI( input_GetItem( p_input ) );
+    if( psz_name != NULL )
+        o_title = [NSMutableString stringWithUTF8String: psz_name];
+    if( psz_uri != NULL )
+        o_mrl = [NSMutableString stringWithUTF8String: psz_uri];
+    free( psz_name );
+    free( psz_uri );
     if( o_title == nil )
         o_title = o_mrl;
 
index 710b064ff2e76265d00f6120f15084a59cbce16d..3e3663602c59e72b89380678e7222aa77d1d7b20 100644 (file)
@@ -597,8 +597,10 @@ static VLCWizard *_o_sharedInstance = nil;
 
                     if( p_item->i_children <= 0 )
                     {
+                        char *psz_uri = input_item_GetURI( p_item->p_input );
                         [tempArray addObject: [NSString stringWithUTF8String:
-                        p_item->p_input->psz_uri]];
+                        psz_uri]];
+                        free( psz_uri );
                         stop = NO;
                     }
                     else
index 89e32849d069a9f099423c0a5f51a23e2d3cd7b6..8f55d68b9fae731113369c973122950fc7d89ed1 100644 (file)
@@ -1206,8 +1206,9 @@ static void Redraw( intf_thread_t *p_intf, time_t *t_last_refresh )
         vlc_value_t val_list;
 
         /* Source */
-        mvnprintw( y++, 0, COLS, " Source   : %s",
-                   input_GetItem(p_input)->psz_uri );
+        char *psz_uri = input_item_GetURI( input_GetItem( p_input ) );
+        mvnprintw( y++, 0, COLS, " Source   : %s", psz_uri );
+        free( psz_uri );
 
         /* State */
         var_Get( p_input, "state", &val );
index c8caa8205b75eddb322f733f0ed86666d1363290..498d1b73f93dda098e1df22ebee266321bcc537a 100644 (file)
@@ -158,15 +158,18 @@ void MetaPanel::saveMeta()
         return;
 
     /* we can write meta data only in a file */
-    if( ( p_input->i_type == ITEM_TYPE_AFILE ) || \
-        ( p_input->i_type == ITEM_TYPE_VFILE ) )
-        /* some audio files are detected as video files */
+    vlc_mutex_lock( &p_input->lock );
+    int i_type = p_input->i_type;
+    vlc_mutex_unlock( &p_input->lock );
+    if( ( i_type == ITEM_TYPE_AFILE ) || ( i_type == ITEM_TYPE_VFILE ) )
     {
-        char *psz_uri = p_input->psz_uri;
+        char *psz_uri_orig = input_item_GetURI( p_input );
+        char *psz_uri = psz_uri_orig;
         if( !strncmp( psz_uri, "file://", 7 ) )
             psz_uri += 7; /* strlen("file://") = 7 */
 
         p_export.psz_file = strndup( psz_uri, PATH_MAX );
+        free( psz_uri_orig );
     }
     else
         return;
@@ -239,20 +242,29 @@ void MetaPanel::update( input_item_t *p_item )
 
     /* Name / Title */
     psz_meta = input_item_GetTitle( p_item );
+    char *psz_name = input_item_GetName( p_item );
     if( !EMPTY_STR( psz_meta ) )
         title_text->setText( qfu( psz_meta ) );
-    else if( !EMPTY_STR( p_item->psz_name ) )
-        title_text->setText( qfu( p_item->psz_name ) );
+    else if( !EMPTY_STR( psz_name ) )
+        title_text->setText( qfu( psz_name ) );
     else title_text->setText( "" );
     free( psz_meta );
+    free( psz_name );
 
     /* URL / URI */
     psz_meta = input_item_GetURL( p_item );
     if( !EMPTY_STR( psz_meta ) )
+    {
         emit uriSet( QString( psz_meta ) );
-    else if( !EMPTY_STR( p_item->psz_uri ) )
-        emit uriSet( QString( p_item->psz_uri ) );
-    free( psz_meta );
+        free( psz_meta );
+    }
+    else
+    {
+        free( psz_meta );
+        psz_meta = input_item_GetURI( p_item );
+        if( !EMPTY_STR( psz_meta ) )
+            emit uriSet( QString( psz_meta ) );
+    }
 
     /* Other classic though */
     UPDATE_META( Artist, artist_text );
index b9bb653e92e3b28f408e29a630fd6164ce00e47e..dae3af64583f8259e255ecf51ae2c39db9cdf589 100644 (file)
@@ -138,6 +138,7 @@ void InputManager::update()
     char *psz_artist = input_item_GetArtist( input_GetItem( p_input ) );
     if( EMPTY_STR( psz_name ) )
     {
+        free( psz_name );
         psz_name = input_item_GetName( input_GetItem( p_input ) );
     }
     if( !EMPTY_STR( psz_nowplaying ) )
index 05b987eb07d696e040abcb547fe8516edb45e431..1ef1ce2040d61ab3b8188a3189c2f98b14620b84 100644 (file)
@@ -231,7 +231,8 @@ void PLItem::update( playlist_item_t *p_item, bool iscurrent )
                     ADD_META( p_item, Description );
                     break;
                 case VLC_META_ENGINE_DURATION:
-                    secstotimestr( psz_duration, p_item->p_input->i_duration / 1000000 );
+                    secstotimestr( psz_duration,
+                        input_item_GetDuration( p_item->p_input ) / 1000000 );
                     strings.append( QString( psz_duration ) );
                     break;
                 case VLC_META_ENGINE_GENRE:
index d59d7ae2592a44954eb6cbc49e387affdcc2a7b0..38d0a2d5aa632c8f13bfe9b4d80374bd5e2a2ca1 100644 (file)
@@ -100,9 +100,11 @@ LRESULT ItemInfoDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
                         WS_CHILD | WS_VISIBLE | SS_RIGHT,
                         0, 10, 60, 15, hwnd, NULL, hInst, NULL);
 
-        uri_text = CreateWindow( _T("EDIT"), _FROMMB(p_item->input.psz_uri),
+        char *psz_uri = input_item_GetURI( &p_item->input );
+        uri_text = CreateWindow( _T("EDIT"), _FROMMB(psz_uri),
             WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
             70, 10 - 3, rcClient.right - 70 - 10, 15 + 6, hwnd, 0, hInst, 0 );
+        free( psz_uri );
 
         /* Name Textbox */
         name_label = CreateWindow( _T("STATIC"), _T("Name:"),
@@ -252,18 +254,15 @@ void ItemInfoDialog::OnOk()
 {
     int b_state = VLC_FALSE;
 
-    vlc_mutex_lock( &p_item->input.lock );
-
     TCHAR psz_name[MAX_PATH];
     Edit_GetText( name_text, psz_name, MAX_PATH );
-    if( p_item->input.psz_name ) free( p_item->input.psz_name );
-    p_item->input.psz_name = strdup( _TOMB(psz_name) );
+    input_item_SetName( &p_item->input, _TOMB( psz_name ) );
 
     TCHAR psz_uri[MAX_PATH];
     Edit_GetText( uri_text, psz_uri, MAX_PATH );
-    if( p_item->input.psz_uri ) free( p_item->input.psz_uri );
-    p_item->input.psz_uri = strdup( _TOMB(psz_uri) );
+    input_item_SetURI( &p_item->input, _TOMB(psz_uri) );
 
+    vlc_mutex_lock( &p_item->input.lock );
     vlc_bool_t b_old_enabled = p_item->b_enabled;
 
     playlist_t * p_playlist = (playlist_t *)
index 96e4db04d31c1ff53e619923d088be67fecf1ec0..fe1ace6f45f860ecc3159ac631da23404189ef1b 100644 (file)
@@ -671,7 +671,7 @@ void Playlist::UpdateItem( int i )
                                    _("General") , _("Author") ) ) );
 
     char psz_duration[MSTRTIME_MAX_SIZE];
-    mtime_t dur = p_item->input.i_duration;
+    mtime_t dur = input_item_GetDuration( p_item );
     if( dur != -1 ) secstotimestr( psz_duration, dur/1000000 );
     else memcpy( psz_duration , "-:--:--", sizeof("-:--:--") );
 
index 1411517dfcb73ff9f4a805af88e0e764f4f07b36..5f6ebed466c812df3515d9c49ee176f4ccb2bcc0 100644 (file)
@@ -373,10 +373,12 @@ void BookmarksDialog::OnExtract( wxCommandEvent& event )
 
     if( i_first < i_bookmarks && i_second <= i_bookmarks )
     {
+        char *psz_uri = input_item_GetURI( input_GetItem( p_input ) );
         WizardDialog *p_wizard_dialog = new WizardDialog( p_intf, this,
-                               input_GetItem(p_input)->psz_uri,
+                               psz_uri,
                                pp_bookmarks[i_first]->i_time_offset/1000000,
                                pp_bookmarks[i_second]->i_time_offset/1000000 );
+        free( psz_uri );
         vlc_object_release( p_input );
         if( p_wizard_dialog )
         {
index 6e04f7257421fb559207a9bf28311b0c6a6dc28c..396fbfdff4a6f987f6648c8d49df25d4d5f5eb5c 100644 (file)
@@ -117,8 +117,6 @@ void MetaDataPanel::Update( input_item_t *p_item )
     /* Rebuild the tree */
     Clear();
 
-    uri_text->SetValue( wxU( p_item->psz_uri ) );
-    name_text->SetValue( wxU( p_item->psz_name ) );
     char *psz_meta;
 
 #define UPDATE_META( meta, widget ) {                                       \
@@ -131,6 +129,8 @@ void MetaDataPanel::Update( input_item_t *p_item )
     }                                                                       \
     free( psz_meta );
 
+    UPDATE_META( URI, uri_text );
+    UPDATE_META( Name, name_text );
     UPDATE_META( Artist, artist_text );
     UPDATE_META( Genre, genre_text );
     UPDATE_META( Copyright, copyright_text );
index 01cc2eaae1e67e9150d9c041646b0374315fe4db..56e04bb2e951db5a15b24b7cea42b740f849a9b3 100644 (file)
@@ -107,10 +107,8 @@ ItemInfoDialog::~ItemInfoDialog()
  *****************************************************************************/
 void ItemInfoDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
 {
-    vlc_mutex_lock( &p_item->p_input->lock );
-    p_item->p_input->psz_name = info_panel->GetName();
-    p_item->p_input->psz_uri = info_panel->GetURI();
-    vlc_mutex_unlock( &p_item->p_input->lock );
+    input_item_SetName( p_item->p_input, info_panel->GetName() );
+    input_item_SetURI( p_item->p_input, info_panel->GetURI() );
     EndModal( wxID_OK );
 }
 
index 5d384caa35dee98fa7ac7f7f53426eaac9e82cc6..4649e20c5e3b207321e5ddb03cfd1941eec1d1d3 100644 (file)
@@ -512,11 +512,11 @@ void Playlist::UpdateTreeItem( wxTreeItemId item )
     wxString msg;
     wxString duration = wxU( "" );
 
-    char *psz_artist;
-    psz_artist = input_item_GetArtist( p_item->p_input );
+    char *psz_artist = input_item_GetArtist( p_item->p_input );
+    char *psz_name = input_item_GetName( p_item->p_input );
 
     char psz_duration[MSTRTIME_MAX_SIZE];
-    mtime_t dur = p_item->p_input->i_duration;
+    mtime_t dur = input_item_GetDuration( p_item->p_input );
 
     if( dur != -1 )
     {
@@ -527,14 +527,15 @@ void Playlist::UpdateTreeItem( wxTreeItemId item )
 
     if( !strcmp( psz_artist, "" ) || p_item->p_input->b_fixed_name == VLC_TRUE )
     {
-        msg = wxString( wxU( p_item->p_input->psz_name ) ) + duration;
+        msg = wxString( wxU( psz_name ) ) + duration;
     }
     else
     {
         msg = wxString(wxU( psz_artist )) + wxT(" - ") +
-              wxString(wxU(p_item->p_input->psz_name)) + duration;
+              wxString(wxU(psz_name)) + duration;
     }
     free( psz_artist );
+    free( psz_name );
     treectrl->SetItemText( item , msg );
     treectrl->SetItemImage( item, p_item->p_input->i_type );
 
index bebfc72f1e699fa02735c50674843302c81a7971..91d8a172bb12ab58b8f71156d0828d94b1e1167a 100644 (file)
@@ -724,7 +724,9 @@ void wizInputPage::OnWizardPageChanging(wxWizardEvent& event)
                 playlist_item_t * p_item = playlist_ItemGetById(                                                   p_playlist, (int)data, VLC_FALSE );
                 if( p_item )
                 {
-                    p_parent->SetMrl( (const char*)p_item->p_input->psz_uri );
+                    const char *psz_uri = input_item_GetURI( p_item->p_input );
+                    p_parent->SetMrl( psz_uri );
+                    free( psz_uri );
                 }
                 else
                     event.Veto();
index 9e467e488cd63692d45fe65c0e8847398e6f2cad..aa867879249bd6dc34cdf014e02a1d6b1823d0f1 100644 (file)
@@ -300,13 +300,15 @@ void PlaylistManager::UpdateTreeItem( wxTreeItemId item )
     wxString duration = wxU( "" );
 
     char *psz_artist = input_item_GetArtist( p_item->p_input );
-    if( ! psz_artist )
-    {
-        psz_artist = "";
-    }
+    if( !psz_artist )
+        psz_artist = strdup( "" );
+
+    char *psz_name = input_item_GetName( p_item->p_input );
+    if( !psz_name )
+        psz_name = strdup( "" );
 
     char psz_duration[MSTRTIME_MAX_SIZE];
-    mtime_t dur = p_item->p_input->i_duration;
+    mtime_t dur = input_item_GetDuration( p_item->p_input );
 
     if( dur != -1 )
     {
@@ -317,14 +319,15 @@ void PlaylistManager::UpdateTreeItem( wxTreeItemId item )
 
     if( !strcmp( psz_artist, "" ) || p_item->p_input->b_fixed_name == VLC_TRUE )
     {
-        msg = wxString( wxU( p_item->p_input->psz_name ) ) + duration;
+        msg = wxString( wxU( psz_name ) ) + duration;
     }
     else
     {
         msg = wxString(wxU( psz_artist )) + wxT(" - ") +
-                    wxString(wxU(p_item->p_input->psz_name)) + duration;
+                    wxString(wxU(psz_name)) + duration;
     }
     free( psz_artist );
+    free( psz_name );
     treectrl->SetItemText( item , msg );
     treectrl->SetItemImage( item, p_item->p_input->i_type );
 
index 10252dbc322f0bf360ea3ed018b91ca69742f061..d52bb60baf2e128c396f3a2a7281a8df1a1b51ec 100644 (file)
@@ -68,7 +68,7 @@ static int FindMeta( vlc_object_t *p_this )
     int i = 0;
     struct stat a;
     char psz_filename[MAX_PATH];
-    char *psz_dir = strdup( p_item->psz_uri );
+    char *psz_dir = input_item_GetURI( p_item );
     char *psz_buf = strrchr( psz_dir, '/' );
 
     if( psz_buf )
index fe92d411eeb6bf57d97e6ddaec498e6980feef10..e9c7c9dd304281601f995564fef23f6861db8917 100644 (file)
@@ -199,11 +199,8 @@ vlc_meta_Set##bar( p_meta, p_t->toString().toCString(true))
         {
             input_item_t *p_item = input_GetItem( p_input );
             if( p_item )
-            {
-                vlc_mutex_lock( &p_item->lock );
-                p_item->i_duration = i_ogg_v_length * 1000000;
-                vlc_mutex_unlock( &p_item->lock );
-            }
+                input_item_SetDuration( p_item,
+                        (mtime_t) i_ogg_v_length * 1000000 );
             vlc_object_release( p_input );
         }
         
@@ -224,11 +221,8 @@ vlc_meta_Set##bar( p_meta, p_t->toString().toCString(true))
         {
             input_item_t *p_item = input_GetItem( p_input );
             if( p_item )
-            {
-                vlc_mutex_lock( &p_item->lock );
-                p_item->i_duration = i_ogg_f_length * 1000000;
-                vlc_mutex_unlock( &p_item->lock );
-            }
+                input_item_SetDuration( p_item,
+                        (mtime_t) i_ogg_f_length * 1000000 );
             vlc_object_release( p_input );
         }
     }
@@ -243,11 +237,8 @@ vlc_meta_Set##bar( p_meta, p_t->toString().toCString(true))
         {
             input_item_t *p_item = input_GetItem( p_input );
             if( p_item )
-            {
-                vlc_mutex_lock( &p_item->lock );
-                p_item->i_duration = i_flac_length * 1000000;
-                vlc_mutex_unlock( &p_item->lock );
-            }
+                input_item_SetDuration( p_item,
+                        (mtime_t) i_flac_length * 1000000 );
             vlc_object_release( p_input );
         }
     }
@@ -350,8 +341,8 @@ static int WriteMeta( vlc_object_t *p_this )
             TagLib::ID3v2::TextIdentificationFrame p_frame( p_byte ); \
             p_frame.setText( psz_meta ); \
             p_id3tag->addFrame( &p_frame ); \
+            free( psz_meta ); \
         } \
-        else free( psz_meta );
 
         WRITE( Publisher, "TPUB" );
         WRITE( Copyright, "TCOP" );
index 4bcfa86d22205251c4fa99b911f8f84ed6874ca2..25d18328cb7d5719c9d7b9a5b48a2894247eb347 100644 (file)
@@ -1093,7 +1093,7 @@ static int ReadMetaData( intf_thread_t *p_this )
         else
             psz_trackid = calloc( 1, 1 );
 
-        i_length = input_GetItem(p_input)->i_duration / 1000000;
+        i_length = input_item_GetDuration( input_GetItem( p_input ) ) / 1000000;
 
         vlc_mutex_lock ( &p_sys->lock );
 
index 6f6ba179093f28e54794a76424dbad0bca59ea2b..c7810f450a258234338dd672b9e94b1d3dc58825 100644 (file)
@@ -138,8 +138,9 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
     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)") );
+    psz_title = input_item_GetTitle( input_GetItem( p_input ) );
+    if( psz_title == NULL )
+        psz_title = input_item_GetName( input_GetItem( p_input ) );
     snprintf( psz_tmp, GROWL_MAX_LENGTH, "%s %s %s",
               psz_title, psz_artist, psz_album );
     free( psz_title );
index 796907d951ef8d2127ea1c1c026ad512e7dc75ef..a807982879247fc79fb2a1bb451a79a772f45f03 100644 (file)
@@ -153,13 +153,13 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
     }
 
     /* Playing something ... */
-    psz_artist = input_item_GetArtist( input_GetItem(p_input) );
-    psz_album = input_item_GetAlbum( input_GetItem(p_input) );
-    psz_title = input_item_GetTitle( input_GetItem(p_input) );
+    psz_artist = input_item_GetArtist( input_GetItem( p_input ) );
+    psz_album = input_item_GetAlbum( input_GetItem( p_input ) );
+    psz_title = input_item_GetTitle( input_GetItem( p_input ) );
     if( !psz_artist ) psz_artist = strdup( "" );
     if( !psz_album ) psz_artist = strdup( "" );
-    if( !strcmp( psz_title, NULL ) )
-        psz_title = strdup( N_("(no title)") );
+    if( !psz_title )
+        psz_title = input_item_GetName( input_GetItem( p_input ) );
 
     psz_buf = str_format_meta( p_this, p_intf->p_sys->psz_format );
 
index b7adc28b35fe990f05bc438edb05bb75a66dfec7..5559c5885060b9c3ae6ac30646993a4d9c25fbee 100644 (file)
@@ -153,7 +153,9 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
     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 ) );
+    psz_title = input_item_GetTitle( input_GetItem( p_input ) );
+    if( psz_title == NULL )
+        psz_title = input_item_GetName( input_GetItem( p_input ) );
 
     vlc_object_release( p_input );
 
index 64ddcdaff8429e0ea362191d79c1f68dcfde3863..4dd0a94bb3ce542ce487e5b1fb17da95e5c6a6ef 100644 (file)
@@ -245,10 +245,11 @@ static void Run( intf_thread_t *p_intf )
 
                 vlc_object_release( p_playlist );
 
-                if( p_input->i_duration != -1 )
+                mtime_t i_duration = input_item_GetDuration( p_input );
+                if( i_duration != -1 )
                 {
                     char psz_durationstr[MSTRTIME_MAX_SIZE];
-                    secstotimestr( psz_durationstr, p_input->i_duration/1000000 );
+                    secstotimestr( psz_durationstr, i_duration / 1000000 );
                     sprintf( psz_duration, "(%s)", psz_durationstr );
                 }
                 else
index 970c381830881d29b9afea4b87c4bbd809256c62..7030e5759cb99ffafba547788e80da6d847f2b71 100644 (file)
@@ -61,34 +61,37 @@ static void DoChildren( playlist_t *p_playlist, playlist_export_t *p_export,
             continue;
         }
 
-        assert( p_current->p_input->psz_uri );
-
         /* General info */
+
+        char *psz_uri = input_item_GetURI( p_current->p_input );
+
+        assert( psz_uri );
+
         char *psz_name = input_item_GetName( p_current->p_input );
-        if( psz_name && strcmp( p_current->p_input->psz_uri, psz_name ) )
+        if( psz_name && strcmp( psz_uri, psz_name ) )
         {
             char *psz_artist = input_item_GetArtist( p_current->p_input );
             if( psz_artist == NULL ) psz_artist = strdup( "" );
+            mtime_t i_duration = input_item_GetDuration( p_current->p_input );
             if( psz_artist && *psz_artist )
             {
                 /* write EXTINF with artist */
                 fprintf( p_export->p_file, "#EXTINF:%i,%s - %s\n",
-                          (int)( p_current->p_input->i_duration/1000000 ),
-                          psz_artist,
-                          p_current->p_input->psz_name);
+                          (int)( i_duration / 1000000 ), psz_artist, psz_name);
             }
             else
             {
                 /* write EXTINF without artist */
                 fprintf( p_export->p_file, "#EXTINF:%i,%s\n",
-                         (int)( p_current->p_input->i_duration/1000000 ),
-                          p_current->p_input->psz_name);
+                         (int)( i_duration / 1000000 ), psz_name);
             }
             free( psz_artist );
         }
+        free( psz_uri );
         free( psz_name );
 
         /* VLC specific options */
+        vlc_mutex_lock( &p_current->p_input->lock );
         for( j = 0; j < p_current->p_input->i_options; j++ )
         {
             fprintf( p_export->p_file, "#EXTVLCOPT:%s\n",
@@ -96,9 +99,9 @@ static void DoChildren( playlist_t *p_playlist, playlist_export_t *p_export,
                      p_current->p_input->ppsz_options[j] + 1 :
                      p_current->p_input->ppsz_options[j] );
         }
+        vlc_mutex_unlock( &p_current->p_input->lock );
 
-        fprintf( p_export->p_file, "%s\n",
-                 p_current->p_input->psz_uri );
+        fprintf( p_export->p_file, "%s\n", psz_uri );
     }
 }
 
index 5b8da77e198284826fb157f57dd1b2bae891aceb..8f732e4fc29a90a89d0b7ba6db75a61f6e0a6ce3 100644 (file)
@@ -110,6 +110,7 @@ static void xspf_export_item( playlist_item_t *p_item, FILE *p_file,
 {
     char *psz;
     char *psz_temp;
+    mtime_t i_duration;
 
     if( !p_item ) return;
 
@@ -138,23 +139,27 @@ static void xspf_export_item( playlist_item_t *p_item, FILE *p_file,
     ( *p_i_count )++;
 
     /* -> the location */
-    if( p_item->p_input->psz_uri && *p_item->p_input->psz_uri )
+
+    char *psz_uri = input_item_GetURI( p_item->p_input );
+
+    if( psz_uri && *psz_uri )
     {
-        psz = assertUTF8URI( p_item->p_input->psz_uri );
+        psz = assertUTF8URI( psz_uri );
         fprintf( p_file, "\t\t\t<location>%s</location>\n", psz );
         free( psz );
     }
 
     /* -> the name/title (only if different from uri)*/
-    if( p_item->p_input->psz_name &&
-        p_item->p_input->psz_uri &&
-        strcmp( p_item->p_input->psz_uri, p_item->p_input->psz_name ) )
+    char *psz_name = input_item_GetName( p_item->p_input );
+    if( psz_name && psz_uri && strcmp( psz_uri, psz_name ) )
     {
-        psz_temp = convert_xml_special_chars( p_item->p_input->psz_name );
+        psz_temp = convert_xml_special_chars( psz_name );
         if( *psz_temp )
             fprintf( p_file, "\t\t\t<title>%s</title>\n", psz_temp );
         free( psz_temp );
     }
+    free( psz_name );
+    free( psz_uri );
 
     if( p_item->p_input->p_meta == NULL )
     {
@@ -208,10 +213,11 @@ static void xspf_export_item( playlist_item_t *p_item, FILE *p_file,
 
 xspfexportitem_end:
     /* -> the duration */
-    if( p_item->p_input->i_duration > 0 )
+    i_duration = input_item_GetDuration( p_item->p_input );
+    if( i_duration > 0 )
     {
         fprintf( p_file, "\t\t\t<duration>%ld</duration>\n",
-                 (long)(p_item->p_input->i_duration / 1000) );
+                 (long)(i_duration / 1000) );
     }
 
     fprintf( p_file, "\t\t</track>\n" );
index 767e743a4a272912bdde19ca3bd28c6556b94bff..884d18304c727b3afe7a3d4227a618beeee78ad3 100644 (file)
@@ -422,7 +422,7 @@ static vod_media_t *MediaNew( vod_t *p_vod, const char *psz_name,
 
     p_media->i_sdp_id = mdate();
     p_media->i_sdp_version = 1;
-    p_media->i_length = p_item->i_duration;
+    p_media->i_length = input_item_GetDuration( p_item );
 
     vlc_mutex_lock( &p_item->lock );
     msg_Dbg( p_vod, "media has %i declared ES", p_item->i_es );
index 6d6bce6bafb4f2c67adc5d7e1c600605df5dbb6b..11e55c7bef51f9ac791598f774be3c0efb84608f 100644 (file)
@@ -590,13 +590,13 @@ static int Demux( demux_t *p_demux )
         return VLC_EGENERIC;
     }
 
-    p_parent_input = input_GetItem(p_input);
+    p_parent_input = input_GetItem( p_input );
+
+    input_item_SetURI( p_parent_input, p_sdp->psz_uri );
+    input_item_SetName( p_parent_input, p_sdp->psz_sessionname );
 
     vlc_mutex_lock( &p_parent_input->lock );
-    FREENULL( p_parent_input->psz_uri );
-    p_parent_input->psz_uri = strdup( p_sdp->psz_uri );
-    FREENULL( p_parent_input->psz_name );
-    p_parent_input->psz_name = strdup( p_sdp->psz_sessionname );
+
     p_parent_input->i_type = ITEM_TYPE_NET;
 
     if( p_playlist->status.p_item &&
index 7d8327ec84f3d7490b68f388f98774b8f77fd5aa..734694713578a9dad4910998315b4b83538cb6de 100644 (file)
@@ -303,7 +303,8 @@ static char *TitleGet( vlc_object_t *p_this )
 
     if( p_input )
     {
-        char *psz = strrchr( input_GetItem(p_input)->psz_uri, '/' );
+        char *psz_orig = input_item_GetURI( input_GetItem( p_input ) );
+        char *psz = strrchr( psz_orig, '/' );
 
         if( psz )
         {
@@ -311,12 +312,13 @@ static char *TitleGet( vlc_object_t *p_this )
         }
         else
         {
-            psz = input_GetItem(p_input)->psz_uri;
+            psz = psz_orig;
         }
         if( psz && *psz )
         {
             psz_title = strdup( psz );
         }
+        free( psz_orig );
         vlc_object_release( p_input );
     }
 
index d21d199e540512491d35078a4c1fc8b6eb089816..3d8c7f67520b8de57cd94f1ab0ef7f2ed0f0b822 100644 (file)
@@ -414,11 +414,12 @@ static char *TitleGet( vlc_object_t *p_this )
 
     if( p_input )
     {
-        psz_title = strdup( input_item_GetTitle( input_GetItem( p_input ) ) );
+        psz_title = input_item_GetTitle( input_GetItem( p_input ) );
         if( EMPTY_STR( psz_title ) )
         {
             free( psz_title );
-            char *psz = strrchr( input_GetItem(p_input)->psz_uri, '/' );
+            char *psz_orig = input_item_GetURI( input_GetItem( p_input ) );
+            char *psz = strrchr( psz_orig, '/' );
 
             if( psz )
             {
@@ -426,12 +427,13 @@ static char *TitleGet( vlc_object_t *p_this )
             }
             else
             {
-                psz = input_GetItem(p_input)->psz_uri;
+                psz = psz_orig;
             }
             if( psz && *psz )
             {
                 psz_title = strdup( psz );
             }
+            free( psz_orig );
         }
         vlc_object_release( p_input );
     }
index e7bb855a0f29c4c0a2137669f417fb82541561e7..77955b442b7bf7aafc1e391b86ce59fe36ba3181 100644 (file)
@@ -303,7 +303,7 @@ libvlc_media_descriptor_get_mrl( libvlc_media_descriptor_t * p_md,
                                  libvlc_exception_t * p_e )
 {
     (void)p_e;
-    return strdup( p_md->p_input_item->psz_uri );
+    return input_item_GetURI( p_md->p_input_item );
 }
 
 /**************************************************************************
index e089411b3bb612ad69c32187ac17e899ae208bc0..c077aff02099fdce2e00d6bd28403d7ed37ed787 100644 (file)
@@ -362,7 +362,7 @@ mediacontrol_playlist_get_list( mediacontrol_Instance *self,
 
     for( i_index = 0 ; i_index < i_playlist_size ; i_index++ )
     {
-        retval->data[i_index] = strdup( ARRAY_VAL(p_playlist->current, i_index)->p_input->psz_uri );
+        retval->data[i_index] = input_item_GetURI( ARRAY_VAL(p_playlist->current, i_index)->p_input );
     }
     vlc_mutex_unlock( &p_playlist->object_lock );
 
@@ -419,7 +419,7 @@ mediacontrol_get_stream_information( mediacontrol_Instance *self,
             break;
         }
 
-        retval->url = strdup( input_GetItem(p_input)->psz_uri );
+        retval->url = input_item_GetURI( input_GetItem( p_input ) );
 
         /* TIME and LENGTH are in microseconds. We want them in ms */
         var_Get( p_input, "time", &val);
index 1d83125fdb9289ff51f56bde4cd45d30e5be9018..c985b58132fe2b826623e64e3c013ff0f41f31fa 100644 (file)
@@ -903,11 +903,14 @@ static int Init( input_thread_t * p_input )
         var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL );
         UpdateItemLength( p_input, val.i_time );
     }
-    else if( p_input->p->input.p_item->i_duration > 0 )
-    { /* fallback: gets length from metadata */
-        val.i_time = p_input->p->input.p_item->i_duration;
-        var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL );
-        UpdateItemLength( p_input, val.i_time );
+    else
+    {
+        val.i_time = input_item_GetDuration( p_input->p->input.p_item );
+        if( val.i_time > 0 )
+        { /* fallback: gets length from metadata */
+            var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL );
+            UpdateItemLength( p_input, val.i_time );
+        }
     }
 
     /* Start title/chapter */
@@ -2034,9 +2037,7 @@ static int UpdateFromAccess( input_thread_t *p_input )
  *****************************************************************************/
 static void UpdateItemLength( input_thread_t *p_input, int64_t i_length )
 {
-    vlc_mutex_lock( &p_input->p->input.p_item->lock );
-    p_input->p->input.p_item->i_duration = i_length;
-    vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+    input_item_SetDuration( p_input->p->input.p_item, (mtime_t) i_length );
 
     if( !p_input->b_preparsing )
     {
index c8a4e96013111e953b55db3a771a0966786d0b72..e38ce3672054bf4517bc694fb9164e25c7dcec32 100644 (file)
@@ -2604,9 +2604,7 @@ static int vlm_ControlMediaInstanceStart( vlm_t *p_vlm, int64_t id, const char *
 
     /* Start new one */
     p_instance->i_index = i_input_index;
-    if( p_instance->item.psz_uri )
-        free( p_instance->item.psz_uri );
-    p_instance->item.psz_uri = strdup( p_media->cfg.ppsz_input[p_instance->i_index] );
+    input_item_SetURI( &p_instance->item, p_media->cfg.ppsz_input[p_instance->i_index] ) ;
 
     asprintf( &psz_log, _("Media: %s"), p_media->cfg.psz_name );
     p_instance->p_input = input_CreateThreadExtended( p_vlm, &p_instance->item, psz_log, p_instance->p_sout );
index 35086a4002e631fae4e9ccfae0a1b83e7fed93a5..cceb5f5e8c8ef50db1484b9490584a7dd2b05bf7 100644 (file)
@@ -616,7 +616,7 @@ int playlist_ItemSetName( playlist_item_t *p_item, const char *psz_name )
 {
     if( psz_name && p_item )
     {
-        input_ItemSetName( p_item->p_input, psz_name );
+        input_item_SetName( p_item->p_input, psz_name );
         return VLC_SUCCESS;
     }
     return VLC_EGENERIC;
index 15cb2e3eb2421a58c9e4c0bb2b29f4986397ab1a..32c630dd1bc9268182b0cf7de5a96c663d1c58e9 100644 (file)
@@ -104,6 +104,15 @@ static int playlist_ItemArraySort( playlist_t *p_playlist, int i_items,
         return VLC_SUCCESS;
     }
 
+#define META_STRCASECMP_NAME( i, i_small ) { \
+    char *psz_i = input_item_GetName( pp_items[i]->p_input ); \
+    char *psz_ismall = input_item_GetName( pp_items[i_small]->p_input ); \
+    i_test = strcasecmp( psz_i, psz_ismall ); \
+    free( psz_i ); \
+    free( psz_ismall ); \
+}    
+        
+
 #define DO_META_SORT( 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 ); \
@@ -117,8 +126,7 @@ static int playlist_ItemArraySort( playlist_t *p_playlist, int i_items,
     else if( pp_items[i]->i_children >= 0 && \
                pp_items[i_small]->i_children >= 0 ) \
     { \
-         i_test = strcasecmp( pp_items[i]->p_input->psz_name, \
-                              pp_items[i_small]->p_input->psz_name ); \
+        META_STRCASECMP_NAME( i, i_small ) \
     } \
     /* Both are items */ \
     else if( psz_a == NULL && psz_b != NULL ) \
@@ -128,8 +136,7 @@ static int playlist_ItemArraySort( playlist_t *p_playlist, int i_items,
     /* No meta, sort by name */ \
     else if( psz_a == NULL && psz_b == NULL ) \
     { \
-        i_test = strcasecmp( pp_items[i]->p_input->psz_name, \
-                             pp_items[i_small]->p_input->psz_name ); \
+        META_STRCASECMP_NAME( i, i_small ); \
     } \
     else \
     { \
@@ -148,18 +155,21 @@ static int playlist_ItemArraySort( playlist_t *p_playlist, int i_items,
 
             if( i_mode == SORT_TITLE )
             {
-                i_test = strcasecmp( pp_items[i]->p_input->psz_name,
-                                     pp_items[i_small]->p_input->psz_name );
+                META_STRCASECMP_NAME( i, i_small );
             }
             else if( i_mode == SORT_TITLE_NUMERIC )
             {
-                i_test = atoi( pp_items[i]->p_input->psz_name ) -
-                         atoi( pp_items[i_small]->p_input->psz_name );
+                char *psz_i = input_item_GetName( pp_items[i]->p_input );
+                char *psz_ismall =
+                        input_item_GetName( pp_items[i_small]->p_input );
+                i_test = atoi( psz_i ) - atoi( psz_ismall );
+                free( psz_i );
+                free( psz_ismall );
             }
             else if( i_mode == SORT_DURATION )
             {
-                i_test = pp_items[i]->p_input->i_duration -
-                             pp_items[i_small]->p_input->i_duration;
+                i_test = input_item_GetDuration( pp_items[i]->p_input ) -
+                         input_item_GetDuration( pp_items[i_small]->p_input );
             }
             else if( i_mode == SORT_ARTIST )
             {
index 10bf1484e7cc207cdbf182ea12826773fd573a04..4d0b317c46922c75fdfe9db369a42fb2a818a991 100644 (file)
@@ -638,14 +638,13 @@ char *str_format_time( const char *tformat )
                     if( check )                                     \
                     {                                               \
                         psz_meta = string;                          \
-                        if( string )                                \
+                        if( psz_meta )                              \
                         {                                           \
-                            int len = strlen( psz_meta );           \
+                            int len = strlen( string );             \
                             dst = realloc( dst,                     \
                                    i_size = i_size + len + 1 );     \
                             strncpy( d, psz_meta, len+1 );          \
                             d += len;                               \
-                            free( psz_meta );                       \
                         }                                           \
                         else                                        \
                         {                                           \
@@ -653,6 +652,23 @@ char *str_format_time( const char *tformat )
                                 d++;                                \
                         }                                           \
                     }
+
+/* same than INSERT_STRING, except that string won't be freed */
+#define INSERT_STRING_NO_FREE( check, string )                           \
+                    if( check && string )                           \
+                    {                                               \
+                            int len = strlen( string );             \
+                            dst = realloc( dst,                     \
+                                   i_size = i_size + len + 1 );     \
+                            strncpy( d, string, len+1 );            \
+                            d += len;                               \
+                            free( string );                         \
+                    }                                               \
+                    else                                            \
+                    {                                               \
+                            *d = '-';                               \
+                            d++;                                    \
+                    }
 char *__str_format_meta( vlc_object_t *p_object, const char *string )
 {
     const char *s = string;
@@ -671,8 +687,6 @@ char *__str_format_meta( vlc_object_t *p_object, const char *string )
     {
         vlc_object_yield( p_input );
         p_item = input_GetItem(p_input);
-        if( p_item )
-            vlc_mutex_lock( &p_item->lock );
     }
 
     sprintf( dst, string );
@@ -726,7 +740,6 @@ char *__str_format_meta( vlc_object_t *p_object, const char *string )
                         lang = strdup( b_empty_if_na ? "" : "-" );
                     }
                     INSERT_STRING( 1, lang );
-                    free( lang );
                     break;
                 }
                 case 't':
@@ -748,7 +761,7 @@ char *__str_format_meta( vlc_object_t *p_object, const char *string )
                     {
                         sprintf( buf, b_empty_if_na ? "" : "-" );
                     }
-                    INSERT_STRING( 1, buf );
+                    INSERT_STRING_NO_FREE( 1, buf );
                     break;
                 case 'C':
                     if( p_input )
@@ -760,24 +773,25 @@ char *__str_format_meta( vlc_object_t *p_object, const char *string )
                     {
                         sprintf( buf, b_empty_if_na ? "" : "-" );
                     }
-                    INSERT_STRING( 1, buf );
+                    INSERT_STRING_NO_FREE( 1, buf );
                     break;
                 case 'D':
                     if( p_item )
                     {
+                        mtime_t i_duration = input_item_GetDuration( p_item );
                         sprintf( buf, "%02d:%02d:%02d",
-                                 (int)(p_item->i_duration/(3600000000)),
-                                 (int)((p_item->i_duration/(60000000))%60),
-                                 (int)((p_item->i_duration/1000000)%60) );
+                                 (int)(i_duration/(3600000000)),
+                                 (int)((i_duration/(60000000))%60),
+                                 (int)((i_duration/1000000)%60) );
                     }
                     else
                     {
                         sprintf( buf, b_empty_if_na ? "" : "--:--:--" );
                     }
-                    INSERT_STRING( 1, buf );
+                    INSERT_STRING_NO_FREE( 1, buf );
                     break;
                 case 'F':
-                    INSERT_STRING( p_item, p_item->psz_uri );
+                    INSERT_STRING( p_item, input_item_GetURI( p_item ) );
                     break;
                 case 'I':
                     if( p_input )
@@ -789,24 +803,26 @@ char *__str_format_meta( vlc_object_t *p_object, const char *string )
                     {
                         sprintf( buf, b_empty_if_na ? "" : "-" );
                     }
-                    INSERT_STRING( 1, buf );
+                    INSERT_STRING_NO_FREE( 1, buf );
                     break;
                 case 'L':
                     if( p_item && p_input )
                     {
+                        mtime_t i_duration = input_item_GetDuration( p_item );
+                        int64_t i_time = p_input->i_time;
                         sprintf( buf, "%02d:%02d:%02d",
-                     (int)((p_item->i_duration-p_input->i_time)/(3600000000)),
-                     (int)(((p_item->i_duration-p_input->i_time)/(60000000))%60),
-                     (int)(((p_item->i_duration-p_input->i_time)/1000000)%60) );
+                     (int)( ( i_duration - i_time ) / 3600000000 ),
+                     (int)( ( ( i_duration - i_time ) / 60000000 ) % 60 ),
+                     (int)( ( ( i_duration - i_time ) / 1000000 ) % 60 ) );
                     }
                     else
                     {
                         sprintf( buf, b_empty_if_na ? "" : "--:--:--" );
                     }
-                    INSERT_STRING( 1, buf );
+                    INSERT_STRING_NO_FREE( 1, buf );
                     break;
                 case 'N':
-                    INSERT_STRING( p_item, p_item->psz_name );
+                    INSERT_STRING( p_item, input_item_GetName( p_item ) );
                     break;
                 case 'O':
                 {
@@ -820,7 +836,6 @@ char *__str_format_meta( vlc_object_t *p_object, const char *string )
                         lang = strdup( b_empty_if_na ? "" : "-" );
                     }
                     INSERT_STRING( 1, lang );
-                    free( lang );
                     break;
                 }
                 case 'P':
@@ -833,7 +848,7 @@ char *__str_format_meta( vlc_object_t *p_object, const char *string )
                     {
                         sprintf( buf, b_empty_if_na ? "" : "--.-%%" );
                     }
-                    INSERT_STRING( 1, buf );
+                    INSERT_STRING_NO_FREE( 1, buf );
                     break;
                 case 'R':
                     if( p_input )
@@ -845,7 +860,7 @@ char *__str_format_meta( vlc_object_t *p_object, const char *string )
                     {
                         sprintf( buf, b_empty_if_na ? "" : "-" );
                     }
-                    INSERT_STRING( 1, buf );
+                    INSERT_STRING_NO_FREE( 1, buf );
                     break;
                 case 'S':
                     if( p_input )
@@ -857,21 +872,21 @@ char *__str_format_meta( vlc_object_t *p_object, const char *string )
                     {
                         sprintf( buf, b_empty_if_na ? "" : "-" );
                     }
-                    INSERT_STRING( 1, buf );
+                    INSERT_STRING_NO_FREE( 1, buf );
                     break;
                 case 'T':
                     if( p_input )
                     {
                         sprintf( buf, "%02d:%02d:%02d",
-                                 (int)(p_input->i_time/(3600000000)),
-                                 (int)((p_input->i_time/(60000000))%60),
-                                 (int)((p_input->i_time/1000000)%60) );
+                            (int)( p_input->i_time / ( 3600000000 ) ),
+                            (int)( ( p_input->i_time / ( 60000000 ) ) % 60 ),
+                            (int)( ( p_input->i_time / 1000000 ) % 60 ) );
                     }
                     else
                     {
                         sprintf( buf, b_empty_if_na ? "" :  "--:--:--" );
                     }
-                    INSERT_STRING( 1, buf );
+                    INSERT_STRING_NO_FREE( 1, buf );
                     break;
                 case 'U':
                     INSERT_STRING( p_item, input_item_GetPublisher(p_item) );
@@ -881,7 +896,7 @@ char *__str_format_meta( vlc_object_t *p_object, const char *string )
                     audio_volume_t volume;
                     aout_VolumeGet( p_object, &volume );
                     snprintf( buf, 10, "%d", volume );
-                    INSERT_STRING( 1, buf );
+                    INSERT_STRING_NO_FREE( 1, buf );
                     break;
                 }
                 case '_':
@@ -916,11 +931,7 @@ char *__str_format_meta( vlc_object_t *p_object, const char *string )
     *d = '\0';
 
     if( p_input )
-    {
         vlc_object_release( p_input );
-        if( p_item )
-            vlc_mutex_unlock( &p_item->lock );
-    }
 
     return dst;
 }
index 0c2d63a003149d3f569c522bfd75bcae2cc6020c..ec11db5101edfc86720fab2deab314f0229c854e 100644 (file)
@@ -1645,7 +1645,12 @@ static void DisplayTitleOnOSD( vout_thread_t *p_vout )
         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 ) );
+        char *psz_name = input_item_GetTitle( input_GetItem( p_input ) );
+        if( EMPTY_STR( psz_name ) )
+            {
+                free( psz_name );
+                psz_name = input_item_GetName( input_GetItem( p_input ) );
+            }
         if( !EMPTY_STR( psz_nowplaying ) )
         {
             vout_ShowTextAbsolute( p_vout, DEFAULT_CHAN,