]> git.sesse.net Git - vlc/blobdiff - include/vlc_playlist.h
Don't loop continuously the playlist thread, use cond.
[vlc] / include / vlc_playlist.h
index 778a025c47651619989797c64696edb44bae7479..9acba2652daafe214723738cb4d5cb92bb1f1ad9 100644 (file)
 #ifndef _VLC_PLAYLIST_H_
 #define _VLC_PLAYLIST_H_
 
-/**
- *  \file
- *  This file contain structures and function prototypes related
- *  to the playlist in vlc
- */
+#include <assert.h>
 
+TYPEDEF_ARRAY(playlist_item_t*, playlist_item_array_t);
+TYPEDEF_ARRAY(input_item_t*, input_item_array_t);
 /**
+ * \file
+ * This file contain structures and function prototypes related
+ * to the playlist in vlc
+ *
  * \defgroup vlc_playlist Playlist
- * Brief description. Longer description
  * @{
  */
 
@@ -71,7 +72,6 @@ struct playlist_item_t
 #define PLAYLIST_RO_FLAG        0x0008    /**< Write-enabled ? */
 #define PLAYLIST_REMOVE_FLAG    0x0010    /**< Remove this item at the end */
 #define PLAYLIST_EXPANDED_FLAG  0x0020    /**< Expanded node */
-#define PLAYLIST_PREFCAT_FLAG   0x0040    /**< Prefer category */
 
 /**
  * Playlist status
@@ -91,15 +91,6 @@ struct services_discovery_t
     void (*pf_run) ( services_discovery_t *);
 };
 
-struct playlist_preparse_t
-{
-    VLC_COMMON_MEMBERS
-    vlc_mutex_t     lock;
-    int             i_waiting;
-    input_item_t  **pp_waiting;
-};
-
-
 /** Structure containing information about the playlist */
 struct playlist_t
 {
@@ -111,15 +102,15 @@ struct playlist_t
 /*@{*/
     int                   i_enabled; /**< How many items are enabled ? */
 
-    /* Arrays of items */
-    int                   i_size;   /**< total size of the list */
-    playlist_item_t **    pp_items; /**< array of pointers to the
-                                     * playlist items */
-    int                   i_all_size; /**< size of list of items and nodes */
-    playlist_item_t **    pp_all_items; /**< array of pointers to the
-                                         * playlist items and nodes */
-    int                   i_input_items;
-    input_item_t **       pp_input_items;
+    playlist_item_array_t items; /**< Arrays of items */
+    playlist_item_array_t all_items; /**< Array of items and nodes */
+
+    input_item_array_t    input_items; /**< Array of input items */
+
+    playlist_item_array_t current; /**< Items currently being played */
+    int                   i_current_index; /**< Index in current array */
+    /** Reset current item ? */
+    vlc_bool_t            b_reset_currently_playing;
 
     int                   i_last_playlist_id; /**< Last id to an item */
     int                   i_last_input_id ; /**< Last id on an input */
@@ -138,14 +129,18 @@ struct playlist_t
     vlc_bool_t            b_always_tree;/**< Always display as tree */
     vlc_bool_t            b_never_tree;/**< Never display as tree */
 
+    vlc_bool_t            b_doing_ml; /**< Doing media library stuff, */
+                                      /*get quicker */
+
     /* 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               i_vout_destroyed_date;
-    mtime_t               i_sout_destroyed_date;
+    mtime_t               gc_date;
+    vlc_bool_t            b_cant_sleep;
     playlist_preparse_t  *p_preparse; /**< Preparser object */
+    playlist_secondary_preparse_t *p_secondary_preparse;/**< Preparser object */
 
     vlc_mutex_t gc_lock;         /**< Lock to protect the garbage collection */
 
@@ -173,6 +168,8 @@ struct playlist_t
 
     // Playlist-unrelated fields
     interaction_t       *p_interaction;       /**< Interaction manager */
+    /** The input thread computing stats */
+    input_thread_t      *p_stats_computer;
     global_stats_t      *p_stats;             /**< Global statistics */
     /*@}*/
 };
@@ -204,25 +201,22 @@ struct playlist_add_t
 
 /* Global thread */
 #define playlist_ThreadCreate(a) __playlist_ThreadCreate(VLC_OBJECT(a))
-playlist_t *__playlist_ThreadCreate   ( vlc_object_t * );
+void        __playlist_ThreadCreate   ( vlc_object_t * );
 int           playlist_ThreadDestroy  ( playlist_t * );
 
 /* Helpers */
 #define PL_LOCK vlc_mutex_lock( &p_playlist->object_lock );
 #define PL_UNLOCK vlc_mutex_unlock( &p_playlist->object_lock );
 
-/* Creation/Deletion */
-playlist_t *playlist_Create   ( vlc_object_t * );
-void        playlist_Destroy  ( playlist_t * );
-
-/* Engine */
-void playlist_MainLoop( playlist_t * );
-void playlist_LastLoop( playlist_t * );
-void playlist_PreparseLoop( playlist_preparse_t * );
-
-/* Control */
-playlist_item_t * playlist_NextItem  ( playlist_t * );
-int playlist_PlayItem  ( playlist_t *, playlist_item_t * );
+#define pl_Get( a ) a->p_libvlc->p_playlist
+#define pl_Yield( a ) __pl_Yield( VLC_OBJECT(a) )
+static inline playlist_t *__pl_Yield( vlc_object_t *p_this )
+{
+    assert( p_this->p_libvlc->p_playlist );
+    vlc_object_yield( p_this->p_libvlc->p_playlist );
+    return p_this->p_libvlc->p_playlist;
+}
+#define pl_Release(a) vlc_object_release( a->p_libvlc->p_playlist );
 
 /* Playlist control */
 #define playlist_Play(p) playlist_LockControl(p,PLAYLIST_PLAY )
@@ -240,6 +234,7 @@ VLC_EXPORT( void,  playlist_LockClear, ( playlist_t * ) );
 
 VLC_EXPORT( int, playlist_PreparseEnqueue, (playlist_t *, input_item_t *) );
 VLC_EXPORT( int, playlist_PreparseEnqueueItem, (playlist_t *, playlist_item_t *) );
+VLC_EXPORT( int, playlist_AskForArtEnqueue, (playlist_t *, input_item_t *) );
 
 /* Services discovery */
 
@@ -345,7 +340,7 @@ static inline int playlist_MLAddExt( playlist_t *p_playlist,
                             i_duration, ppsz_options, i_options, VLC_FALSE );
 }
 
-/** Add an input item to the playlist node 
+/** Add an input item to the playlist node
  * \see playlist_AddInput
  */
 static inline int playlist_PlaylistAddInput( playlist_t* p_playlist,
@@ -354,7 +349,7 @@ static inline int playlist_PlaylistAddInput( playlist_t* p_playlist,
     return playlist_AddInput( p_playlist, p_input, i_mode, i_pos, VLC_TRUE );
 }
 
-/** Add an input item to the media library 
+/** Add an input item to the media library
  * \see playlist_AddInput
  */
 static inline int playlist_MLAddInput( playlist_t* p_playlist,
@@ -363,14 +358,13 @@ static inline int playlist_MLAddInput( playlist_t* p_playlist,
     return playlist_AddInput( p_playlist, p_input, i_mode, i_pos, VLC_FALSE );
 }
 
-void playlist_SendAddNotify( playlist_t *p_playlist, int i_item_id, int i_node_id );
-
 /********************** Misc item operations **********************/
 VLC_EXPORT( playlist_item_t*, playlist_ItemToNode, (playlist_t *,playlist_item_t *) );
 VLC_EXPORT( playlist_item_t*, playlist_LockItemToNode, (playlist_t *,playlist_item_t *) );
 
 playlist_item_t *playlist_ItemFindFromInputAndRoot( playlist_t *p_playlist,
-                                   int i_input_id, playlist_item_t *p_root );
+                                   int i_input_id, playlist_item_t *p_root,
+                                   vlc_bool_t );
 
 /********************************** Item search *************************/
 VLC_EXPORT( playlist_item_t *, playlist_ItemGetById, (playlist_t *, int) );
@@ -412,19 +406,9 @@ VLC_EXPORT( int, playlist_NodeRemoveItem, (playlist_t *,playlist_item_t*,playlis
 VLC_EXPORT( playlist_item_t *, playlist_ChildSearchName, (playlist_item_t*, const char* ) );
 VLC_EXPORT( int, playlist_NodeDelete, ( playlist_t *, playlist_item_t *, vlc_bool_t , vlc_bool_t ) );
 VLC_EXPORT( int, playlist_NodeEmpty, ( playlist_t *, playlist_item_t *, vlc_bool_t ) );
-VLC_EXPORT( void, playlist_NodesCreateForSD, (playlist_t *, char *, playlist_item_t **, playlist_item_t ** ) );
+VLC_EXPORT( void, playlist_NodesPairCreate, (playlist_t *, char *, playlist_item_t **, playlist_item_t **, vlc_bool_t ) );
 VLC_EXPORT( playlist_item_t *, playlist_GetPreferredNode, ( playlist_t *p_playlist, playlist_item_t *p_node ) );
 
-/* Tree walking - These functions are only for playlist, not plugins */
-playlist_item_t *playlist_GetNextLeaf( playlist_t *p_playlist,
-                                    playlist_item_t *p_root,
-                                    playlist_item_t *, vlc_bool_t, vlc_bool_t );
-playlist_item_t *playlist_GetPrevLeaf( playlist_t *p_playlist,
-                                    playlist_item_t *p_root,
-                                    playlist_item_t *, vlc_bool_t, vlc_bool_t );
-playlist_item_t *playlist_GetLastLeaf( playlist_t *p_playlist,
-                                    playlist_item_t *p_root );
-
 /***********************************************************************
  * Inline functions
  ***********************************************************************/
@@ -444,23 +428,21 @@ static inline vlc_bool_t playlist_IsEmpty( playlist_t * p_playlist )
 {
     vlc_bool_t b_empty;
     vlc_mutex_lock( &p_playlist->object_lock );
-    b_empty = p_playlist->i_size == 0;
+    b_empty = p_playlist->items.i_size == 0;
     vlc_mutex_unlock( &p_playlist->object_lock );
     return( b_empty );
 }
 
+/** Ask the playlist to do some work */
+static inline void playlist_Signal( playlist_t *p_playlist )
+{
+    PL_LOCK;
+    vlc_cond_signal( &p_playlist->object_wait );
+    PL_UNLOCK;
+}
+
 /**
  * @}
  */
 
-#define PLAYLIST_DEBUG 1
-
-#ifdef PLAYLIST_DEBUG
-#define PL_DEBUG( msg, args... ) msg_Dbg( p_playlist, msg, ## args )
-#else
-#define PL_DEBUG( msg, args ... ) {}
-#endif
-
-#define PLI_NAME( p ) p ? p->p_input->psz_name : "null"
-
 #endif