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 6f15034..508f063 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 6c51cb2..b246ad6 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 a3bc177..3ab6e0d 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 33c15e8..040044e 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 feb9f05..bf44c68 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 f1cb6d7..25a8eff 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 b9f583c..fa45e66 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 6ee354b..7dc1aa1 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 f3a25c8..5e87f55 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 d220c0a..89ed3c1 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 dc393e6..389fd1d 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 f1d315c..908a400 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 2866fc1..194facb 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 650f11c..789e54c 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 411006e..fc5db9c 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 f254169..c74da0e 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 3921e7f..c33a419 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 589f79e..07fd22b 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 2d3bb97..115d323 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 d777f87..3bda2f7 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 78e04a5..3d7330e 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 710b064..3e36636 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 89e3284..8f55d68 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 c8caa82..498d1b7 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 b9bb653..dae3af6 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 05b987e..1ef1ce2 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 d59d7ae..38d0a2d 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 96e4db0..fe1ace6 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 1411517..5f6ebed 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 6e04f72..396fbfd 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 01cc2ea..56e04bb 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 5d384ca..4649e20 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 bebfc72..91d8a17 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 9e467e4..aa86787 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 10252db..d52bb60 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 fe92d41..e9c7c9d 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 4bcfa86..25d1832 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 6f6ba17..c7810f4 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 796907d..a807982 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 b7adc28..5559c58 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 64ddcda..4dd0a94 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 970c381..7030e57 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 5b8da77..8f732e4 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 767e743..884d183 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 6d6bce6..11e55c7 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 7d8327e..7346947 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 d21d199..3d8c7f6 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 e7bb855..77955b4 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 e089411..c077aff 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 1d83125..c985b58 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 c8a4e96..e38ce36 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 35086a4..cceb5f5 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 15cb2e3..32c630d 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 10bf148..4d0b317 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 0c2d63a..ec11db5 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,