VLC  4.0.0-dev
playlist_internal.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * playlist_internal.h : Playlist internals
3  *****************************************************************************
4  * Copyright (C) 1999-2008 VLC authors and VideoLAN
5  *
6  * Authors: Samuel Hocevar <sam@zoy.org>
7  * ClĂ©ment Stenac <zorglub@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23 
24 #ifndef __LIBVLC_PLAYLIST_INTERNAL_H
25 # define __LIBVLC_PLAYLIST_INTERNAL_H 1
26 
27 /**
28  * \defgroup playlist_internals VLC playlist internals
29  * \ingroup playlist_legacy
30  *
31  * @{
32  * \file
33  * VLC playlist internal interface
34  */
35 
36 #include "input/input_interface.h"
37 #include <assert.h>
38 
39 #include "preparser/preparser.h"
40 
42 
43 typedef struct playlist_private_t
44 {
46 
47  void *input_tree; /**< Search tree for input item
48  to playlist item mapping */
49  void *id_tree; /**< Search tree for item ID to item mapping */
50 
51  struct vlc_list sds;
52  input_thread_t * p_input; /**< the input thread associated
53  * with the current item */
54  input_resource_t * p_input_resource; /**< input resources */
56  struct {
57  /* Current status. These fields are readonly, only the playlist
58  * main loop can touch it*/
59  playlist_item_t * p_item; /**< Currently playing/active item */
60  playlist_item_t * p_node; /**< Current node to play from */
61  } status;
62 
63  struct {
64  /* Request. Use this to give orders to the playlist main loop */
65  playlist_item_t * p_node; /**< requested node to play from */
66  playlist_item_t * p_item; /**< requested item to play in the node */
67 
68  int i_skip; /**< Number of items to skip */
69 
70  bool b_request;/**< Set to true by the requester
71  The playlist sets it back to false
72  when processing the request */
73  bool input_dead; /**< Set when input has finished. */
74  } request;
75 
76  vlc_thread_t thread; /**< engine thread */
77  vlc_mutex_t lock; /**< dah big playlist global lock */
78  vlc_cond_t signal; /**< wakes up the playlist engine thread */
79  bool killed; /**< playlist is shutting down */
80  bool cork_effective; /**< Corked while actively playing */
81 
82  int i_last_playlist_id; /**< Last id to an item */
83  bool b_reset_currently_playing; /** Reset current item array */
84 
85  bool b_tree; /**< Display as a tree */
86  bool b_preparse; /**< Preparse items */
88 
89 #define pl_priv( pl ) container_of(pl, playlist_private_t, public_data)
90 
91 /*****************************************************************************
92  * Prototypes
93  *****************************************************************************/
94 
95 /* Creation/Deletion */
99 
100 /* */
103 
104 /* Engine */
109 
110 /**********************************************************************
111  * Item management
112  **********************************************************************/
113 
114 void playlist_SendAddNotify( playlist_t *p_playlist, playlist_item_t *item );
115 
117  playlist_item_t *, input_item_node_t *, int, bool );
118 
120 
121 /* Tree walking */
123 
124 /**
125  * Flags for playlist_NodeDeleteExplicit
126  * \defgroup playlist_NodeDeleteExplicit_flags
127  * @{
128  **/
129 #define PLAYLIST_DELETE_FORCE 0x01 /**< delete node even if read-only */
130 #define PLAYLIST_DELETE_STOP_IF_CURRENT 0x02 /**< stop playlist playback if
131  node is currently the one
132  played */
133 /** @} */
134 
135 /**
136  * Delete a node with explicit semantics
137  *
138  * This function acts like \ref playlist_NodeDelete with the advantage of the
139  * caller being able control some of the semantics of the function.
140  *
141  * \ref p_playlist the playlist where the node is to be deleted
142  * \ref p_node the node to delete
143  * \ref flags a bitfield consisting of \ref playlist_NodeDeleteExplicit_flags
144  **/
146  int flags);
147 
149 
150 void ResetCurrentlyPlaying( playlist_t *p_playlist, playlist_item_t *p_cur );
151 void ResyncCurrentIndex( playlist_t *p_playlist, playlist_item_t *p_cur );
152 
154  playlist_item_t *p_item, bool b_ena, bool b_unplayed ) VLC_USED;
155 
156 #define PLAYLIST_DEBUG 1
157 //#undef PLAYLIST_DEBUG2
159 #ifdef PLAYLIST_DEBUG
160  #define PL_DEBUG( ... ) msg_Dbg( p_playlist, __VA_ARGS__ )
161  #ifdef PLAYLIST_DEBUG2
162  #define PL_DEBUG2( msg, ... ) msg_Dbg( p_playlist, __VA_ARGS__ )
163  #else
164  #define PL_DEBUG2( msg, ... ) {}
165  #endif
166 #else
167  #define PL_DEBUG( msg, ... ) {}
168  #define PL_DEBUG2( msg, ... ) {}
169 #endif
170 
171 #define PLI_NAME( p ) p && p->p_input ? p->p_input->psz_name : "null"
172 
173 #define PL_LOCK_IF( cond ) pl_lock_if( p_playlist, cond )
174 static inline void pl_lock_if( playlist_t * p_playlist, bool cond )
175 {
176  if( cond ) PL_LOCK; else PL_ASSERT_LOCKED;
177 }
178 
179 #define PL_UNLOCK_IF( cond ) pl_unlock_if( p_playlist, cond )
180 static inline void pl_unlock_if( playlist_t * p_playlist, bool cond )
181 {
182  if( cond ) PL_UNLOCK;
183 }
184 
185 /** @} */
186 #endif /* !__LIBVLC_PLAYLIST_INTERNAL_H */
playlist_item_t * p_item
Currently playing/active item.
Definition: playlist_internal.h:59
Definition: resource.c:46
vlc_cond_t signal
wakes up the playlist engine thread
Definition: playlist_internal.h:78
void ResyncCurrentIndex(playlist_t *p_playlist, playlist_item_t *p_cur)
Synchronise the current index of the playlist to match the index of the current item.
Definition: thread.c:120
int playlist_InsertInputItemTree(playlist_t *, playlist_item_t *, input_item_node_t *, int, bool)
Insert a tree of input items into a given playlist node.
Definition: item.c:595
void playlist_NodeDeleteExplicit(playlist_t *, playlist_item_t *, int flags)
Delete a node with explicit semantics.
Definition: tree.c:97
void playlist_Activate(playlist_t *)
Creates the main playlist thread.
Definition: thread.c:51
int i_last_playlist_id
Last id to an item.
Definition: playlist_internal.h:82
static void pl_unlock_if(playlist_t *p_playlist, bool cond)
Definition: playlist_internal.h:182
Describes an input and is used to spawn input_thread_t objects.
Definition: vlc_input_item.h:77
pthread_mutex_t vlc_mutex_t
Mutex.
Definition: vlc_threads.h:278
Definition: vlc_input_item.h:191
playlist_t public_data
Definition: playlist_internal.h:45
void * input_tree
Search tree for input item to playlist item mapping.
Definition: playlist_internal.h:47
struct playlist_private_t playlist_private_t
playlist_t * playlist_Create(vlc_object_t *)
Create playlist.
Definition: engine.c:197
bool cork_effective
Corked while actively playing.
Definition: playlist_internal.h:80
bool b_request
Set to true by the requester The playlist sets it back to false when processing the request...
Definition: playlist_internal.h:70
void playlist_Destroy(playlist_t *)
Destroy playlist.
Definition: engine.c:301
playlist_item_t * p_node
Current node to play from.
Definition: playlist_internal.h:60
input_resource_t * p_input_resource
input resources
Definition: playlist_internal.h:54
Definition: renderer_discovery.c:34
void set_current_status_item(playlist_t *, playlist_item_t *)
Definition: engine.c:392
Definition: playlist_internal.h:43
playlist_item_t * get_current_status_node(playlist_t *p_playlist)
Definition: engine.c:385
void * id_tree
Search tree for item ID to item mapping.
Definition: playlist_internal.h:49
vlc_mutex_t lock
dah big playlist global lock
Definition: playlist_internal.h:77
vlc_renderer_item_t * p_renderer
Definition: playlist_internal.h:55
playlist item / node
Definition: vlc_playlist_legacy.h:122
Thread handle.
Definition: vlc_threads.h:263
static void pl_lock_if(playlist_t *p_playlist, bool cond)
Definition: playlist_internal.h:176
void playlist_AddSubtree(playlist_t *, input_item_t *, input_item_node_t *)
Definition: item.c:61
playlist_item_t * playlist_ItemNewFromInput(playlist_t *p_playlist, input_item_t *p_input)
Definition: item.c:262
bool input_dead
Set when input has finished.
Definition: playlist_internal.h:73
input_thread_t * p_input
the input thread associated with the current item
Definition: playlist_internal.h:52
bool killed
playlist is shutting down
Definition: playlist_internal.h:79
pthread_cond_t vlc_cond_t
Condition variable.
Definition: vlc_threads.h:290
vlc_thread_t thread
engine thread
Definition: playlist_internal.h:76
void playlist_ItemRelease(playlist_t *, playlist_item_t *)
Release an item.
Definition: item.c:344
struct vlc_list sds
Definition: playlist_internal.h:51
Main structure representing an input thread.
Definition: vlc_input.h:226
#define PL_ASSERT_LOCKED
Definition: vlc_playlist_legacy.h:214
void playlist_ServicesDiscoveryKillAll(playlist_t *p_playlist)
Definition: services_discovery.c:235
playlist_item_t * playlist_GetNextLeaf(playlist_t *, playlist_item_t *p_root, playlist_item_t *p_item, bool b_ena, bool b_unplayed) VLC_USED
Finds the next item to play.
Definition: tree.c:206
Doubly-linked list node.
Definition: vlc_list.h:43
bool b_tree
Reset current item array.
Definition: playlist_internal.h:85
#define PL_UNLOCK
Definition: vlc_playlist_legacy.h:213
int i_skip
Number of items to skip.
Definition: playlist_internal.h:68
bool b_preparse
Preparse items.
Definition: playlist_internal.h:86
void playlist_SendAddNotify(playlist_t *p_playlist, playlist_item_t *item)
Send a notification that an item has been added to a node.
Definition: item.c:702
struct playlist_private_t::@94 status
#define PL_LOCK
Definition: vlc_playlist_legacy.h:212
VLC object common members.
Definition: vlc_objects.h:43
playlist_item_t * get_current_status_item(playlist_t *p_playlist)
Accessor for status item and status nodes.
Definition: engine.c:378
struct playlist_private_t::@95 request
void set_current_status_node(playlist_t *, playlist_item_t *)
Definition: engine.c:400
#define VLC_USED
Definition: fourcc_gen.c:32
Structure containing information about the playlist.
Definition: vlc_playlist_legacy.h:147
void ResetCurrentlyPlaying(playlist_t *p_playlist, playlist_item_t *p_cur)
Reset the currently playing playlist.
Definition: thread.c:146
int playlist_NodeInsert(playlist_item_t *, playlist_item_t *, int)
Definition: tree.c:148
bool b_reset_currently_playing
Definition: playlist_internal.h:83