playlist: Move more members as private.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Sat, 27 Sep 2008 17:12:07 +0000 (19:12 +0200)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Sat, 27 Sep 2008 17:12:39 +0000 (19:12 +0200)
22 files changed:
include/vlc_playlist.h
modules/access/cdda.c
modules/access/cdda/info.c
modules/codec/cmml/intf.c
modules/control/gestures.c
modules/control/hotkeys.c
modules/control/http/http.c
modules/control/http/util.c
modules/control/rc.c
modules/gui/macosx/intf.m
modules/gui/macosx/playlist.m
modules/gui/ncurses.c
modules/misc/audioscrobbler.c
modules/misc/lua/libs/input.c
modules/misc/lua/libs/playlist.c
src/control/playlist.c
src/libvlccore.sym
src/playlist/control.c
src/playlist/engine.c
src/playlist/item.c
src/playlist/playlist_internal.h
src/playlist/services_discovery.c

index 8307d40..ee17144 100644 (file)
@@ -158,14 +158,6 @@ struct playlist_t
 {
     VLC_COMMON_MEMBERS
 
-    struct playlist_services_discovery_support_t {
-        /* the playlist items for category and onelevel */
-        playlist_item_t*    p_cat;
-        playlist_item_t*    p_one;
-        services_discovery_t * p_sd; /**< Loaded service discovery modules */
-    } ** pp_sds;
-    int                   i_sds;   /**< Number of service discovery modules */
-
     playlist_item_array_t items; /**< Arrays of items */
     playlist_item_array_t all_items; /**< Array of items and nodes */
     playlist_item_array_t items_to_delete; /**< Array of items and nodes to
@@ -194,34 +186,11 @@ struct playlist_t
     bool            b_auto_preparse;
 
     /* Runtime */
-    input_thread_t *      p_input;  /**< the input thread associated
-                                     * with the current item */
     int                   i_sort; /**< Last sorting applied to the playlist */
     int                   i_order; /**< Last ordering applied to the playlist */
     mtime_t               gc_date;
     bool            b_cant_sleep;
 
-    struct {
-        /* Current status. These fields are readonly, only the playlist
-         * main loop can touch it*/
-        playlist_status_t   i_status;  /**< Current status of playlist */
-        playlist_item_t *   p_item; /**< Currently playing/active item */
-        playlist_item_t *   p_node; /**< Current node to play from */
-    } status;
-
-    struct {
-        /* Request. Use this to give orders to the playlist main loop  */
-        playlist_status_t   i_status; /**< requested playlist status */
-        playlist_item_t *   p_node;   /**< requested node to play from */
-        playlist_item_t *   p_item;   /**< requested item to play in the node */
-
-        int                 i_skip;   /**< Number of items to skip */
-
-        bool          b_request;/**< Set to true by the requester
-                                           The playlist sets it back to false
-                                           when processing the request */
-        vlc_mutex_t         lock;     /**< Lock to protect request */
-    } request;
 };
 
 /** Helper to add an item */
@@ -316,19 +285,15 @@ VLC_EXPORT( int, playlist_PreparseEnqueueItem, (playlist_t *, playlist_item_t *)
 /** Request the art for an input item to be fetched */
 VLC_EXPORT( int, playlist_AskForArtEnqueue, (playlist_t *, input_item_t *) );
 
-/********************** Services discovery ***********************/
-
-/** Add a list of comma-separated service discovery modules */
-VLC_EXPORT( int, playlist_ServicesDiscoveryAdd, (playlist_t *, const char *));
-/** Remove a services discovery module by name */
-VLC_EXPORT( int, playlist_ServicesDiscoveryRemove, (playlist_t *, const char *));
-/** Check whether a given SD is loaded */
-VLC_EXPORT( bool, playlist_IsServicesDiscoveryLoaded, ( playlist_t *,const char *));
-
 /* Playlist sorting */
 VLC_EXPORT( int,  playlist_TreeMove, ( playlist_t *, playlist_item_t *, playlist_item_t *, int ) );
 VLC_EXPORT( int,  playlist_RecursiveNodeSort, ( playlist_t *, playlist_item_t *,int, int ) );
 
+VLC_EXPORT( playlist_item_t *,  playlist_CurrentPlayingItem, ( playlist_t * ) );
+VLC_EXPORT( int,  playlist_CurrentId, ( playlist_t * ) );
+VLC_EXPORT( bool,  playlist_IsPlaying, ( playlist_t * ) );
+VLC_EXPORT( int,   playlist_Status, ( playlist_t * ) );
+
 /**
  * Export a node of the playlist to a certain type of playlistfile
  * \param p_playlist the playlist to export
@@ -339,6 +304,17 @@ VLC_EXPORT( int,  playlist_RecursiveNodeSort, ( playlist_t *, playlist_item_t *,
  */
 VLC_EXPORT( int,  playlist_Export, ( playlist_t *p_playlist, const char *psz_name, playlist_item_t *p_export_root, const char *psz_type ) );
 
+/********************** Services discovery ***********************/
+
+/** Add a list of comma-separated service discovery modules */
+VLC_EXPORT( int, playlist_ServicesDiscoveryAdd, (playlist_t *, const char *));
+/** Remove a services discovery module by name */
+VLC_EXPORT( int, playlist_ServicesDiscoveryRemove, (playlist_t *, const char *));
+/** Check whether a given SD is loaded */
+VLC_EXPORT( bool, playlist_IsServicesDiscoveryLoaded, ( playlist_t *,const char *));
+
+
+
 /********************************************************
  * Item management
  ********************************************************/
@@ -427,22 +403,12 @@ static  inline input_thread_t * __pl_CurrentInput( vlc_object_t * p_this )
     return p_input;
 }
 
-/** Tell if the playlist is currently running */
-#define playlist_IsPlaying( pl ) ( pl->status.i_status == PLAYLIST_RUNNING && \
-            !(pl->request.b_request && pl->request.i_status == PLAYLIST_STOPPED) )
-
-#define playlist_IsStopped( pl ) ( pl->status.i_status == PLAYLIST_STOPPED || \
-            (pl->request.b_request && pl->request.i_status == PLAYLIST_STOPPED) )
-
 /** Tell if the playlist is empty */
 #define playlist_IsEmpty( pl ) ( pl->items.i_size == 0 )
 
 /** Tell the number of items in the current playing context */
 #define playlist_CurrentSize( pl ) pl->current.i_size
 
-/** Tell the current item id in current  playing context */
-#define playlist_CurrentId( pl ) pl->status.p_item->i_id
-
 /** Ask the playlist to do some work */
 #define playlist_Signal( p_playlist ) vlc_object_signal( p_playlist )
 
index 9f09682..3d1cadb 100644 (file)
@@ -198,8 +198,8 @@ static int Open( vlc_object_t *p_this )
                 input_item_t *p_current = input_GetItem( p_input );
                 playlist_item_t *p_item;
 
-                if( p_playlist->status.p_item->p_input == p_current )
-                    p_item = p_playlist->status.p_item;
+                if( playlist_CurrentPlayingItem(p_playlist)->p_input == p_current )
+                    p_item = playlist_CurrentPlayingItem(p_playlist);
                 else
                     p_item = playlist_ItemGetByInput( p_playlist, p_current, pl_Unlocked );
 
index e90b28c..8639388 100644 (file)
@@ -884,7 +884,7 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
         {
             p_item = playlist_ItemGetByInput( p_playlist, input_GetItem(p_input), pl_Unlocked );
 
-            if( p_item == p_playlist->status.p_item && !b_single_track )
+            if( p_item == playlist_CurrentPlayingItem(p_playlist) && !b_single_track )
                 b_play = true;
             else
                 b_play = false;
@@ -964,7 +964,7 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
     if( b_play )
     {
         playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Unlocked,
-                          p_playlist->status.p_item, NULL );
+                          playlist_CurrentPlayingItem(p_playlist), NULL );
     }
 
     if (p_playlist) pl_Release( p_access );
index a93fe44..e9d54f3 100644 (file)
@@ -440,7 +440,7 @@ static void FollowAnchor ( intf_thread_t *p_intf )
         p_playlist = pl_Hold( p_intf );
 
         /* Get new URL */
-        p_current_item = p_playlist->status.p_item;
+        p_current_item = playlist_CurrentPlayingItem( p_playlist );
         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\"", psz_uri );
@@ -668,7 +668,7 @@ void GoBack( intf_thread_t *p_intf )
         return;
     }
 
-    p_current_item = p_playlist->status.p_item;
+    p_current_item = playlist_CurrentPlayingItem( p_playlist );
 
     /* Save the currently-playing media in a new history item */
     psz_timed_url = GetTimedURLFromPlaylistItem( p_intf, p_current_item );
@@ -750,7 +750,7 @@ void GoForward( intf_thread_t *p_intf )
         vlc_object_release( p_playlist );
         return;
     }
-    p_current_item = p_playlist->status.p_item;
+    p_current_item = playlist_CurrentPlayingItem( p_playlist );
     p_new_history_item->psz_uri = GetTimedURLFromPlaylistItem( p_intf,
             p_current_item );
     p_new_history_item->psz_name = p_new_history_item->psz_uri;
index a2e4093..940bbc4 100644 (file)
@@ -139,15 +139,7 @@ static int gesture( int i_pattern, int i_num )
  *****************************************************************************/
 static input_thread_t * input_from_playlist ( playlist_t *p_playlist )
 {
-    input_thread_t * p_input;
-
-    PL_LOCK;
-    p_input = p_playlist->p_input;
-    if( p_input )
-        vlc_object_hold( p_input );
-    PL_UNLOCK;
-
-    return p_input;
+    return playlist_CurrentInput( p_playlist );
 }
 
 /*****************************************************************************
index 68161c3..9766301 100644 (file)
@@ -174,11 +174,7 @@ static void Run( intf_thread_t *p_intf )
         canc = vlc_savecancel();
 
         /* Update the input */
-        PL_LOCK;
-        p_input = p_playlist->p_input;
-        if( p_input )
-            vlc_object_hold( p_input );
-        PL_UNLOCK;
+        p_input = playlist_CurrentInput( p_playlist );
 
         /* Update the vout */
         p_last_vout = p_vout;
@@ -978,9 +974,10 @@ static void SetBookmark( intf_thread_t *p_intf, int i_num )
     sprintf( psz_bookmark_name, "bookmark%i", i_num );
     var_Create( p_intf, psz_bookmark_name,
                 VLC_VAR_STRING|VLC_VAR_DOINHERIT );
-    if( p_playlist->status.p_item )
+    playlist_item_t * p_item = playlist_CurrentPlayingItem( p_playlist );
+    if( p_item )
     {
-        char *psz_uri = input_item_GetURI( p_playlist->status.p_item->p_input );
+        char *psz_uri = input_item_GetURI( 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 );
index d66e8f1..a1f77f2 100644 (file)
@@ -384,10 +384,9 @@ static void ParseExecute( httpd_file_sys_t *p_args, char *p_buffer,
 
     assert( p_sys->p_input == NULL );
     /* FIXME: proper locking anyone? */
-    p_sys->p_input = p_sys->p_playlist->p_input;
+    p_sys->p_input = playlist_CurrentInput( p_sys->p_playlist );
     if( p_sys->p_input )
     {
-        vlc_object_hold( p_sys->p_input );
         var_Get( p_sys->p_input, "position", &val);
         sprintf( position, "%d" , (int)((val.f_float) * 100.0));
         var_Get( p_sys->p_input, "time", &val);
index 8abfb35..e04bdfc 100644 (file)
@@ -352,10 +352,10 @@ void PlaylistListNode( intf_thread_t *p_intf, playlist_t *p_pl,
             char value[512];
             char *psz;
             mvar_t *itm = mvar_New( name, "set" );
-
-            if( p_pl->status.p_item && p_node &&
-                p_pl->status.p_item->p_input && p_node->p_input &&
-                p_pl->status.p_item->p_input->i_id == p_node->p_input->i_id )
+            playlist_item_t * p_item = playlist_CurrentPlayingItem(p_pl);
+            if( p_item && p_node &&
+                p_item->p_input && p_node->p_input &&
+                p_item->p_input->i_id == p_node->p_input->i_id )
             {
                 mvar_AppendNewVar( itm, "current", "1" );
             }
index 9c8b627..b8f4e68 100644 (file)
@@ -553,24 +553,25 @@ static void Run( intf_thread_t *p_intf )
             (p_playlist != NULL) )
         {
             PL_LOCK;
-            if( (p_intf->p_sys->i_last_state != p_playlist->status.i_status) &&
-                (p_playlist->status.i_status == PLAYLIST_STOPPED) )
+            int status = playlist_Status( p_playlist );
+            if( (p_intf->p_sys->i_last_state != status) &&
+                (status == PLAYLIST_STOPPED) )
             {
                 p_intf->p_sys->i_last_state = PLAYLIST_STOPPED;
                 msg_rc( STATUS_CHANGE "( stop state: 5 )" );
             }
             else if(
-                (p_intf->p_sys->i_last_state != p_playlist->status.i_status) &&
-                (p_playlist->status.i_status == PLAYLIST_RUNNING) )
+                (p_intf->p_sys->i_last_state != status) &&
+                (status == PLAYLIST_RUNNING) )
             {
-                p_intf->p_sys->i_last_state = p_playlist->status.i_status;
+                p_intf->p_sys->i_last_state = PLAYLIST_RUNNING;
                  msg_rc( STATUS_CHANGE "( play state: 3 )" );
             }
             else if(
-                (p_intf->p_sys->i_last_state != p_playlist->status.i_status) &&
-                (p_playlist->status.i_status == PLAYLIST_PAUSED) )
+                (p_intf->p_sys->i_last_state != status) &&
+                (status == PLAYLIST_PAUSED) )
             {
-                p_intf->p_sys->i_last_state = p_playlist->status.i_status;
+                p_intf->p_sys->i_last_state = PLAYLIST_PAUSED;
                 msg_rc( STATUS_CHANGE "( pause state: 4 )" );
             }
             PL_UNLOCK;
@@ -993,7 +994,7 @@ static int StateChanged( vlc_object_t *p_this, char const *psz_cmd,
     {
         p_playlist = pl_Hold( p_input );
         char cmd[6];
-        switch( p_playlist->status.i_status )
+        switch( playlist_Status( p_playlist ) )
         {
         case PLAYLIST_STOPPED:
             strcpy( cmd, "stop" );
@@ -1304,20 +1305,20 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
 
     intf_thread_t *p_intf = (intf_thread_t*)p_this;
     playlist_t *p_playlist = pl_Hold( p_this );
+    input_thread_t * p_input = playlist_CurrentInput( p_playlist );
 
-    PL_LOCK;
-    if( p_playlist->p_input )
+    if( p_input )
     {
-        var_Get( p_playlist->p_input, "state", &val );
+        var_Get( p_input, "state", &val );
+        vlc_object_release( p_input );
+
         if( ( val.i_int == PAUSE_S ) || ( val.i_int == PLAYLIST_PAUSED ) )
         {
             msg_rc( _("Type 'menu select' or 'pause' to continue.") );
-            vlc_object_release( p_playlist );
-            PL_UNLOCK;
+            pl_Release( p_this );
             return VLC_EGENERIC;
         }
     }
-    PL_UNLOCK;
 
     /* Parse commands that require a playlist */
     if( !strcmp( psz_cmd, "prev" ) )
@@ -1476,18 +1477,19 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
     }
     else if( !strcmp( psz_cmd, "status" ) )
     {
-        if( p_playlist->p_input )
+        input_thread_t * p_input = playlist_CurrentInput( p_playlist );
+        if( p_input )
         {
             /* Replay the current state of the system. */
             char *psz_uri =
-                    input_item_GetURI( input_GetItem( p_playlist->p_input ) );
+                    input_item_GetURI( 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" ));
 
             PL_LOCK;
-            switch( p_playlist->status.i_status )
+            switch( playlist_Status(p_playlist) )
             {
                 case PLAYLIST_STOPPED:
                     msg_rc( STATUS_CHANGE "( stop state: 5 )" );
@@ -1503,6 +1505,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
                     break;
             }
             PL_UNLOCK;
+            vlc_object_release( p_input );
         }
     }
 
@@ -1514,7 +1517,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
         msg_rc( "unknown command!" );
     }
 
-    vlc_object_release( p_playlist );
+    pl_Release( p_this );
     return VLC_SUCCESS;
 }
 
@@ -1913,19 +1916,22 @@ static int Menu( vlc_object_t *p_this, char const *psz_cmd,
     }
 
     p_playlist = pl_Hold( p_this );
+    input_thread_t * p_input = playlist_CurrentInput( p_playlist );
 
-    if( p_playlist->p_input )
+    if( p_input )
     {
-        var_Get( p_playlist->p_input, "state", &val );
+        var_Get( p_input, "state", &val );
+        vlc_object_release( p_input );
+
         if( ( ( val.i_int == PAUSE_S ) || ( val.i_int == PLAYLIST_PAUSED ) ) &&
             ( strcmp( newval.psz_string, "select" ) != 0 ) )
         {
             msg_rc( _("Type 'menu select' or 'pause' to continue.") );
-            vlc_object_release( p_playlist );
+            pl_Release( p_this );
             return VLC_EGENERIC;
         }
     }
-    vlc_object_release( p_playlist );
+    pl_Release( p_this );
 
     val.psz_string = strdup( newval.psz_string );
     if( !val.psz_string )
index 84de154..75a346c 100644 (file)
@@ -1802,12 +1802,11 @@ end:
     if( p_input && vlc_object_alive (p_input) )
     {
         NSString *o_temp;
-        if( input_item_GetNowPlaying ( p_playlist->status.p_item->p_input ) )
-            o_temp = [NSString stringWithUTF8String: 
-                input_item_GetNowPlaying ( p_playlist->status.p_item->p_input )];
+        playlist_item_t * p_item = playlist_CurrentPlayingItem( p_playlist );
+        if( input_item_GetNowPlaying( p_item->p_input ) )
+            o_temp = [NSString stringWithUTF8String:input_item_GetNowPlaying( p_item->p_input )];
         else
-            o_temp = [NSString stringWithUTF8String:
-                p_playlist->status.p_item->p_input->psz_name];
+            o_temp = [NSString stringWithUTF8String:p_item->p_input->psz_name];
         [self setScrollField: o_temp stopAfter:-1];
         [[[self getControls] getFSPanel] setStreamTitle: o_temp];
         vlc_object_release( p_input );
index 9ee7912..b4d9e24 100644 (file)
     playlist_item_t *p_item, *p_temp_item;
     NSMutableArray *o_array = [NSMutableArray array];
 
-    p_item = p_playlist->status.p_item;
+    p_item = playlist_CurrentPlayingItem( p_playlist );
     if( p_item == NULL )
     {
-        vlc_object_release(p_playlist);
+        pl_Release( VLCIntf );
         return;
     }
 
 
     }
 
-    vlc_object_release( p_playlist );
-
+    pl_Release( VLCIntf );
 }
 
 /* Check if p_item is a child of p_node recursively. We need to check the item
         if( p_item->i_children != -1 )
         //is a node and not an item
         {
-            if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
-                [self isItem: p_playlist->status.p_item inNode:
+            if( playlist_Status( p_playlist ) != PLAYLIST_STOPPED &&
+                [self isItem: playlist_CurrentPlayingItem( p_playlist ) inNode:
                         ((playlist_item_t *)[o_item pointerValue])
                         checkItemExistence: NO locked:YES] == YES )
                 // if current item is in selected node and is playing then stop playlist
     id o_playing_item;
 
     o_playing_item = [o_outline_dict objectForKey:
-                [NSString stringWithFormat:@"%p",  p_playlist->status.p_item]];
+                [NSString stringWithFormat:@"%p",  playlist_CurrentPlayingItem( p_playlist )]];
 
     if( [self isItem: [o_playing_item pointerValue] inNode:
                         [item pointerValue] checkItemExistence: YES]
index 38c3ec8..e5415a4 100644 (file)
@@ -412,14 +412,7 @@ static void Run( intf_thread_t *p_intf )
         PL_LOCK;
         if( p_sys->p_input == NULL )
         {
-            p_sys->p_input = p_playlist->p_input;
-            if( p_sys->p_input )
-            {
-                if( !p_sys->p_input->b_dead )
-                {
-                    vlc_object_hold( p_sys->p_input );
-                }
-            }
+            p_sys->p_input = playlist_CurrentInput( p_playlist );
         }
         else if( p_sys->p_input->b_dead )
         {
@@ -430,7 +423,7 @@ static void Run( intf_thread_t *p_intf )
         }
         PL_UNLOCK;
 
-        if( p_sys->b_box_plidx_follow && p_playlist->status.p_item )
+        if( p_sys->b_box_plidx_follow && playlist_CurrentPlayingItem(p_playlist) )
         {
             FindIndex( p_intf );
         }
@@ -794,7 +787,7 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
 
                     playlist_item_t *p_parent = p_sys->p_node;
                     if( !p_parent )
-                    p_parent = p_playlist->status.p_node;
+                    p_parent = playlist_CurrentPlayingItem(p_playlist) ? playlist_CurrentPlayingItem(p_playlist)->p_parent : NULL;
                     if( !p_parent )
                         p_parent = p_playlist->p_local_onelevel;
 
@@ -996,7 +989,7 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
                     playlist_item_t *p_parent = p_sys->p_node;
 
                     if( !p_parent )
-                    p_parent = p_playlist->status.p_node;
+                    p_parent = playlist_CurrentPlayingItem(p_playlist) ? playlist_CurrentPlayingItem(p_playlist)->p_parent : NULL;
                     if( !p_parent )
                         p_parent = p_playlist->p_local_onelevel;
 
@@ -2187,7 +2180,7 @@ static void Redraw( intf_thread_t *p_intf, time_t *t_last_refresh )
             int c = ' ';
             if( ( p_node && p_item->p_input == p_node->p_input ) ||
                         ( !p_node && p_item->p_input ==
-                        p_playlist->status.p_node->p_input ) )
+                        playlist_CurrentPlayingItem(p_playlist)->p_input ) )
                 c = '*';
             else if( p_item == p_node || ( p_item != p_node &&
                         PlaylistIsPlaying( p_intf, p_item ) ) )
@@ -2350,7 +2343,7 @@ static int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
     intf_thread_t *p_intf = (intf_thread_t *)param;
     playlist_t *p_playlist = pl_Hold( p_intf );
     p_intf->p_sys->b_need_update = true;
-    p_intf->p_sys->p_node = p_playlist->status.p_node;
+    p_intf->p_sys->p_node = playlist_CurrentPlayingItem(p_playlist) ? playlist_CurrentPlayingItem(p_playlist)->p_parent : NULL;
     vlc_object_release( p_playlist );
     return VLC_SUCCESS;
 }
@@ -2360,7 +2353,7 @@ static inline bool PlaylistIsPlaying( intf_thread_t *p_intf,
                                             playlist_item_t *p_item )
 {
     playlist_t *p_playlist = pl_Hold( p_intf );
-    playlist_item_t *p_played_item = p_playlist->status.p_item;
+    playlist_item_t *p_played_item = playlist_CurrentPlayingItem(p_playlist);
     vlc_object_release( p_playlist );
     return( p_item != NULL && p_played_item != NULL &&
             p_item->p_input != NULL && p_played_item->p_input != NULL &&
@@ -2419,14 +2412,14 @@ static void Eject( intf_thread_t *p_intf )
     playlist_t * p_playlist = pl_Hold( p_intf );
     PL_LOCK;
 
-    if( p_playlist->status.p_item == NULL )
+    if( playlist_CurrentPlayingItem(p_playlist) == NULL )
     {
         PL_UNLOCK;
         vlc_object_release( p_playlist );
         return;
     }
 
-    psz_name = p_playlist->status.p_item->p_input->psz_name;
+    psz_name = playlist_CurrentPlayingItem(p_playlist)->p_input->psz_name;
 
     if( psz_name )
     {
index 839f8fa..d464118 100644 (file)
@@ -208,22 +208,18 @@ static void Close( vlc_object_t *p_this )
     p_playlist = pl_Hold( p_intf );
     if( p_playlist )
     {
-        PL_LOCK;
 
         var_DelCallback( p_playlist, "playlist-current", ItemChange, p_intf );
 
-        p_input = p_playlist->p_input;
+        p_input = playlist_CurrentInput( p_playlist );
         if ( p_input )
         {
-            vlc_object_hold( p_input );
-
             if( p_sys->b_state_cb )
                 var_DelCallback( p_input, "state", PlayingChange, p_intf );
 
             vlc_object_release( p_input );
         }
 
-        PL_UNLOCK;
         pl_Release( p_intf );
     }
 
@@ -506,18 +502,14 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
     p_sys->b_submit         = false;
 
     p_playlist = pl_Hold( p_intf );
-    PL_LOCK;
-    p_input = p_playlist->p_input;
+    p_input = playlist_CurrentInput( p_playlist );
 
     if( !p_input || p_input->b_dead )
     {
-        PL_UNLOCK;
         pl_Release( p_intf );
         return VLC_SUCCESS;
     }
 
-    vlc_object_hold( p_input );
-    PL_UNLOCK;
     pl_Release( p_intf );
 
     p_item = input_GetItem( p_input );
@@ -921,17 +913,13 @@ static int ReadMetaData( intf_thread_t *p_this )
     intf_sys_t          *p_sys = p_this->p_sys;
 
     p_playlist = pl_Hold( p_this );
-    PL_LOCK;
-    p_input = p_playlist->p_input;
+    p_input = playlist_CurrentInput( p_playlist );
     if( !p_input )
     {
-        PL_UNLOCK;
         pl_Release( p_this );
         return( VLC_SUCCESS );
     }
 
-    vlc_object_hold( p_input );
-    PL_UNLOCK;
     pl_Release( p_this );
 
     p_item = input_GetItem( p_input );
index 2e73525..7af4cab 100644 (file)
 input_thread_t * vlclua_get_input_internal( lua_State *L )
 {
     playlist_t *p_playlist = vlclua_get_playlist_internal( L );
-    PL_LOCK;
-    input_thread_t *p_input = p_playlist->p_input;
-    if( p_input ) vlc_object_hold( p_input );
-    PL_UNLOCK;
+    input_thread_t *p_input = playlist_CurrentInput( p_playlist );
     vlclua_release_playlist_internal( p_playlist );
     return p_input;
 }
index c4ac01a..02d7144 100644 (file)
@@ -268,6 +268,7 @@ static int vlclua_playlist_get( lua_State *L )
         else
         {
             int i;
+#ifdef FIX_THAT_CODE_NOT_TO_MESS_WITH_PLAYLIST_INTERNALS
             for( i = 0; i < p_playlist->i_sds; i++ )
             {
                 if( !strcasecmp( psz_what,
@@ -278,6 +279,10 @@ static int vlclua_playlist_get( lua_State *L )
                     break;
                 }
             }
+#else
+# warning Don't access playlist iternal, broken code here.
+            abort();
+#endif
             if( !p_item )
             {
                 PL_UNLOCK;
@@ -372,7 +377,8 @@ static int vlclua_playlist_status( lua_State *L )
     /*
     int i_count = 0;
     lua_settop( L, 0 );*/
-    if( p_playlist->p_input )
+    input_thread_t * p_input = playlist_CurrentInput( p_playlist );
+    if( p_input )
     {
         /*char *psz_uri =
             input_item_GetURI( input_GetItem( p_playlist->p_input ) );
@@ -380,7 +386,7 @@ static int vlclua_playlist_status( lua_State *L )
         free( psz_uri );
         lua_pushnumber( L, config_GetInt( p_intf, "volume" ) );*/
         PL_LOCK;
-        switch( p_playlist->status.i_status )
+        switch( playlist_Status( p_playlist ) )
         {
             case PLAYLIST_STOPPED:
                 lua_pushstring( L, "stopped" );
@@ -397,6 +403,7 @@ static int vlclua_playlist_status( lua_State *L )
         }
         PL_UNLOCK;
         /*i_count += 3;*/
+        vlc_object_release( p_input );
     }
     else
     {
index 4cd0ecc..e66e401 100644 (file)
@@ -80,7 +80,7 @@ void libvlc_playlist_play( libvlc_instance_t *p_instance, int i_id,
         }
 
         p_item = playlist_ItemGetByInputId( PL, i_id,
-                                            PL->status.p_node );
+                                            PL->p_root_category );
         if( !p_item )
         {
             if( did_lock == 1 )
@@ -92,7 +92,7 @@ void libvlc_playlist_play( libvlc_instance_t *p_instance, int i_id,
         }
 
         playlist_Control( PL, PLAYLIST_VIEWPLAY, pl_Locked,
-                          PL->status.p_node, p_item );
+                          PL->p_root_category, p_item );
         if( did_lock == 1 )
         {
             vlc_object_unlock( PL );
@@ -214,8 +214,6 @@ int libvlc_playlist_get_current_index ( libvlc_instance_t *p_instance,
     VLC_UNUSED(p_e);
 
     assert( PL );
-    if( !PL->status.p_item )
-        return -1;
     return playlist_CurrentId( PL );
 }
 
@@ -239,12 +237,12 @@ libvlc_media_player_t * libvlc_playlist_get_media_player(
 {
     libvlc_media_player_t *p_mi;
     assert( PL );
-
-    vlc_object_lock( PL );
-    if( PL->p_input )
+    input_thread_t * input = playlist_CurrentInput( PL );
+    if( input )
     {
         p_mi = libvlc_media_player_new_from_input_thread(
-                            p_instance, PL->p_input, p_e );
+                            p_instance, input, p_e );
+        vlc_object_release( input );
     }
     else
     {
@@ -252,7 +250,6 @@ libvlc_media_player_t * libvlc_playlist_get_media_player(
         p_mi = NULL;
         libvlc_exception_raise( p_e, "No active input" );
     }
-    vlc_object_unlock( PL );
 
     return p_mi;
 }
index be32a5b..9e3cb01 100644 (file)
@@ -276,13 +276,16 @@ playlist_BothAddInput
 playlist_ChildSearchName
 playlist_Clear
 playlist_Control
+playlist_CurrentId
 playlist_CurrentInput
+playlist_CurrentPlayingItem
 playlist_DeleteFromInput
 playlist_Export
 playlist_GetLastLeaf
 playlist_GetNextLeaf
 playlist_GetPreferredNode
 playlist_GetPrevLeaf
+playlist_IsPlaying
 playlist_IsServicesDiscoveryLoaded
 playlist_ItemGetById
 playlist_ItemGetByInput
@@ -304,6 +307,7 @@ playlist_PreparseEnqueueItem
 playlist_RecursiveNodeSort
 playlist_ServicesDiscoveryAdd
 playlist_ServicesDiscoveryRemove
+playlist_Status
 playlist_TreeMove
 __pl_Hold
 __pl_Release
index 913423b..7a70513 100644 (file)
@@ -97,9 +97,9 @@ static int PlaylistVAControl( playlist_t * p_playlist, int i_query, va_list args
     switch( i_query )
     {
     case PLAYLIST_STOP:
-        p_playlist->request.i_status = PLAYLIST_STOPPED;
-        p_playlist->request.b_request = true;
-        p_playlist->request.p_item = NULL;
+        pl_priv(p_playlist)->request.i_status = PLAYLIST_STOPPED;
+        pl_priv(p_playlist)->request.b_request = true;
+        pl_priv(p_playlist)->request.p_item = NULL;
         break;
 
     // Node can be null, it will keep the same. Use with care ...
@@ -112,65 +112,65 @@ static int PlaylistVAControl( playlist_t * p_playlist, int i_query, va_list args
             p_node = get_current_status_node( p_playlist );
             assert( p_node );
         }
-        p_playlist->request.i_status = PLAYLIST_RUNNING;
-        p_playlist->request.i_skip = 0;
-        p_playlist->request.b_request = true;
-        p_playlist->request.p_node = p_node;
-        p_playlist->request.p_item = p_item;
+        pl_priv(p_playlist)->request.i_status = PLAYLIST_RUNNING;
+        pl_priv(p_playlist)->request.i_skip = 0;
+        pl_priv(p_playlist)->request.b_request = true;
+        pl_priv(p_playlist)->request.p_node = p_node;
+        pl_priv(p_playlist)->request.p_item = p_item;
         if( p_item && var_GetBool( p_playlist, "random" ) )
             p_playlist->b_reset_currently_playing = true;
         break;
 
     case PLAYLIST_PLAY:
-        if( p_playlist->p_input )
+        if( pl_priv(p_playlist)->p_input )
         {
             val.i_int = PLAYING_S;
-            var_Set( p_playlist->p_input, "state", val );
+            var_Set( pl_priv(p_playlist)->p_input, "state", val );
             break;
         }
         else
         {
-            p_playlist->request.i_status = PLAYLIST_RUNNING;
-            p_playlist->request.b_request = true;
-            p_playlist->request.p_node = get_current_status_node( p_playlist );
-            p_playlist->request.p_item = get_current_status_item( p_playlist );
-            p_playlist->request.i_skip = 0;
+            pl_priv(p_playlist)->request.i_status = PLAYLIST_RUNNING;
+            pl_priv(p_playlist)->request.b_request = true;
+            pl_priv(p_playlist)->request.p_node = get_current_status_node( p_playlist );
+            pl_priv(p_playlist)->request.p_item = get_current_status_item( p_playlist );
+            pl_priv(p_playlist)->request.i_skip = 0;
         }
         break;
 
     case PLAYLIST_PAUSE:
         val.i_int = 0;
-        if( p_playlist->p_input )
-            var_Get( p_playlist->p_input, "state", &val );
+        if( pl_priv(p_playlist)->p_input )
+            var_Get( pl_priv(p_playlist)->p_input, "state", &val );
 
         if( val.i_int == PAUSE_S )
         {
-            p_playlist->status.i_status = PLAYLIST_RUNNING;
-            if( p_playlist->p_input )
+            pl_priv(p_playlist)->status.i_status = PLAYLIST_RUNNING;
+            if( pl_priv(p_playlist)->p_input )
             {
                 val.i_int = PLAYING_S;
-                var_Set( p_playlist->p_input, "state", val );
+                var_Set( pl_priv(p_playlist)->p_input, "state", val );
             }
         }
         else
         {
-            p_playlist->status.i_status = PLAYLIST_PAUSED;
-            if( p_playlist->p_input )
+            pl_priv(p_playlist)->status.i_status = PLAYLIST_PAUSED;
+            if( pl_priv(p_playlist)->p_input )
             {
                 val.i_int = PAUSE_S;
-                var_Set( p_playlist->p_input, "state", val );
+                var_Set( pl_priv(p_playlist)->p_input, "state", val );
             }
         }
         break;
 
     case PLAYLIST_SKIP:
-        p_playlist->request.p_node = get_current_status_node( p_playlist );
-        p_playlist->request.p_item = get_current_status_item( p_playlist );
-        p_playlist->request.i_skip = (int) va_arg( args, int );
+        pl_priv(p_playlist)->request.p_node = get_current_status_node( p_playlist );
+        pl_priv(p_playlist)->request.p_item = get_current_status_item( p_playlist );
+        pl_priv(p_playlist)->request.i_skip = (int) va_arg( args, int );
         /* if already running, keep running */
-        if( p_playlist->status.i_status != PLAYLIST_STOPPED )
-            p_playlist->request.i_status = p_playlist->status.i_status;
-        p_playlist->request.b_request = true;
+        if( pl_priv(p_playlist)->status.i_status != PLAYLIST_STOPPED )
+            pl_priv(p_playlist)->request.i_status = pl_priv(p_playlist)->status.i_status;
+        pl_priv(p_playlist)->request.b_request = true;
         break;
 
     default:
@@ -291,14 +291,14 @@ void ResetCurrentlyPlaying( playlist_t *p_playlist, bool b_random,
     stats_TimerStart( p_playlist, "Items array build",
                       STATS_TIMER_PLAYLIST_BUILD );
     PL_DEBUG( "rebuilding array of current - root %s",
-              PLI_NAME( p_playlist->status.p_node ) );
+              PLI_NAME( pl_priv(p_playlist)->status.p_node ) );
     ARRAY_RESET( p_playlist->current );
     p_playlist->i_current_index = -1;
     while( 1 )
     {
         /** FIXME: this is *slow* */
         p_next = playlist_GetNextLeaf( p_playlist,
-                                       p_playlist->status.p_node,
+                                       pl_priv(p_playlist)->status.p_node,
                                        p_next, true, false );
         if( p_next )
         {
@@ -355,19 +355,19 @@ playlist_item_t * playlist_NextItem( playlist_t *p_playlist )
     }
 
     /* Repeat and play/stop */
-    if( !p_playlist->request.b_request && b_repeat == true &&
+    if( !pl_priv(p_playlist)->request.b_request && b_repeat == true &&
          get_current_status_item( p_playlist ) )
     {
         msg_Dbg( p_playlist,"repeating item" );
         return get_current_status_item( p_playlist );
     }
-    if( !p_playlist->request.b_request && b_playstop == true )
+    if( !pl_priv(p_playlist)->request.b_request && b_playstop == true )
     {
         msg_Dbg( p_playlist,"stopping (play and stop)" );
         return NULL;
     }
 
-    if( !p_playlist->request.b_request &&
+    if( !pl_priv(p_playlist)->request.b_request &&
         get_current_status_item( p_playlist ) )
     {
         playlist_item_t *p_parent = get_current_status_item( p_playlist );
@@ -383,20 +383,20 @@ playlist_item_t * playlist_NextItem( playlist_t *p_playlist )
     }
 
     /* Start the real work */
-    if( p_playlist->request.b_request )
+    if( pl_priv(p_playlist)->request.b_request )
     {
-        p_new = p_playlist->request.p_item;
-        i_skip = p_playlist->request.i_skip;
+        p_new = pl_priv(p_playlist)->request.p_item;
+        i_skip = pl_priv(p_playlist)->request.i_skip;
         PL_DEBUG( "processing request item %s node %s skip %i",
-                        PLI_NAME( p_playlist->request.p_item ),
-                        PLI_NAME( p_playlist->request.p_node ), i_skip );
+                        PLI_NAME( pl_priv(p_playlist)->request.p_item ),
+                        PLI_NAME( pl_priv(p_playlist)->request.p_node ), i_skip );
 
-        if( p_playlist->request.p_node &&
-            p_playlist->request.p_node != get_current_status_node( p_playlist ) )
+        if( pl_priv(p_playlist)->request.p_node &&
+            pl_priv(p_playlist)->request.p_node != get_current_status_node( p_playlist ) )
         {
 
-            set_current_status_node( p_playlist, p_playlist->request.p_node );
-            p_playlist->request.p_node = NULL;
+            set_current_status_node( p_playlist, pl_priv(p_playlist)->request.p_node );
+            pl_priv(p_playlist)->request.p_node = NULL;
             p_playlist->b_reset_currently_playing = true;
         }
 
@@ -457,7 +457,7 @@ playlist_item_t * playlist_NextItem( playlist_t *p_playlist )
                                p_playlist->i_current_index );
         }
         /* Clear the request */
-        p_playlist->request.b_request = false;
+        pl_priv(p_playlist)->request.b_request = false;
     }
     /* "Automatic" item change ( next ) */
     else
@@ -509,7 +509,7 @@ int playlist_PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
     p_input->i_nb_played++;
     set_current_status_item( p_playlist, p_item );
 
-    p_playlist->status.i_status = PLAYLIST_RUNNING;
+    pl_priv(p_playlist)->status.i_status = PLAYLIST_RUNNING;
 
     var_SetInteger( p_playlist, "activity", i_activity +
                     DEFAULT_INPUT_ACTIVITY );
index 577c2bb..8745d34 100644 (file)
@@ -72,7 +72,7 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
 
     assert( offsetof( playlist_private_t, public_data ) == 0 );
     p_playlist = &p->public_data;
-    TAB_INIT( p_playlist->i_sds, p_playlist->pp_sds );
+    TAB_INIT( pl_priv(p_playlist)->i_sds, pl_priv(p_playlist)->pp_sds );
 
     libvlc_priv(p_parent->p_libvlc)->p_playlist = p_playlist;
 
@@ -80,7 +80,7 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
 
     /* Initialise data structures */
     p_playlist->i_last_playlist_id = 0;
-    p_playlist->p_input = NULL;
+    pl_priv(p_playlist)->p_input = NULL;
 
     p_playlist->gc_date = 0;
     p_playlist->b_cant_sleep = false;
@@ -146,10 +146,10 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
     }
 
     /* Initial status */
-    p_playlist->status.p_item = NULL;
-    p_playlist->status.p_node = p_playlist->p_local_onelevel;
-    p_playlist->request.b_request = false;
-    p_playlist->status.i_status = PLAYLIST_STOPPED;
+    pl_priv(p_playlist)->status.p_item = NULL;
+    pl_priv(p_playlist)->status.p_node = p_playlist->p_local_onelevel;
+    pl_priv(p_playlist)->request.b_request = false;
+    pl_priv(p_playlist)->status.i_status = PLAYLIST_STOPPED;
 
     p_playlist->i_sort = SORT_ID;
     p_playlist->i_order = ORDER_NORMAL;
@@ -251,16 +251,16 @@ void playlist_release_current_input( playlist_t * p_playlist )
 {
     PL_ASSERT_LOCKED;
 
-    if( !p_playlist->p_input ) return;
+    if( !pl_priv(p_playlist)->p_input ) return;
 
-    input_thread_t * p_input = p_playlist->p_input;
+    input_thread_t * p_input = pl_priv(p_playlist)->p_input;
     vlc_event_manager_t * p_em = input_get_event_manager( p_input );
 
     vlc_event_detach( p_em, vlc_InputStateChanged,
                       input_state_changed, p_playlist );
     vlc_event_detach( p_em, vlc_InputSelectedStreamChanged,
                       input_selected_stream_changed, p_playlist );
-    p_playlist->p_input = NULL;
+    pl_priv(p_playlist)->p_input = NULL;
 
     /* Release the playlist lock, because we may get stuck
      * in vlc_object_release() for some time. */
@@ -280,7 +280,7 @@ void playlist_set_current_input(
     if( p_input )
     {
         vlc_object_hold( p_input );
-        p_playlist->p_input = p_input;
+        pl_priv(p_playlist)->p_input = p_input;
         vlc_event_manager_t * p_em = input_get_event_manager( p_input );
         vlc_event_attach( p_em, vlc_InputStateChanged,
                           input_state_changed, p_playlist );
@@ -295,7 +295,7 @@ input_thread_t * playlist_CurrentInput( playlist_t * p_playlist )
 {
     input_thread_t * p_input;
     PL_LOCK;
-    p_input = p_playlist->p_input;
+    p_input = pl_priv(p_playlist)->p_input;
     if( p_input ) vlc_object_hold( p_input );
     PL_UNLOCK;
     return p_input;
@@ -311,14 +311,14 @@ playlist_item_t * get_current_status_item( playlist_t * p_playlist )
 {
     PL_ASSERT_LOCKED;
 
-    return p_playlist->status.p_item;
+    return pl_priv(p_playlist)->status.p_item;
 }
 
 playlist_item_t * get_current_status_node( playlist_t * p_playlist )
 {
     PL_ASSERT_LOCKED;
 
-    return p_playlist->status.p_node;
+    return pl_priv(p_playlist)->status.p_node;
 }
 
 void set_current_status_item( playlist_t * p_playlist,
@@ -326,14 +326,14 @@ void set_current_status_item( playlist_t * p_playlist,
 {
     PL_ASSERT_LOCKED;
 
-    if( p_playlist->status.p_item &&
-        p_playlist->status.p_item->i_flags & PLAYLIST_REMOVE_FLAG &&
-        p_playlist->status.p_item != p_item )
+    if( pl_priv(p_playlist)->status.p_item &&
+        pl_priv(p_playlist)->status.p_item->i_flags & PLAYLIST_REMOVE_FLAG &&
+        pl_priv(p_playlist)->status.p_item != p_item )
     {
         /* It's unsafe given current design to delete a playlist item :(
-        playlist_ItemDelete( p_playlist->status.p_item ); */
+        playlist_ItemDelete( pl_priv(p_playlist)->status.p_item ); */
     }
-    p_playlist->status.p_item = p_item;
+    pl_priv(p_playlist)->status.p_item = p_item;
 }
 
 void set_current_status_node( playlist_t * p_playlist,
@@ -341,14 +341,14 @@ void set_current_status_node( playlist_t * p_playlist,
 {
     PL_ASSERT_LOCKED;
 
-    if( p_playlist->status.p_node &&
-        p_playlist->status.p_node->i_flags & PLAYLIST_REMOVE_FLAG &&
-        p_playlist->status.p_node != p_node )
+    if( pl_priv(p_playlist)->status.p_node &&
+        pl_priv(p_playlist)->status.p_node->i_flags & PLAYLIST_REMOVE_FLAG &&
+        pl_priv(p_playlist)->status.p_node != p_node )
     {
         /* It's unsafe given current design to delete a playlist item :(
-        playlist_ItemDelete( p_playlist->status.p_node ); */
+        playlist_ItemDelete( pl_priv(p_playlist)->status.p_node ); */
     }
-    p_playlist->status.p_node = p_node;
+    pl_priv(p_playlist)->status.p_node = p_node;
 }
 
 /**
@@ -376,16 +376,16 @@ void playlist_MainLoop( playlist_t *p_playlist )
 
 check_input:
     /* If there is an input, check that it doesn't need to die. */
-    if( p_playlist->p_input )
+    if( pl_priv(p_playlist)->p_input )
     {
-        if( p_playlist->request.b_request && !p_playlist->p_input->b_die )
+        if( pl_priv(p_playlist)->request.b_request && !pl_priv(p_playlist)->p_input->b_die )
         {
             PL_DEBUG( "incoming request - stopping current input" );
-            input_StopThread( p_playlist->p_input );
+            input_StopThread( pl_priv(p_playlist)->p_input );
         }
 
         /* This input is dead. Remove it ! */
-        if( p_playlist->p_input->b_dead )
+        if( pl_priv(p_playlist)->p_input->b_dead )
         {
             int i_activity;
             input_thread_t *p_input;
@@ -393,7 +393,7 @@ check_input:
 
             PL_DEBUG( "dead input" );
 
-            p_input = p_playlist->p_input;
+            p_input = pl_priv(p_playlist)->p_input;
 
             assert( *pp_sout == NULL );
             if( var_CreateGetBool( p_input, "sout-keep" ) )
@@ -412,7 +412,7 @@ check_input:
             goto check_input;
         }
         /* This input is dying, let it do */
-        else if( p_playlist->p_input->b_die )
+        else if( pl_priv(p_playlist)->p_input->b_die )
         {
             PL_DEBUG( "dying input" );
             PL_UNLOCK;
@@ -421,15 +421,15 @@ check_input:
             goto check_input;
         }
         /* This input has finished, ask it to die ! */
-        else if( p_playlist->p_input->b_error
-                  || p_playlist->p_input->b_eof )
+        else if( pl_priv(p_playlist)->p_input->b_error
+                  || pl_priv(p_playlist)->p_input->b_eof )
         {
             PL_DEBUG( "finished input" );
-            input_StopThread( p_playlist->p_input );
+            input_StopThread( pl_priv(p_playlist)->p_input );
             /* No need to wait here, we'll wait in the p_input->b_die case */
             goto check_input;
         }
-        else if( p_playlist->p_input->i_state != INIT_S )
+        else if( pl_priv(p_playlist)->p_input->i_state != INIT_S )
         {
             ObjectGarbageCollector( p_playlist, false );
         }
@@ -442,8 +442,8 @@ check_input:
          *  - Request, running requested -> start new item
          *  - Request, stopped requested -> collect garbage
         */
-        int i_status = p_playlist->request.b_request ?
-            p_playlist->request.i_status : p_playlist->status.i_status;
+        int i_status = pl_priv(p_playlist)->request.b_request ?
+            pl_priv(p_playlist)->request.i_status : pl_priv(p_playlist)->status.i_status;
         if( i_status != PLAYLIST_STOPPED )
         {
             msg_Dbg( p_playlist, "starting new item" );
@@ -452,7 +452,7 @@ check_input:
             if( p_item == NULL )
             {
                 msg_Dbg( p_playlist, "nothing to play" );
-                p_playlist->status.i_status = PLAYLIST_STOPPED;
+                pl_priv(p_playlist)->status.i_status = PLAYLIST_STOPPED;
 
                 if( b_playexit == true )
                 {
@@ -468,9 +468,9 @@ check_input:
         }
         else
         {
-            const bool b_gc_forced = p_playlist->status.i_status != PLAYLIST_STOPPED;
+            const bool b_gc_forced = pl_priv(p_playlist)->status.i_status != PLAYLIST_STOPPED;
 
-            p_playlist->status.i_status = PLAYLIST_STOPPED;
+            pl_priv(p_playlist)->status.i_status = PLAYLIST_STOPPED;
 
             /* Collect garbage */
             ObjectGarbageCollector( p_playlist, b_gc_forced );
@@ -491,13 +491,13 @@ void playlist_LastLoop( playlist_t *p_playlist )
     while( 1 )
     {
         PL_LOCK;
-        if( p_playlist->p_input == NULL )
+        if( pl_priv(p_playlist)->p_input == NULL )
         {
             PL_UNLOCK;
             break;
         }
 
-        if( p_playlist->p_input->b_dead )
+        if( pl_priv(p_playlist)->p_input->b_dead )
         {
             /* remove input */
             playlist_release_current_input( p_playlist );
@@ -508,20 +508,20 @@ void playlist_LastLoop( playlist_t *p_playlist )
             PL_UNLOCK;
             continue;
         }
-        else if( p_playlist->p_input->b_die )
+        else if( pl_priv(p_playlist)->p_input->b_die )
         {
             /* This input is dying, leave it alone */
             ;
         }
-        else if( p_playlist->p_input->b_error || p_playlist->p_input->b_eof )
+        else if( pl_priv(p_playlist)->p_input->b_error || pl_priv(p_playlist)->p_input->b_eof )
         {
-            input_StopThread( p_playlist->p_input );
+            input_StopThread( pl_priv(p_playlist)->p_input );
             PL_UNLOCK;
             continue;
         }
         else
         {
-            p_playlist->p_input->b_eof = 1;
+            pl_priv(p_playlist)->p_input->b_eof = 1;
         }
         PL_UNLOCK;
 
@@ -693,8 +693,8 @@ void *playlist_FetcherLoop( void *data )
             {
                 bool b_break;
                 PL_LOCK;
-                b_break = ( !p_playlist->p_input || input_GetItem(p_playlist->p_input) != p_item  ||
-                            p_playlist->p_input->b_die || p_playlist->p_input->b_eof || p_playlist->p_input->b_error );
+                b_break = ( !pl_priv(p_playlist)->p_input || input_GetItem(pl_priv(p_playlist)->p_input) != p_item  ||
+                            pl_priv(p_playlist)->p_input->b_die || pl_priv(p_playlist)->p_input->b_eof || pl_priv(p_playlist)->p_input->b_error );
                 PL_UNLOCK;
                 if( b_break )
                     break;
@@ -772,3 +772,24 @@ static void VariablesInit( playlist_t *p_playlist )
 
     var_AddCallback( p_playlist, "random", RandomCallback, NULL );
 }
+
+int playlist_CurrentId( playlist_t * p_playlist )
+{
+    return pl_priv(p_playlist)->status.p_item->i_id;
+}
+
+bool playlist_IsPlaying( playlist_t * p_playlist )
+{
+    return ( pl_priv(p_playlist)->status.i_status == PLAYLIST_RUNNING &&
+            !(pl_priv(p_playlist)->request.b_request && pl_priv(p_playlist)->request.i_status == PLAYLIST_STOPPED) );
+}
+
+playlist_item_t * playlist_CurrentPlayingItem( playlist_t * p_playlist )
+{
+    return pl_priv(p_playlist)->status.p_item;
+}
+
+int playlist_Status( playlist_t * p_playlist )
+{
+    return pl_priv(p_playlist)->status.i_status;
+}
index d72e415..99b285b 100644 (file)
@@ -852,12 +852,12 @@ static void GoAndPreparse( playlist_t *p_playlist, int i_mode,
             p_parent = p_parent->p_parent;
         }
         assert( p_toplay );
-        p_playlist->request.b_request = true;
-        p_playlist->request.i_skip = 0;
-        p_playlist->request.p_item = p_toplay;
-        if( p_playlist->p_input )
-            input_StopThread( p_playlist->p_input );
-        p_playlist->request.i_status = PLAYLIST_RUNNING;
+        pl_priv(p_playlist)->request.b_request = true;
+        pl_priv(p_playlist)->request.i_skip = 0;
+        pl_priv(p_playlist)->request.p_item = p_toplay;
+        if( pl_priv(p_playlist)->p_input )
+            input_StopThread( pl_priv(p_playlist)->p_input );
+        pl_priv(p_playlist)->request.i_status = PLAYLIST_RUNNING;
         vlc_object_signal_unlocked( p_playlist );
     }
     /* Preparse if PREPARSE or SPREPARSE & not enough meta */
@@ -937,9 +937,9 @@ static int DeleteInner( playlist_t * p_playlist, playlist_item_t *p_item,
         /* Hack we don't call playlist_Control for lock reasons */
         if( b_stop )
         {
-            p_playlist->request.i_status = PLAYLIST_STOPPED;
-            p_playlist->request.b_request = true;
-            p_playlist->request.p_item = NULL;
+            pl_priv(p_playlist)->request.i_status = PLAYLIST_STOPPED;
+            pl_priv(p_playlist)->request.b_request = true;
+            pl_priv(p_playlist)->request.p_item = NULL;
             msg_Info( p_playlist, "stopping playback" );
             vlc_object_signal_unlocked( VLC_OBJECT(p_playlist) );
         }
index 86b93f4..496b021 100644 (file)
@@ -66,6 +66,38 @@ typedef struct playlist_private_t
     playlist_preparse_t  preparse; /**< Preparser data */
     playlist_fetcher_t   fetcher; /**< Meta and art fetcher data */
     sout_instance_t      *p_sout; /**< Kept sout instance */
+
+    struct playlist_services_discovery_support_t {
+        /* the playlist items for category and onelevel */
+        playlist_item_t*    p_cat;
+        playlist_item_t*    p_one;
+        services_discovery_t * p_sd; /**< Loaded service discovery modules */
+    } ** pp_sds;
+    int                   i_sds;   /**< Number of service discovery modules */
+    input_thread_t *      p_input;  /**< the input thread associated
+                                     * with the current item */
+    struct {
+        /* Current status. These fields are readonly, only the playlist
+         * main loop can touch it*/
+        playlist_status_t   i_status;  /**< Current status of playlist */
+        playlist_item_t *   p_item; /**< Currently playing/active item */
+        playlist_item_t *   p_node; /**< Current node to play from */
+    } status;
+
+    struct {
+        /* Request. Use this to give orders to the playlist main loop  */
+        playlist_status_t   i_status; /**< requested playlist status */
+        playlist_item_t *   p_node;   /**< requested node to play from */
+        playlist_item_t *   p_item;   /**< requested item to play in the node */
+
+        int                 i_skip;   /**< Number of items to skip */
+
+        bool          b_request;/**< Set to true by the requester
+                                           The playlist sets it back to false
+                                           when processing the request */
+        vlc_mutex_t         lock;     /**< Lock to protect request */
+    } request;
+
 } playlist_private_t;
 
 #define pl_priv( pl ) ((playlist_private_t *)(pl))
index acb0261..bb6ebac 100644 (file)
@@ -356,7 +356,7 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist,  const char *psz_modu
         p_sds->p_cat = p_cat;
 
         PL_LOCK;
-        TAB_APPEND( p_playlist->i_sds, p_playlist->pp_sds, p_sds );
+        TAB_APPEND( pl_priv(p_playlist)->i_sds, pl_priv(p_playlist)->pp_sds, p_sds );
         PL_UNLOCK;
 
     }
@@ -371,12 +371,12 @@ int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist,
     int i;
 
     PL_LOCK;
-    for( i = 0 ; i< p_playlist->i_sds ; i ++ )
+    for( i = 0 ; i< pl_priv(p_playlist)->i_sds ; i ++ )
     {
-        if( !strcmp( psz_module, p_playlist->pp_sds[i]->p_sd->psz_module ) )
+        if( !strcmp( psz_module, pl_priv(p_playlist)->pp_sds[i]->p_sd->psz_module ) )
         {
-            p_sds = p_playlist->pp_sds[i];
-            REMOVE_ELEM( p_playlist->pp_sds, p_playlist->i_sds, i );
+            p_sds = pl_priv(p_playlist)->pp_sds[i];
+            REMOVE_ELEM( pl_priv(p_playlist)->pp_sds, pl_priv(p_playlist)->i_sds, i );
             break;
         }
     }
@@ -430,9 +430,9 @@ bool playlist_IsServicesDiscoveryLoaded( playlist_t * p_playlist,
     int i;
     PL_LOCK;
 
-    for( i = 0 ; i< p_playlist->i_sds ; i ++ )
+    for( i = 0 ; i< pl_priv(p_playlist)->i_sds ; i ++ )
     {
-        if( !strcmp( psz_module, p_playlist->pp_sds[i]->p_sd->psz_module ) )
+        if( !strcmp( psz_module, pl_priv(p_playlist)->pp_sds[i]->p_sd->psz_module ) )
         {
             PL_UNLOCK;
             return true;
@@ -444,7 +444,7 @@ bool playlist_IsServicesDiscoveryLoaded( playlist_t * p_playlist,
 
 void playlist_ServicesDiscoveryKillAll( playlist_t *p_playlist )
 {
-    while( p_playlist->i_sds > 0 )
+    while( pl_priv(p_playlist)->i_sds > 0 )
         playlist_ServicesDiscoveryRemove( p_playlist,
-                                     p_playlist->pp_sds[0]->p_sd->psz_module );
+                                     pl_priv(p_playlist)->pp_sds[0]->p_sd->psz_module );
 }