]> git.sesse.net Git - vlc/commitdiff
* Start cleaning up libvlc playlist API (Refs:#457)
authorClément Stenac <zorglub@videolan.org>
Tue, 20 Feb 2007 07:29:54 +0000 (07:29 +0000)
committerClément Stenac <zorglub@videolan.org>
Tue, 20 Feb 2007 07:29:54 +0000 (07:29 +0000)
  - Return correct item ids
  - Structures for navigating the playlist
  - Consistent locking
* Add a b_locked parameter to the remaining playlist API calls

44 files changed:
include/vlc/libvlc.h
include/vlc_playlist.h
modules/access/cdda.c
modules/access/directory.c
modules/access/mms/mmsh.c
modules/codec/cmml/intf.c
modules/control/http/macro.c
modules/control/http/rpn.c
modules/control/rc.c
modules/demux/mp4/mp4.c
modules/demux/playlist/asx.c
modules/demux/playlist/b4s.c
modules/demux/playlist/dvb.c
modules/demux/playlist/gvp.c
modules/demux/playlist/m3u.c
modules/demux/playlist/pls.c
modules/demux/playlist/podcast.c
modules/demux/playlist/qtl.c
modules/demux/playlist/sgimb.c
modules/demux/playlist/shoutcast.c
modules/demux/playlist/xspf.c
modules/gui/macosx/applescript.m
modules/gui/macosx/playlist.m
modules/gui/macosx/wizard.m
modules/gui/qt4/dialogs/open.cpp
modules/gui/qt4/dialogs/playlist.cpp
modules/gui/qt4/dialogs_provider.cpp
modules/gui/qt4/main_interface.cpp
modules/gui/wxwidgets/dialogs.cpp
modules/gui/wxwidgets/dialogs/open.cpp
modules/gui/wxwidgets/dialogs/wizard.cpp
modules/gui/wxwidgets/interface.cpp
modules/services_discovery/bonjour.c
modules/services_discovery/hal.c
modules/services_discovery/podcast.c
modules/services_discovery/sap.c
modules/services_discovery/shout.c
modules/services_discovery/upnp_cc.cpp
modules/services_discovery/upnp_intel.cpp
src/control/libvlc_internal.h
src/control/playlist.c
src/libvlc.c
src/misc/win32_specific.c
src/playlist/item.c

index 1850175572185a737c983b1e89fec7764c06bc5b..0ddc1a52d71bee0836497093395b890a56f1268a 100644 (file)
@@ -48,13 +48,12 @@ extern "C" {
  * @{
  */
 
-struct libvlc_exception_t
+typedef struct
 {
     int b_raised;
     int i_code;
     char *psz_message;
-};
-typedef struct libvlc_exception_t libvlc_exception_t;
+} libvlc_exception_t;
 
 /**
  * Initialize an exception structure. This can be called several times to reuse
@@ -140,6 +139,13 @@ VLC_PUBLIC_API void libvlc_destroy( libvlc_instance_t *, libvlc_exception_t * );
  * @{
  */
 
+typedef struct {
+    int i_id;
+    char * psz_uri;
+    char * psz_name
+
+} libvlc_playlist_item_t;
+
 /**
  * Set loop variable
  */
index c139ccb58a40cc1f49e00fbb990ef473d3fd34ad..032288c4f113eec32fabdcbb371511dfaff453e1 100644 (file)
@@ -368,11 +368,11 @@ VLC_EXPORT( int,  playlist_DeleteFromInput, ( playlist_t *, int, vlc_bool_t ) );
 VLC_EXPORT( int, playlist_ItemSetName, (playlist_item_t *, const char * ) );
 
 /******************** Item addition ********************/
-VLC_EXPORT( int,  playlist_Add,    ( playlist_t *, const char *, const char *, int, int, vlc_bool_t ) );
-VLC_EXPORT( int,  playlist_AddExt, ( playlist_t *, const char *, const char *, int, int, mtime_t, const char *const *,int, vlc_bool_t ) );
-VLC_EXPORT( int, playlist_AddInput, ( playlist_t *, input_item_t *,int , int, vlc_bool_t ) );
-VLC_EXPORT( playlist_item_t *, playlist_NodeAddInput, ( playlist_t *, input_item_t *,playlist_item_t *,int , int ) );
-VLC_EXPORT( int, playlist_BothAddInput, ( playlist_t *, input_item_t *,playlist_item_t *,int , int, int*, int* ) );
+VLC_EXPORT( int,  playlist_Add,    ( playlist_t *, const char *, const char *, int, int, vlc_bool_t, vlc_bool_t ) );
+VLC_EXPORT( int,  playlist_AddExt, ( playlist_t *, const char *, const char *, int, int, mtime_t, const char *const *,int, vlc_bool_t, vlc_bool_t ) );
+VLC_EXPORT( int, playlist_AddInput, ( playlist_t *, input_item_t *, int, int, vlc_bool_t, vlc_bool_t ) );
+VLC_EXPORT( playlist_item_t *, playlist_NodeAddInput, ( playlist_t *, input_item_t *,playlist_item_t *,int , int, vlc_bool_t ) );
+VLC_EXPORT( int, playlist_BothAddInput, ( playlist_t *, input_item_t *,playlist_item_t *,int , int, int*, int*, vlc_bool_t ) );
 
 /********************** Misc item operations **********************/
 VLC_EXPORT( playlist_item_t*, playlist_ItemToNode, (playlist_t *,playlist_item_t *, vlc_bool_t) );
@@ -415,7 +415,7 @@ static inline int playlist_Import( playlist_t *p_playlist, const char *psz_file)
     snprintf( psz_uri, 256+9, "file/://%s", psz_file );
     p_input = input_ItemNewExt( p_playlist, psz_uri, psz_file, 0, NULL, -1 );
     playlist_AddInput( p_playlist, p_input, PLAYLIST_APPEND, PLAYLIST_END,
-                       VLC_TRUE );
+                       VLC_TRUE, VLC_FALSE );
     input_Read( p_playlist, p_input, VLC_TRUE );
     return VLC_SUCCESS;
 }
index 4cddad0adb150132ba73db277ceeccb509899ebb..589e0d7c9aaf1e22fd064fd7f7d2a08ba42b697f 100644 (file)
@@ -503,7 +503,8 @@ static int GetTracks( access_t *p_access,
         }
 #endif
         playlist_BothAddInput( p_playlist, p_input_item, p_item_in_category,
-                               PLAYLIST_APPEND, PLAYLIST_END, NULL, NULL );
+                               PLAYLIST_APPEND, PLAYLIST_END, NULL, NULL,
+                               VLC_FALSE );
         free( psz_uri ); free( psz_opt ); free( psz_name );
         free( psz_first ); free( psz_last );
     }
index 49c56cc967194dcf244568fdf20f3326dd28f43d..832cb6c5cb1fed92509789a6170761239c735dab 100644 (file)
@@ -516,7 +516,8 @@ static int ReadDir( playlist_t *p_playlist, const char *psz_name,
                                            p_parent_category,
                                            PLAYLIST_APPEND|PLAYLIST_PREPARSE|
                                            PLAYLIST_NO_REBUILD,
-                                           PLAYLIST_END, NULL, NULL );
+                                           PLAYLIST_END, NULL, NULL,
+                                           VLC_FALSE );
                 }
             }
         }
index c3011e6415095d9f80eea79fd52547b3023e4204..2758549c4d4cf9f3191551968803d253f67b3ad6 100644 (file)
@@ -112,7 +112,8 @@ int E_(MMSHOpen)( access_t *p_access )
 
         /** \bug we do not autodelete here */
         playlist_Add( p_playlist, psz_location, psz_location,
-                      PLAYLIST_INSERT | PLAYLIST_GO, PLAYLIST_END, VLC_TRUE );
+                      PLAYLIST_INSERT | PLAYLIST_GO, PLAYLIST_END, VLC_TRUE,
+                      VLC_FALSE );
         vlc_object_release( p_playlist );
 
         free( psz_location );
index b193ea8bc3b31e48044d75b402cbc7c6674783ef..114ccc882e19b732629417575b6658f559c1d92b 100644 (file)
@@ -796,7 +796,8 @@ static void ReplacePlaylistItem( playlist_t *p_playlist, char *psz_uri )
 {
     playlist_Stop( p_playlist );
     (void) playlist_Add( p_playlist, psz_uri, psz_uri,
-                         PLAYLIST_INSERT /* FIXME: used to be PLAYLIST_REPLACE */, PLAYLIST_END|PLAYLIST_GO, VLC_TRUE /* FIXME: p_playlist->status.i_index */ );
+                         PLAYLIST_INSERT /* FIXME: used to be PLAYLIST_REPLACE */, PLAYLIST_END|PLAYLIST_GO, VLC_TRUE /* FIXME: p_playlist->status.i_index */,
+                         VLC_FALSE);
 }
 
 /****************************************************************************
index bc97060962130512511bc8c84f26c941f0b41bb2..ee0971632b15121aa63e7e34e9376f22675be3a8 100644 (file)
@@ -343,7 +343,8 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
                     else
                     {
                         playlist_AddInput( p_sys->p_playlist, p_input,
-                                     PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE );
+                                     PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE,
+                                     VLC_FALSE);
                         msg_Dbg( p_intf, "requested mrl add: %s", mrl );
                     }
 
index c280f31a5c037f36658c5ddaa3e75c85b4de8e0e..6027a15d636d4fd41c1ca092ad0ac3addec7763b 100644 (file)
@@ -851,7 +851,8 @@ void E_(EvaluateRPN)( intf_thread_t *p_intf, mvar_t  *vars,
             else
             {
                 i_id = playlist_AddInput( p_sys->p_playlist, p_input,
-                                   PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE );
+                                   PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE,
+                                   VLC_FALSE);
                 msg_Dbg( p_intf, "requested mrl add: %s", mrl );
             }
             E_(SSPushN)( st, i_id );
index 3428849ca3086969aa283753d9d1e84115c4fa2c..b5748067c94b86dea02ae699ea50a4fd20c1012b 100644 (file)
@@ -1367,7 +1367,8 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
         {
             msg_rc( "Trying to add %s to playlist.", newval.psz_string );
             playlist_AddInput( p_playlist, p_item,
-                     PLAYLIST_GO|PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE );
+                     PLAYLIST_GO|PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE,
+                     VLC_FALSE );
         }
     }
     else if( !strcmp( psz_cmd, "enqueue" ) &&
@@ -1379,7 +1380,8 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
         {
             msg_rc( "trying to enqueue %s to playlist", newval.psz_string );
             playlist_AddInput( p_playlist, p_item,
-                               PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE );
+                               PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE,
+                               VLC_FALSE);
         }
     }
     else if( !strcmp( psz_cmd, "playlist" ) )
index cc90eb67c4dacd9dba7fee5608b5261477589616..c33367221d7ce244eb3f0f95659d2a6327ac1eb6 100644 (file)
@@ -419,7 +419,7 @@ static int Open( vlc_object_t * p_this )
                         playlist_BothAddInput( p_playlist, p_input,
                                                p_item_in_category,
                                                PLAYLIST_APPEND, PLAYLIST_END,
-                                               NULL, NULL);
+                                               NULL, NULL, VLC_FALSE );
                     }
                 }
                 else
index cdb0902e5e478099bae34aaf01fa498d0689f47c..714a201b200df2f1beccbc0267fe2f8fb9999890 100644 (file)
@@ -371,7 +371,8 @@ static int Demux( demux_t *p_demux )
                             playlist_BothAddInput( p_playlist, p_input,
                                                    p_item_in_category,
                                             PLAYLIST_APPEND|PLAYLIST_SPREPARSE,
-                                            PLAYLIST_END, NULL, NULL );
+                                            PLAYLIST_END, NULL, NULL,
+                                            VLC_FALSE);
                             free( psz_string );
                         }
                         else continue;
@@ -451,7 +452,8 @@ static int Demux( demux_t *p_demux )
                             playlist_BothAddInput( p_playlist, p_entry,
                                                  p_item_in_category,
                                                  PLAYLIST_APPEND | PLAYLIST_SPREPARSE
-                                                 , PLAYLIST_END, NULL, NULL);
+                                                 , PLAYLIST_END, NULL, NULL,
+                                                 VLC_FALSE );
                             free( psz_string );
                         }
                         else continue;
index 1ce444f96002e495c361e3c64a3cf3ce2fb1f1c4..99a91296813a66aec4823b90b4ded1a4f81642e7 100644 (file)
@@ -270,7 +270,7 @@ static int Demux( demux_t *p_demux )
                     playlist_BothAddInput( p_playlist, p_input,
                                            p_item_in_category,
                                            PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
-                                           PLAYLIST_END, NULL, NULL );
+                                           PLAYLIST_END, NULL, NULL, VLC_FALSE );
                     FREENULL( psz_name );
                     FREENULL( psz_mrl );
                     FREENULL( psz_genre );
index c020f5579178715fdd495398004c7d4efadbba9e..2fe46ab14ccea208b8d58db99600746c413f802e 100644 (file)
@@ -120,7 +120,7 @@ static int Demux( demux_t *p_demux )
         }
         playlist_BothAddInput( p_playlist, p_input, p_item_in_category,
                                PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
-                               PLAYLIST_END, NULL, NULL );
+                               PLAYLIST_END, NULL, NULL, VLC_FALSE );
 
         while( i_options-- ) free( ppsz_options[i_options] );
         if( ppsz_options ) free( ppsz_options );
index 369ff3aff6ed123f3bc458c750e7ab02e43142b2..a4869d436156a8923c4134f3d6efdba078c9c1d9 100644 (file)
@@ -215,7 +215,7 @@ static int Demux( demux_t *p_demux )
         playlist_BothAddInput( p_sys->p_playlist, p_input,
                                p_sys->p_item_in_category,
                                PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
-                               PLAYLIST_END, NULL, NULL );
+                               PLAYLIST_END, NULL, NULL, VLC_FALSE );
     }
 
     HANDLE_PLAY_AND_RELEASE;
index 40c7ebae4259fbeceafe87df56a06e4d306a16f6..39696a62b565eedb55b3360422c6ff3a450fd5a3 100644 (file)
@@ -187,7 +187,7 @@ static int Demux( demux_t *p_demux )
                                         _(VLC_META_ARTIST), "%s", psz_artist );
             playlist_BothAddInput( p_playlist, p_input, p_item_in_category,
                                    PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
-                                   PLAYLIST_END, NULL, NULL );
+                                   PLAYLIST_END, NULL, NULL, VLC_FALSE );
             free( psz_mrl );
             // XXX Not to be a scare monger, but I suspect options are leaked
         }
index e723f6fc73b65dc6b35823f7304f5942be91c966..b3df8e2d8ccff1eb8b4d9c2d37f494a3e0eae9f3 100644 (file)
@@ -163,7 +163,7 @@ static int Demux( demux_t *p_demux )
                 input_ItemCopyOptions( p_current->p_input, p_input );
                 playlist_BothAddInput( p_playlist, p_input, p_item_in_category,
                                        PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
-                                       PLAYLIST_END, NULL, NULL );
+                                       PLAYLIST_END, NULL, NULL, VLC_FALSE );
             }
             else
             {
@@ -220,7 +220,7 @@ static int Demux( demux_t *p_demux )
         input_ItemCopyOptions( p_current->p_input, p_input );
         playlist_BothAddInput( p_playlist, p_input, p_item_in_category,
                                PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
-                               PLAYLIST_END, NULL, NULL );
+                               PLAYLIST_END, NULL, NULL, VLC_FALSE );
         free( psz_mrl_orig );
         psz_mrl = NULL;
     }
index 50cc010c17fdba62b735b419aab97f310150cf44..ca19bf8148feadc0827c9b21f979e376698ed9a0 100644 (file)
@@ -293,7 +293,7 @@ static int Demux( demux_t *p_demux )
                     playlist_BothAddInput( p_playlist, p_input,
                                            p_item_in_category,
                                            PLAYLIST_APPEND | PLAYLIST_SPREPARSE
-                                           , PLAYLIST_END, NULL, NULL );
+                                           , PLAYLIST_END, NULL, NULL, VLC_FALSE );
                     FREENULL( psz_item_name );
                     FREENULL( psz_item_mrl );
                     FREENULL( psz_item_size );
index 08ee00fb4b9a240697a32ac95ec8932318c24cbc..eac3157ec8ee7e956a3c1b6264ee7193d28a8561 100644 (file)
@@ -362,7 +362,7 @@ static int Demux( demux_t *p_demux )
         playlist_BothAddInput( p_sys->p_playlist, p_input,
                                p_sys->p_item_in_category,
                                PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
-                               PLAYLIST_END, NULL, NULL );
+                               PLAYLIST_END, NULL, NULL, VLC_FALSE );
         if( psz_qtnext )
         {
             p_input = input_ItemNewExt( p_sys->p_playlist,
@@ -370,7 +370,7 @@ static int Demux( demux_t *p_demux )
             playlist_BothAddInput( p_sys->p_playlist, p_input,
                                    p_sys->p_item_in_category,
                                    PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
-                                   PLAYLIST_END, NULL, NULL );
+                                   PLAYLIST_END, NULL, NULL, VLC_FALSE );
         }
     }
 
index 59a9f51dabddaab551360950fb8df46db7c0f211..358a599ae625c18a84a50c87efaee524d13bf478 100644 (file)
@@ -408,7 +408,7 @@ static int Demux ( demux_t *p_demux )
 
     playlist_BothAddInput( p_playlist, p_child, p_item_in_category,
                            PLAYLIST_APPEND | PLAYLIST_SPREPARSE, PLAYLIST_END,
-                           NULL, NULL);
+                           NULL, NULL, VLC_FALSE );
     HANDLE_PLAY_AND_RELEASE
     return -1; /* Needed for correct operation of go back */
 }
index 5487f1d3affcce53d547970a2bed3b0cfb33be00..518c6cc42c514a0b2659d5884303223fdd6228da 100644 (file)
@@ -242,7 +242,7 @@ static int DemuxGenre( demux_t *p_demux )
                     playlist_BothAddInput( p_sys->p_playlist, p_input,
                                            p_sys->p_item_in_category,
                                            PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
-                                           PLAYLIST_END, NULL, NULL );
+                                           PLAYLIST_END, NULL, NULL, VLC_FALSE );
                     FREENULL( psz_name );
                 }
                 FREENULL( psz_eltname );
@@ -434,7 +434,7 @@ static int DemuxStation( demux_t *p_demux )
                     playlist_BothAddInput( p_sys->p_playlist, p_input,
                                            p_sys->p_item_in_category,
                                            PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
-                                           PLAYLIST_END, NULL, NULL );
+                                           PLAYLIST_END, NULL, NULL, VLC_FALSE );
 
                     FREENULL( psz_name );
                     FREENULL( psz_mt )
index d19c69269a0c173b58eee16eab6b85f1d80bc49f..ceea35e67e27c15427b5130ba784519f78d1cc0c 100644 (file)
@@ -481,7 +481,7 @@ static vlc_bool_t parse_track_node COMPLEX_INTERFACE
                     playlist_BothAddInput( p_playlist, p_new_input,
                                            p_demux->p_sys->p_item_in_category,
                                            PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
-                                           PLAYLIST_END, NULL, NULL );
+                                           PLAYLIST_END, NULL, NULL, VLC_FALSE );
                     if( p_demux->p_sys->i_identifier <
                         p_demux->p_sys->i_tracklist_entries )
                     {
index adf31885bcdb8692dc0a9d00f09ba80b946773b9..97ff247110b6fd35c7e88451a3ed586559c9e0c5 100644 (file)
@@ -58,7 +58,7 @@
                                     [[[NSFileManager defaultManager]
                                     displayNameAtPath: o_urlString] UTF8String] );
             playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT,
-                               PLAYLIST_END, VLC_TRUE );
+                               PLAYLIST_END, VLC_TRUE, VLC_FALSE );
 
 
             o_url = [NSURL fileURLWithPath: o_urlString];
     [o_controls toogleFullscreen: self];
 }
 
-@end
\ No newline at end of file
+@end
index 517d2889d67aa65d56050cb66b449b277eedf1ea..c21d79d72e13d5d29146d9008ee2727cb834a2f5 100644 (file)
@@ -1011,7 +1011,8 @@ NSLog( @"expandable" );
 
         /* Add the item */
         playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT,
-             i_position == -1 ? PLAYLIST_END : i_position + i_item, VLC_TRUE );
+             i_position == -1 ? PLAYLIST_END : i_position + i_item, VLC_TRUE,
+            VLC_FALSE );
 
         if( i_item == 0 && !b_enqueue )
         {
index c2f3845f758bcad8fc0000244789ef86ead607e6..90e668f439e63ee7e26affc7664d13d7253642c9 100644 (file)
@@ -1314,7 +1314,7 @@ static VLCWizard *_o_sharedInstance = nil;
                 UTF8String] );
 
             playlist_AddInput( p_playlist, p_input, PLAYLIST_STOP, 
-                       PLAYLIST_END, VLC_TRUE );
+                       PLAYLIST_END, VLC_TRUE, VLC_FALSE );
 
             if( x == 0 )
             {
index bf572dc10643455d4443e87415e18046003aa39c..c56b1bac4ef33bb7d6b25575578fdbebe8774427 100644 (file)
@@ -121,7 +121,7 @@ void OpenDialog::ok()
              playlist_Add( THEPL, psz_utf8, NULL,
                            PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO) |
                            ( i ? PLAYLIST_PREPARSE : 0 ),
-                           PLAYLIST_END, VLC_TRUE );
+                           PLAYLIST_END, VLC_TRUE, VLC_FALSE );
          }
 
     }
index fbb945056614bdb3ba4b656530eb8eae024fa89d..52e174b9b5a57ae29f886ba793bfb2cc564e129b 100644 (file)
@@ -85,7 +85,7 @@ void PlaylistDialog::dropEvent(QDropEvent *event)
         QString s = url.toString();
         if( s.length() > 0 ) {
             playlist_Add( THEPL, qtu(s), NULL,
-                          PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE );
+                          PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE, VLC_FALSE );
         }
      }
      event->acceptProposedAction();
index 09a0581679d25d3a6c8bade325af4f3846b6c47c..a71fd9a8dc83cbedf74cf3d9932868d27b133f5b 100644 (file)
@@ -239,7 +239,7 @@ void DialogsProvider::addFromSimple( bool pl, bool go)
                                                ( i ? PLAYLIST_PREPARSE : 0 ) )
                          : ( PLAYLIST_APPEND | PLAYLIST_PREPARSE ),
                       PLAYLIST_END,
-                      pl ? VLC_TRUE : VLC_FALSE );
+                      pl ? VLC_TRUE : VLC_FALSE, VLC_FALSE );
         i++;
     }
 }
@@ -319,7 +319,7 @@ static void openDirectory( intf_thread_t* p_intf, bool pl, bool go )
                                                0, NULL, -1 );
     playlist_AddInput( THEPL, p_input,
                        go ? ( PLAYLIST_APPEND | PLAYLIST_GO ) : PLAYLIST_APPEND,
-                       PLAYLIST_END, pl);
+                       PLAYLIST_END, pl, VLC_FALSE );
     input_Read( THEPL, p_input, VLC_FALSE );
 }
 
@@ -354,7 +354,7 @@ void DialogsProvider::streamingDialog()
 
             playlist_AddExt( THEPL, qtu( o->mrl ), "Streaming",
                              PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END,
-                             -1, &psz_option, 1, VLC_TRUE );
+                             -1, &psz_option, 1, VLC_TRUE, VLC_FALSE );
         }
         delete s;
     }
index 6ecb381142be1eba436f792efe9149fd28fc820b..6b0a77ae29c46bc1b5e70ba9faa8e7931dddad7f 100644 (file)
@@ -521,7 +521,7 @@ void MainInterface::dropEvent(QDropEvent *event)
         if( s.length() > 0 ) {
             playlist_Add( THEPL, qtu(s), NULL,
                           PLAYLIST_APPEND | (first ? PLAYLIST_GO:0),
-                          PLAYLIST_END, VLC_TRUE );
+                          PLAYLIST_END, VLC_TRUE, VLC_FALSE );
             first = false;
         }
      }
index 793a19a31bd8d6c41e46510d46a25c732ae01b0e..3abe162f3e3276c6fe9958ec2ef86b1d9b260e5b 100644 (file)
@@ -453,10 +453,10 @@ void DialogsProvider::OnOpenFileSimple( wxCommandEvent& event )
                 playlist_Add( p_playlist, psz_utf8, NULL,
                               PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO) |
                               (i ? PLAYLIST_PREPARSE : 0 ),
-                              PLAYLIST_END, VLC_TRUE );
+                              PLAYLIST_END, VLC_TRUE, VLC_FALSE );
             else
                 playlist_Add( p_playlist, psz_utf8, NULL,
-                              PLAYLIST_APPEND | PLAYLIST_PREPARSE , PLAYLIST_END , VLC_TRUE);
+                              PLAYLIST_APPEND | PLAYLIST_PREPARSE , PLAYLIST_END , VLC_TRUE, VLC_FALSE );
             wxLocaleFree( psz_utf8 );
         }
     }
@@ -483,7 +483,7 @@ void DialogsProvider::OnOpenDirectory( wxCommandEvent& event )
         char *psz_utf8 = wxFromLocale( path );
         playlist_Add( p_playlist, psz_utf8, NULL,
                       PLAYLIST_APPEND | (event.GetInt() ? PLAYLIST_GO : 0),
-                      PLAYLIST_END, VLC_TRUE );
+                      PLAYLIST_END, VLC_TRUE, VLC_FALSE );
         wxLocaleFree( psz_utf8 );
     }
 
index 65115e71c834b314ce516e4472488a736a0d2c26..c33f58698b08e3532fcd6fdcdbc6436cfd319341 100644 (file)
@@ -1206,13 +1206,13 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
         {
             playlist_AddInput( p_playlist, p_input,
                                PLAYLIST_APPEND | PLAYLIST_GO,
-                               PLAYLIST_END, VLC_TRUE );
+                               PLAYLIST_END, VLC_TRUE, VLC_FALSE );
         }
         else
         {
             playlist_AddInput( p_playlist, p_input,
                                        PLAYLIST_APPEND|PLAYLIST_PREPARSE,
-                                       PLAYLIST_END, VLC_TRUE );
+                                       PLAYLIST_END, VLC_TRUE, VLC_FALSE );
         }
     }
 
index 03bba2420717a139f64a4be95122df7de8c5620c..19504c015d57598c825d4f2451bad39bd652612a 100644 (file)
@@ -1640,7 +1640,7 @@ void WizardDialog::Run()
             input_ItemAddOption( p_input, psz_ttl );
 
             playlist_AddInput( p_playlist, p_input,
-                               PLAYLIST_GO, PLAYLIST_END, VLC_TRUE );
+                               PLAYLIST_GO, PLAYLIST_END, VLC_TRUE, VLC_FALSE );
             vlc_object_release(p_playlist);
         }
         else
index 64199b3c3cfb2e0a7909264a716fc16e0fa8e223..c2e3c4fba5226cb646a9b4bef3aa763cf9ba3638 100644 (file)
@@ -1324,7 +1324,7 @@ bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
 
         playlist_Add( p_playlist, psz_utf8, NULL,
                       PLAYLIST_APPEND | ((i | b_enqueue) ? 0 : PLAYLIST_GO),
-                      PLAYLIST_END, VLC_TRUE );
+                      PLAYLIST_END, VLC_TRUE, VLC_FALSE );
 
         wxDnDLocaleFree( psz_utf8 );
     }
index f3108d8f9b31227011912f3f6d8a5e921cad1ab2..6f9a6ca38e24441b89bd69728274152b449dd240 100644 (file)
@@ -184,12 +184,14 @@ static void resolve_callback(
             playlist_item_t *p_item;
             p_item = playlist_NodeAddInput( p_sys->p_playlist, p_input,
                                             p_sys->p_node_cat,
-                                            PLAYLIST_APPEND, PLAYLIST_END );
+                                            PLAYLIST_APPEND, PLAYLIST_END,
+                                            VLC_FALSE);
             p_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
             p_item->i_flags &= ~PLAYLIST_SAVE_FLAG;
             p_item = playlist_NodeAddInput( p_sys->p_playlist, p_input,
                                             p_sys->p_node_one,
-                                            PLAYLIST_APPEND, PLAYLIST_END );
+                                            PLAYLIST_APPEND, PLAYLIST_END,
+                                            VLC_FALSE );
             p_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
             p_item->i_flags &= ~PLAYLIST_SAVE_FLAG;
        }
index ac4f52e683a24ff7de0c922cdc1ec36968f31911..6ff31ecd44a04e6ff6d46c0167ac486a2522e1ca 100644 (file)
@@ -226,10 +226,12 @@ static void AddItem( services_discovery_t *p_sd, input_item_t * p_input
         return;
     }
     p_item_cat = playlist_NodeAddInput( p_playlist,
-            p_input,p_sd->p_sys->p_node_cat, PLAYLIST_APPEND, PLAYLIST_END );
+            p_input,p_sd->p_sys->p_node_cat, PLAYLIST_APPEND, PLAYLIST_END,
+            VLC_FALSE );
     p_item_cat->i_flags &= ~PLAYLIST_SKIP_FLAG;
     p_item_one = playlist_NodeAddInput( p_playlist,
-            p_input,p_sd->p_sys->p_node_one, PLAYLIST_APPEND, PLAYLIST_END );
+            p_input,p_sd->p_sys->p_node_one, PLAYLIST_APPEND, PLAYLIST_END,
+            VLC_FALSE );
     p_item_one->i_flags &= ~PLAYLIST_SKIP_FLAG;
 
     vlc_object_release( p_playlist );
index 42f6574ab858a9ba8d10fea1652308f778ff0f30..ca3488dabe22523f481062e3df31169aa42dd720 100644 (file)
@@ -167,9 +167,11 @@ static int Open( vlc_object_t *p_this )
                                     p_sys->ppsz_urls[i], 0, NULL, -1 );
         input_ItemAddOption( p_input, "demux=podcast" );
         p_item = playlist_NodeAddInput( p_playlist, p_input, p_sys->p_node_cat,
-                                        PLAYLIST_APPEND, PLAYLIST_END );
+                                        PLAYLIST_APPEND, PLAYLIST_END,
+                                        VLC_FALSE );
         p_item = playlist_NodeAddInput( p_playlist, p_input, p_sys->p_node_one,
-                                        PLAYLIST_APPEND, PLAYLIST_END );
+                                        PLAYLIST_APPEND, PLAYLIST_END,
+                                        VLC_FALSE );
         free( psz_buf );
         p_sys->pp_input[i] = input_CreateThread( p_playlist, p_input );
     }
index 732c9be6bf6b3d71b128776216066109e24776f6..278d03f2b3612b685fad80b45c99f8d2c433df70 100644 (file)
@@ -813,13 +813,14 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint16_t i_hash,
     }
 
     p_item = playlist_NodeAddInput( pl_Get( p_sd ), p_input, p_child,
-                                    PLAYLIST_APPEND, PLAYLIST_END );
+                                    PLAYLIST_APPEND, PLAYLIST_END, VLC_FALSE );
     p_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
     p_item->i_flags &= ~PLAYLIST_SAVE_FLAG;
     p_sap->i_item_id_cat = p_item->i_id;
 
     p_item = playlist_NodeAddInput( pl_Get( p_sd ), p_input,
-                        p_sys->p_node_one, PLAYLIST_APPEND, PLAYLIST_END );
+                        p_sys->p_node_one, PLAYLIST_APPEND, PLAYLIST_END,
+                        VLC_FALSE );
     p_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
     p_item->i_flags &= ~PLAYLIST_SAVE_FLAG;
     p_sap->i_item_id_one = p_item->i_id;
index f219b6e5d2abe28593c2385f13e507c80f6b72a1..87f3520c1a20209a0ff1f817e9cbf5a2e4b9314f 100644 (file)
@@ -139,10 +139,10 @@ static int Open( vlc_object_t *p_this, int i_type )
     p_sys->p_input->b_prefers_tree = VLC_TRUE;
     p_sys->p_node_cat = playlist_NodeAddInput( p_playlist, p_sys->p_input,
                            p_playlist->p_root_category,
-                           PLAYLIST_APPEND, PLAYLIST_END );
+                           PLAYLIST_APPEND, PLAYLIST_END, VLC_FALSE );
     p_sys->p_node_one = playlist_NodeAddInput( p_playlist, p_sys->p_input,
                            p_playlist->p_root_onelevel,
-                           PLAYLIST_APPEND, PLAYLIST_END );
+                           PLAYLIST_APPEND, PLAYLIST_END, VLC_FALSE );
     p_sys->p_node_cat->i_flags |= PLAYLIST_RO_FLAG;
     p_sys->p_node_cat->i_flags |= PLAYLIST_SKIP_FLAG;
     p_sys->p_node_one->i_flags |= PLAYLIST_RO_FLAG;
index e05900b3fb956cb1e0e327c22363c7528adc33e9..8c49df872e987315a8918055278e1ce4302ccc93 100644 (file)
@@ -240,7 +240,8 @@ void UPnPHandler::AddContent( playlist_item_t *p_parent, ContentNode *node )
         ItemNode *iNode = (ItemNode *)node;
         input_item_t *p_input = input_ItemNew( p_sd, iNode->getResource(), title );
         playlist_BothAddInput( p_sys->p_playlist, p_input, p_parent,
-                               PLAYLIST_APPEND, PLAYLIST_END, NULL, NULL );
+                               PLAYLIST_APPEND, PLAYLIST_END, NULL, NULL,
+                               VLC_FALSE );
     } else if ( node->isContainerNode() )
     {
         ContainerNode *conNode = (ContainerNode *)node;
index 40a0febc041027517d706dc6c62fd18dfbf7972b..28513d97d0536d64fefc3e4447475280fca6b148 100644 (file)
@@ -871,7 +871,8 @@ void MediaServer::_buildPlaylist( Container* parent )
                                                item->getTitle() );
         int i_cat;
         playlist_BothAddInput( p_playlist, p_input, parentNode,
-                               PLAYLIST_APPEND, PLAYLIST_END, &i_cat, NULL );
+                               PLAYLIST_APPEND, PLAYLIST_END, &i_cat, NULL,
+                               VLC_FALSE );
         /* TODO: do this better by storing ids */
         playlist_item_t *p_node = playlist_ItemGetById( p_playlist, i_cat, VLC_FALSE );
         assert( p_node );
index 6da3d6376a4f023d82ba7c96d52d129c019239b6..2813682fa5e14db75a1f52a1f658f23301563698 100644 (file)
@@ -49,7 +49,9 @@ VLC_EXPORT (int, libvlc_InternalAddIntf, ( libvlc_int_t *, const char *, vlc_boo
 struct libvlc_instance_t
 {
     libvlc_int_t *p_libvlc_int;
-    vlm_t      *p_vlm;
+    vlm_t        *p_vlm;
+    int           b_playlist_locked;
+    vlc_mutex_t   instance_lock;
 };
 
 struct libvlc_input_t
index 22a75a6fc4aef5bda3ea4107a78afecca7a45e3e..9a17a838fc1084772865ff49af6325b438d7f953 100644 (file)
 
 #define PL p_instance->p_libvlc_int->p_playlist
 
+static inline int playlist_was_locked( libvlc_instance_t *p_instance )
+{
+    int was_locked;
+    vlc_mutex_lock( &p_instance->instance_lock );
+    was_locked = p_instance->b_playlist_locked;
+    vlc_mutex_unlock( &p_instance->instance_lock );
+    return was_locked;
+}
+
+static inline void playlist_mark_locked( libvlc_instance_t *p_instance,
+                                         int locked )
+{
+    vlc_mutex_lock( &p_instance->instance_lock );
+    p_instance->b_playlist_locked = locked;
+    vlc_mutex_unlock( &p_instance->instance_lock );
+}
+
 void libvlc_playlist_loop( libvlc_instance_t *p_instance, vlc_bool_t loop,
                            libvlc_exception_t *p_e)
 {
@@ -42,30 +59,54 @@ void libvlc_playlist_play( libvlc_instance_t *p_instance, int i_id,
                            int i_options, char **ppsz_options,
                            libvlc_exception_t *p_e )
 {
+    int did_lock = 0;
     assert( PL );
     ///\todo Handle additionnal options
 
     if( PL->items.i_size == 0 ) RAISEVOID( "Empty playlist" );
     if( i_id > 0 )
     {
-        playlist_item_t *p_item = playlist_ItemGetByInputId( PL, i_id,
-                                                           PL->status.p_node );
-        if( !p_item ) RAISEVOID( "Unable to find item" );
-
-        playlist_Control( PL, PLAYLIST_VIEWPLAY, VLC_FALSE,
+        playlist_item_t *p_item;
+        if (! playlist_was_locked( p_instance ) )
+        {
+            playlist_mark_locked( p_instance, 1 );
+            vlc_mutex_lock( &PL->object_lock );
+            did_lock = 1;
+        }
+
+        p_item = playlist_ItemGetByInputId( PL, i_id,
+                                            PL->status.p_node );
+        if( !p_item )
+        {
+            if( did_lock == 1 )
+            {
+                vlc_mutex_unlock( &PL->object_lock );
+                playlist_mark_locked( p_instance, 0 );
+            }
+            RAISEVOID( "Unable to find item" );
+        }
+
+        playlist_Control( PL, PLAYLIST_VIEWPLAY, VLC_TRUE,
                           PL->status.p_node, p_item );
+        if( did_lock == 1 )
+        {
+            vlc_mutex_unlock( &PL->object_lock );
+            playlist_mark_locked( p_instance, 0 );
+        }
     }
     else
     {
-        playlist_Play( PL );
+        playlist_Control( PL, PLAYLIST_PLAY,
+                          playlist_was_locked( p_instance ) );
     }
 }
 
 void libvlc_playlist_pause( libvlc_instance_t *p_instance,
-                           libvlc_exception_t *p_e )
+                            libvlc_exception_t *p_e )
 {
     assert( PL );
-    if( playlist_Pause( PL ) != VLC_SUCCESS )
+    if( playlist_Control( PL, PLAYLIST_PAUSE,
+                          playlist_was_locked( p_instance ) ) != VLC_SUCCESS )
         RAISEVOID( "Empty playlist" );
 }
 
@@ -74,29 +115,32 @@ void libvlc_playlist_stop( libvlc_instance_t *p_instance,
                            libvlc_exception_t *p_e )
 {
     assert( PL );
-    if( playlist_Stop( PL ) != VLC_SUCCESS )
+    if( playlist_Control( PL, PLAYLIST_STOP,
+                          playlist_was_locked( p_instance ) ) != VLC_SUCCESS )
         RAISEVOID( "Empty playlist" );
 }
 
 void libvlc_playlist_clear( libvlc_instance_t *p_instance,
-                           libvlc_exception_t *p_e )
+                            libvlc_exception_t *p_e )
 {
     assert( PL );
-    playlist_Clear( PL, VLC_FALSE );
+    playlist_Clear( PL, playlist_was_locked( p_instance ) );
 }
 
 void libvlc_playlist_next( libvlc_instance_t *p_instance,
                            libvlc_exception_t *p_e )
 {
     assert( PL );
-    if( playlist_Next( PL ) != VLC_SUCCESS )
+    if( playlist_Control( PL, PLAYLIST_SKIP, playlist_was_locked( p_instance ),
+                          1 ) != VLC_SUCCESS )
         RAISEVOID( "Empty playlist" );
 }
 
 void libvlc_playlist_prev( libvlc_instance_t *p_instance,
                            libvlc_exception_t *p_e )
 {
-    if( playlist_Prev( PL ) != VLC_SUCCESS )
+    if( playlist_Control( PL, PLAYLIST_SKIP, playlist_was_locked( p_instance ),
+                          -1  ) != VLC_SUCCESS )
         RAISEVOID( "Empty playlist" );
 }
 
@@ -113,19 +157,25 @@ int libvlc_playlist_add_extended( libvlc_instance_t *p_instance,
                                   libvlc_exception_t *p_e )
 {
     assert( PL );
+    if( playlist_was_locked( p_instance ) )
+    {
+        libvlc_exeption_raise( p_e, "You must unlock playlist before "
+                               "calling libvlc_playlist_add" );
+        return VLC_EGENERIC;
+    }
     return playlist_AddExt( PL, psz_uri, psz_name,
                             PLAYLIST_INSERT, PLAYLIST_END, -1, ppsz_options,
-                            i_options, 1 );
+                            i_options, 1, VLC_FALSE );
 }
 
 
-
 int libvlc_playlist_delete_item( libvlc_instance_t *p_instance, int i_id,
                                  libvlc_exception_t *p_e )
 {
     assert( PL );
 
-    if( playlist_DeleteFromInput( PL, i_id, VLC_FALSE ) )
+    if( playlist_DeleteFromInput( PL, i_id,
+                                  playlist_was_locked( p_instance ) ) )
     {
         libvlc_exception_raise( p_e, "deletion failed" );
         return VLC_ENOITEM;
@@ -144,9 +194,25 @@ int libvlc_playlist_items_count( libvlc_instance_t *p_instance,
                                  libvlc_exception_t *p_e )
 {
     assert( PL );
-    return PL->items.i_size;
+    return playlist_CurrentSize( PL );
 }
 
+void libvlc_playlist_lock( libvlc_instance_t *p_instance )
+{
+    assert( PL );
+    vlc_mutex_lock( &PL->object_lock );
+    p_instance->b_playlist_locked = 1;
+}
+
+void libvlc_playlist_unlock( libvlc_instance_t *p_instance )
+{
+    assert( PL );
+    p_instance->b_playlist_locked = 0;
+    vlc_mutex_unlock( &PL->object_lock );
+}
+
+
+
 libvlc_input_t * libvlc_playlist_get_input( libvlc_instance_t *p_instance,
                                             libvlc_exception_t *p_e )
 {
index 277fae3d4bddf7e1af2bccc8a2fc7918fb8f1661..a8c72bfe7037dd9f8a7037684ec53f6f6fd3a788 100644 (file)
@@ -314,7 +314,7 @@ int VLC_AddTarget( int i_object, char const *psz_target,
     LIBVLC_PLAYLIST_FUNC;
     i_err = playlist_AddExt( p_libvlc->p_playlist, psz_target,
                              NULL,  i_mode, i_pos, -1,
-                             ppsz_options, i_options, VLC_TRUE );
+                             ppsz_options, i_options, VLC_TRUE, VLC_FALSE );
     LIBVLC_PLAYLIST_FUNC_END;
     return i_err;
 }
index 0921bbb96bf912f785779677b34f725617e7c5af..c318c7d46e7a6b5dc912cd9c74559b21eafbb10c 100644 (file)
@@ -325,13 +325,13 @@ LRESULT CALLBACK WMCOPYWNDPROC( HWND hwnd, UINT uMsg, WPARAM wParam,
                     NULL, PLAYLIST_APPEND ,
                     PLAYLIST_END, -1,
                     (char const **)( i_options ? &ppsz_argv[i_opt+1] : NULL ),
-                    i_options, VLC_TRUE );
+                    i_options, VLC_TRUE, VLC_FALSE );
                 } else {
                   playlist_AddExt( p_playlist, ppsz_argv[i_opt],
                     NULL, PLAYLIST_APPEND | PLAYLIST_GO,
                     PLAYLIST_END, -1,
                     (char const **)( i_options ? &ppsz_argv[i_opt+1] : NULL ),
-                    i_options, VLC_TRUE );
+                    i_options, VLC_TRUE, VLC_FALSE );
                 }
 
                 i_opt += i_options;
index cc47aa110407756075163ff7c7eb273ab3684629..9c4f6b72f9b90b29dc7ef1bfa84c8f17f1b028dc 100644 (file)
@@ -136,7 +136,8 @@ void playlist_Clear( playlist_t * p_playlist, vlc_bool_t b_locked )
  * This function is to be used only by the playlist */
 int playlist_DeleteFromItemId( playlist_t *p_playlist, int i_id )
 {
-    playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id,  VLC_TRUE );
+    playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id,
+                                                    VLC_TRUE );
     if( !p_item ) return VLC_EGENERIC;
     return DeleteInner( p_playlist, p_item, VLC_TRUE );
 }
@@ -157,10 +158,10 @@ int playlist_DeleteFromItemId( playlist_t *p_playlist, int i_id )
  */
 int playlist_Add( playlist_t *p_playlist, const char *psz_uri,
                   const char *psz_name, int i_mode, int i_pos,
-                  vlc_bool_t b_playlist )
+                  vlc_bool_t b_playlist, vlc_bool_t b_locked )
 {
     return playlist_AddExt( p_playlist, psz_uri, psz_name,
-                            i_mode, i_pos, -1, NULL, 0, b_playlist );
+                            i_mode, i_pos, -1, NULL, 0, b_playlist, b_locked );
 }
 
 /**
@@ -182,14 +183,15 @@ int playlist_Add( playlist_t *p_playlist, const char *psz_uri,
 int playlist_AddExt( playlist_t *p_playlist, const char * psz_uri,
                      const char *psz_name, int i_mode, int i_pos,
                      mtime_t i_duration, const char *const *ppsz_options,
-                     int i_options, vlc_bool_t b_playlist )
+                     int i_options, vlc_bool_t b_playlist, vlc_bool_t b_locked )
 {
     int i_ret;
     input_item_t *p_input = input_ItemNewExt( p_playlist, psz_uri, psz_name,
                                               i_options, ppsz_options,
                                               i_duration );
 
-    i_ret = playlist_AddInput( p_playlist, p_input, i_mode, i_pos, b_playlist );
+    i_ret = playlist_AddInput( p_playlist, p_input, i_mode, i_pos, b_playlist,
+                               b_locked );
     if( i_ret == VLC_SUCCESS )
         return p_input->i_id;
     return -1;
@@ -197,7 +199,8 @@ int playlist_AddExt( playlist_t *p_playlist, const char * psz_uri,
 
 /** Add an input item to the playlist node */
 int playlist_AddInput( playlist_t* p_playlist, input_item_t *p_input,
-                      int i_mode, int i_pos, vlc_bool_t b_playlist )
+                       int i_mode, int i_pos, vlc_bool_t b_playlist,
+                       vlc_bool_t b_locked )
 {
     playlist_item_t *p_item_cat, *p_item_one;
 
@@ -205,7 +208,7 @@ int playlist_AddInput( playlist_t* p_playlist, input_item_t *p_input,
         PL_DEBUG( "adding item `%s' ( %s )", p_input->psz_name,
                                              p_input->psz_uri );
 
-    PL_LOCK;
+    if( !b_locked ) PL_LOCK;
 
     /* Add to ONELEVEL */
     p_item_one = playlist_ItemNewFromInput( p_playlist, p_input );
@@ -223,7 +226,7 @@ int playlist_AddInput( playlist_t* p_playlist, input_item_t *p_input,
 
     GoAndPreparse( p_playlist, i_mode, p_item_cat, p_item_one );
 
-    PL_UNLOCK;
+    if( !b_locked ) PL_UNLOCK;
     return VLC_SUCCESS;
 }
 
@@ -233,12 +236,12 @@ int playlist_BothAddInput( playlist_t *p_playlist,
                            input_item_t *p_input,
                            playlist_item_t *p_direct_parent,
                            int i_mode, int i_pos,
-                           int *i_cat, int *i_one )
+                           int *i_cat, int *i_one, vlc_bool_t b_locked )
 {
     playlist_item_t *p_item_cat, *p_item_one, *p_up;
     int i_top;
     assert( p_input );
-    vlc_mutex_lock( & p_playlist->object_lock );
+    if( !b_locked ) PL_LOCK;
 
     /* Add to category */
     p_item_cat = playlist_ItemNewFromInput( p_playlist, p_input );
@@ -271,7 +274,7 @@ int playlist_BothAddInput( playlist_t *p_playlist,
     if( i_cat ) *i_cat = p_item_cat->i_id;
     if( i_one ) *i_one = p_item_one->i_id;
 
-    vlc_mutex_unlock( &p_playlist->object_lock );
+    if( !b_locked ) PL_UNLOCK;
     return VLC_SUCCESS;
 }
 
@@ -279,19 +282,20 @@ int playlist_BothAddInput( playlist_t *p_playlist,
 playlist_item_t * playlist_NodeAddInput( playlist_t *p_playlist,
                                          input_item_t *p_input,
                                          playlist_item_t *p_parent,
-                                         int i_mode, int i_pos )
+                                         int i_mode, int i_pos,
+                                         vlc_bool_t b_locked )
 {
     playlist_item_t *p_item;
     assert( p_input );
     assert( p_parent && p_parent->i_children != -1 );
 
-    vlc_mutex_lock( &p_playlist->object_lock );
+    if( !b_locked ) PL_LOCK;
 
     p_item = playlist_ItemNewFromInput( p_playlist, p_input );
     if( p_item == NULL ) return NULL;
     AddItem( p_playlist, p_item, p_parent, i_mode, i_pos );
 
-    vlc_mutex_unlock( &p_playlist->object_lock );
+    if( !b_locked ) PL_UNLOCK;
 
     return p_item;
 }