]> git.sesse.net Git - vlc/blob - src/playlist/engine.c
f7ba590bc2b93982835fea26e18ffd627b43aec9
[vlc] / src / playlist / engine.c
1 /*****************************************************************************
2  * engine.c : Run the playlist and handle its control
3  *****************************************************************************
4  * Copyright (C) 1999-2004 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *          ClĂ©ment Stenac <zorglub@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24 #include <vlc/vlc.h>
25 #include <vlc/vout.h>
26 #include <vlc/sout.h>
27 #include <vlc/input.h>
28 #include "vlc_playlist.h"
29 #include "vlc_interaction.h"
30 #include "playlist_internal.h"
31
32 /*****************************************************************************
33  * Local prototypes
34  *****************************************************************************/
35 static void VariablesInit( playlist_t *p_playlist );
36
37 static int RandomCallback( vlc_object_t *p_this, char const *psz_cmd,
38                            vlc_value_t oldval, vlc_value_t newval, void *a )
39 {
40     ((playlist_t*)p_this)->b_reset_currently_playing = VLC_TRUE;
41     return VLC_SUCCESS;
42 }
43
44 /**
45  * Create playlist
46  *
47  * Create a playlist structure.
48  * \param p_parent the vlc object that is to be the parent of this playlist
49  * \return a pointer to the created playlist, or NULL on error
50  */
51 playlist_t * playlist_Create( vlc_object_t *p_parent )
52 {
53     playlist_t *p_playlist;
54     int i_tree;
55
56     /* Allocate structure */
57     p_playlist = vlc_object_create( p_parent, VLC_OBJECT_PLAYLIST );
58     if( !p_playlist )
59     {
60         msg_Err( p_parent, "out of memory" );
61         return NULL;
62     }
63     p_parent->p_libvlc->p_playlist = p_playlist;
64
65     VariablesInit( p_playlist );
66
67     /* Initialise data structures */
68     vlc_mutex_init( p_playlist, &p_playlist->gc_lock );
69     p_playlist->i_last_playlist_id = 0;
70     p_playlist->i_last_input_id = 0;
71     p_playlist->p_input = NULL;
72
73     p_playlist->i_vout_destroyed_date = 0;
74     p_playlist->i_sout_destroyed_date = 0;
75
76     ARRAY_INIT( p_playlist->items );
77     ARRAY_INIT( p_playlist->all_items );
78     ARRAY_INIT( p_playlist->input_items );
79     ARRAY_INIT( p_playlist->current );
80
81     p_playlist->i_current_index = 0;
82     p_playlist->b_reset_currently_playing = VLC_TRUE;
83
84     i_tree = var_CreateGetBool( p_playlist, "playlist-tree" );
85     p_playlist->b_always_tree = (i_tree == 1);
86     p_playlist->b_never_tree = (i_tree == 2);
87
88     p_playlist->b_doing_ml = VLC_FALSE;
89
90     p_playlist->p_root_category = playlist_NodeCreate( p_playlist, NULL, NULL);
91     p_playlist->p_root_onelevel = playlist_NodeCreate( p_playlist, NULL, NULL);
92
93     /* Create playlist and media library */
94     p_playlist->p_local_category = playlist_NodeCreate( p_playlist,
95                                  _( "Playlist" ),p_playlist->p_root_category );
96     p_playlist->p_local_onelevel =  playlist_NodeCreate( p_playlist,
97                                 _( "Playlist" ), p_playlist->p_root_onelevel );
98     p_playlist->p_local_category->i_flags |= PLAYLIST_RO_FLAG;
99     p_playlist->p_local_onelevel->i_flags |= PLAYLIST_RO_FLAG;
100
101     /* Link the nodes together. Todo: actually create them from the same input*/
102     p_playlist->p_local_onelevel->p_input->i_id =
103         p_playlist->p_local_category->p_input->i_id;
104
105     if( config_GetInt( p_playlist, "media-library") )
106     {
107         p_playlist->p_ml_category =   playlist_NodeCreate( p_playlist,
108                            _( "Media Library" ), p_playlist->p_root_category );
109         p_playlist->p_ml_onelevel =  playlist_NodeCreate( p_playlist,
110                            _( "Media Library" ), p_playlist->p_root_onelevel );
111         p_playlist->p_ml_category->i_flags |= PLAYLIST_RO_FLAG;
112         p_playlist->p_ml_onelevel->i_flags |= PLAYLIST_RO_FLAG;
113         p_playlist->p_ml_onelevel->p_input->i_id =
114              p_playlist->p_ml_category->p_input->i_id;
115
116     }
117     else
118     {
119         p_playlist->p_ml_category = p_playlist->p_ml_onelevel = NULL;
120     }
121
122     /* Initial status */
123     p_playlist->status.p_item = NULL;
124     p_playlist->status.p_node = p_playlist->p_local_onelevel;
125     p_playlist->request.b_request = VLC_FALSE;
126     p_playlist->status.i_status = PLAYLIST_STOPPED;
127
128     p_playlist->i_sort = SORT_ID;
129     p_playlist->i_order = ORDER_NORMAL;
130
131     vlc_object_attach( p_playlist, p_parent );
132
133     playlist_MLLoad( p_playlist );
134     return p_playlist;
135 }
136
137 void playlist_Destroy( playlist_t *p_playlist )
138 {
139     while( p_playlist->i_sds )
140     {
141         playlist_ServicesDiscoveryRemove( p_playlist,
142                                           p_playlist->pp_sds[0]->psz_module );
143     }
144
145     playlist_MLDump( p_playlist );
146
147     vlc_thread_join( p_playlist->p_preparse );
148     vlc_thread_join( p_playlist->p_secondary_preparse );
149     vlc_thread_join( p_playlist );
150
151     vlc_object_detach( p_playlist->p_preparse );
152     vlc_object_detach( p_playlist->p_secondary_preparse );
153
154     var_Destroy( p_playlist, "intf-change" );
155     var_Destroy( p_playlist, "item-change" );
156     var_Destroy( p_playlist, "playlist-current" );
157     var_Destroy( p_playlist, "intf-popmenu" );
158     var_Destroy( p_playlist, "intf-show" );
159     var_Destroy( p_playlist, "play-and-stop" );
160     var_Destroy( p_playlist, "play-and-exit" );
161     var_Destroy( p_playlist, "random" );
162     var_Destroy( p_playlist, "repeat" );
163     var_Destroy( p_playlist, "loop" );
164     var_Destroy( p_playlist, "activity" );
165
166     PL_LOCK;
167     /* Go through all items, and simply free everything without caring
168      * about the tree structure. Do not decref, it will be done by doing
169      * the same thing on the input items array */
170     FOREACH_ARRAY( playlist_item_t *p_del, p_playlist->all_items )
171         free( p_del->pp_children );
172         free( p_del );
173     FOREACH_END();
174     ARRAY_RESET( p_playlist->all_items );
175
176     FOREACH_ARRAY( input_item_t *p_del, p_playlist->input_items )
177         input_ItemClean( p_del );
178         free( p_del );
179     FOREACH_END();
180     ARRAY_RESET( p_playlist->input_items );
181
182     ARRAY_RESET( p_playlist->items );
183     ARRAY_RESET( p_playlist->current );
184
185     PL_UNLOCK;
186
187     if( p_playlist->p_stats )
188         free( p_playlist->p_stats );
189
190     vlc_mutex_destroy( &p_playlist->gc_lock );
191     vlc_object_destroy( p_playlist->p_preparse );
192     vlc_object_destroy( p_playlist->p_secondary_preparse );
193     vlc_object_detach( p_playlist );
194     vlc_object_destroy( p_playlist );
195
196 }
197 /* Destroy remaining objects */
198 static mtime_t ObjectGarbageCollector( playlist_t *p_playlist, int i_type,
199                                        mtime_t destroy_date )
200 {
201     vlc_object_t *p_obj;
202
203     if( destroy_date > mdate() ) return destroy_date;
204
205     if( destroy_date == 0 )
206     {
207         /* give a little time */
208         return mdate() + I64C(1000000);
209     }
210     else
211     {
212         vlc_mutex_lock( &p_playlist->gc_lock );
213         while( ( p_obj = vlc_object_find( p_playlist, i_type, FIND_CHILD ) ) )
214         {
215             if( p_obj->p_parent != (vlc_object_t*)p_playlist )
216             {
217                 /* only first child (ie unused) */
218                 vlc_object_release( p_obj );
219                 break;
220             }
221             if( i_type == VLC_OBJECT_VOUT )
222             {
223                 msg_Dbg( p_playlist, "garbage collector destroying 1 vout" );
224                 vlc_object_detach( p_obj );
225                 vlc_object_release( p_obj );
226                 vout_Destroy( (vout_thread_t *)p_obj );
227             }
228             else if( i_type == VLC_OBJECT_SOUT )
229             {
230                 vlc_object_release( p_obj );
231                 sout_DeleteInstance( (sout_instance_t*)p_obj );
232             }
233         }
234         vlc_mutex_unlock( &p_playlist->gc_lock );
235         return 0;
236     }
237 }
238
239 /** Main loop for the playlist */
240 void playlist_MainLoop( playlist_t *p_playlist )
241 {
242     playlist_item_t *p_item = NULL;
243     vlc_bool_t b_playexit = var_GetBool( p_playlist, "play-and-exit" );
244     PL_LOCK;
245
246     /* First, check if we have something to do */
247     /* FIXME : this can be called several times */
248     if( p_playlist->request.b_request )
249     {
250         /* Stop the existing input */
251         if( p_playlist->p_input && !p_playlist->p_input->b_die )
252         {
253             PL_DEBUG( "incoming request - stopping current input" );
254             input_StopThread( p_playlist->p_input );
255         }
256     }
257
258     /* If there is an input, check that it doesn't need to die. */
259     if( p_playlist->p_input )
260     {
261         /* This input is dead. Remove it ! */
262         if( p_playlist->p_input->b_dead )
263         {
264             int i_activity;
265             input_thread_t *p_input;
266             PL_DEBUG( "dead input" );
267
268             p_input = p_playlist->p_input;
269             p_playlist->p_input = NULL;
270
271             /* Release the playlist lock, because we may get stuck
272              * in input_DestroyThread() for some time. */
273             PL_UNLOCK
274
275             /* Destroy input */
276             input_DestroyThread( p_input );
277
278             /* Unlink current input
279              * (_after_ input_DestroyThread for vout garbage collector) */
280             vlc_object_detach( p_input );
281
282             /* Destroy object */
283             vlc_object_destroy( p_input );
284
285             p_playlist->i_vout_destroyed_date = 0;
286             p_playlist->i_sout_destroyed_date = 0;
287
288             if( p_playlist->status.p_item->i_flags
289                 & PLAYLIST_REMOVE_FLAG )
290             {
291                  PL_DEBUG( "%s was marked for deletion, deleting",
292                                  PLI_NAME( p_playlist->status.p_item  ) );
293                  playlist_ItemDelete( p_playlist->status.p_item );
294                  if( p_playlist->request.p_item == p_playlist->status.p_item )
295                      p_playlist->request.p_item = NULL;
296                  p_playlist->status.p_item = NULL;
297             }
298
299             i_activity= var_GetInteger( p_playlist, "activity") ;
300             var_SetInteger( p_playlist, "activity", i_activity -
301                             DEFAULT_INPUT_ACTIVITY );
302
303             return;
304         }
305         /* This input is dying, let it do */
306         else if( p_playlist->p_input->b_die )
307         {
308             PL_DEBUG( "dying input" );
309         }
310         /* This input has finished, ask it to die ! */
311         else if( p_playlist->p_input->b_error
312                   || p_playlist->p_input->b_eof )
313         {
314             PL_DEBUG( "finished input" );
315             input_StopThread( p_playlist->p_input );
316             /* Select the next playlist item */
317             PL_UNLOCK
318             return;
319         }
320         else if( p_playlist->p_input->i_state != INIT_S )
321         {
322             PL_UNLOCK;
323             p_playlist->i_vout_destroyed_date =
324                 ObjectGarbageCollector( p_playlist, VLC_OBJECT_VOUT,
325                                         p_playlist->i_vout_destroyed_date );
326             p_playlist->i_sout_destroyed_date =
327                 ObjectGarbageCollector( p_playlist, VLC_OBJECT_SOUT,
328                                         p_playlist->i_sout_destroyed_date );
329             PL_LOCK
330         }
331     }
332     else
333     {
334         /* No input. Several cases
335          *  - No request, running status -> start new item
336          *  - No request, stopped status -> collect garbage
337          *  - Request, running requested -> start new item
338          *  - Request, stopped requested -> collect garbage
339          */
340          if( (!p_playlist->request.b_request &&
341               p_playlist->status.i_status != PLAYLIST_STOPPED) ||
342               ( p_playlist->request.b_request &&
343                 p_playlist->request.i_status != PLAYLIST_STOPPED ) )
344          {
345              msg_Dbg( p_playlist, "starting new item" );
346              stats_TimerStart( p_playlist, "Playlist walk",
347                                   STATS_TIMER_PLAYLIST_WALK );
348              p_item = playlist_NextItem( p_playlist );
349              stats_TimerStop( p_playlist, STATS_TIMER_PLAYLIST_WALK );
350
351              if( p_item == NULL )
352              {
353                 msg_Dbg( p_playlist, "nothing to play" );
354                 if( b_playexit == VLC_TRUE )
355                 {
356                     msg_Info( p_playlist, "end of playlist, exiting" );
357                     p_playlist->p_libvlc->b_die = VLC_TRUE;
358                 }
359                 p_playlist->status.i_status = PLAYLIST_STOPPED;
360                 PL_UNLOCK
361                 return;
362              }
363              playlist_PlayItem( p_playlist, p_item );
364          }
365          else
366          {
367              p_playlist->status.i_status = PLAYLIST_STOPPED;
368              if( p_playlist->status.p_item &&
369                  p_playlist->status.p_item->i_flags & PLAYLIST_REMOVE_FLAG )
370              {
371                  PL_DEBUG( "deleting item marked for deletion" );
372                  playlist_ItemDelete( p_playlist->status.p_item );
373                  p_playlist->status.p_item = NULL;
374              }
375
376              /* Collect garbage */
377              PL_UNLOCK
378              p_playlist->i_sout_destroyed_date =
379              ObjectGarbageCollector( p_playlist, VLC_OBJECT_SOUT, mdate() );
380              p_playlist->i_vout_destroyed_date =
381              ObjectGarbageCollector( p_playlist, VLC_OBJECT_VOUT, mdate() );
382              PL_LOCK
383          }
384     }
385     PL_UNLOCK
386 }
387
388 /** Playlist dying last loop */
389 void playlist_LastLoop( playlist_t *p_playlist )
390 {
391     vlc_object_t *p_obj;
392
393     /* If there is an input, kill it */
394     while( 1 )
395     {
396         PL_LOCK
397
398         if( p_playlist->p_input == NULL )
399         {
400             PL_UNLOCK
401             break;
402         }
403
404         if( p_playlist->p_input->b_dead )
405         {
406             input_thread_t *p_input;
407
408             /* Unlink current input */
409             p_input = p_playlist->p_input;
410             p_playlist->p_input = NULL;
411             PL_UNLOCK
412
413             /* Destroy input */
414             input_DestroyThread( p_input );
415             /* Unlink current input (_after_ input_DestroyThread for vout
416              * garbage collector)*/
417             vlc_object_detach( p_input );
418
419             /* Destroy object */
420             vlc_object_destroy( p_input );
421             continue;
422         }
423         else if( p_playlist->p_input->b_die )
424         {
425             /* This input is dying, leave it alone */
426             ;
427         }
428         else if( p_playlist->p_input->b_error || p_playlist->p_input->b_eof )
429         {
430             input_StopThread( p_playlist->p_input );
431             PL_UNLOCK
432             continue;
433         }
434         else
435         {
436             p_playlist->p_input->b_eof = 1;
437         }
438
439         PL_UNLOCK
440
441         msleep( INTF_IDLE_SLEEP );
442     }
443
444     /* close all remaining sout */
445     while( ( p_obj = vlc_object_find( p_playlist,
446                                       VLC_OBJECT_SOUT, FIND_CHILD ) ) )
447     {
448         vlc_object_release( p_obj );
449         sout_DeleteInstance( (sout_instance_t*)p_obj );
450     }
451
452     /* close all remaining vout */
453     while( ( p_obj = vlc_object_find( p_playlist,
454                                       VLC_OBJECT_VOUT, FIND_CHILD ) ) )
455     {
456         vlc_object_detach( p_obj );
457         vlc_object_release( p_obj );
458         vout_Destroy( (vout_thread_t *)p_obj );
459     }
460 }
461
462 /** Main loop for preparser queue */
463 void playlist_PreparseLoop( playlist_preparse_t *p_obj )
464 {
465     playlist_t *p_playlist = (playlist_t *)p_obj->p_parent;
466     input_item_t *p_current;
467     int i_activity;
468     uint32_t i_m, i_o;
469
470     while( !p_playlist->b_die )
471     {
472         vlc_mutex_lock( &p_obj->object_lock );
473         while( p_obj->i_waiting == 0 )
474         {
475             vlc_cond_wait( &p_obj->object_wait, &p_obj->object_lock );
476             if( p_playlist->b_die )
477             {
478                 vlc_mutex_unlock( &p_obj->object_lock );
479                 return;
480             }
481         }
482
483         p_current = p_obj->pp_waiting[0];
484         REMOVE_ELEM( p_obj->pp_waiting, p_obj->i_waiting, 0 );
485         vlc_mutex_unlock( &p_obj->object_lock );
486
487         PL_LOCK;
488         if( p_current )
489         {
490             vlc_bool_t b_preparsed = VLC_FALSE;
491             if( strncmp( p_current->psz_uri, "http:", 5 ) &&
492                 strncmp( p_current->psz_uri, "rtsp:", 5 ) &&
493                 strncmp( p_current->psz_uri, "udp:", 4 ) &&
494                 strncmp( p_current->psz_uri, "mms:", 4 ) &&
495                 strncmp( p_current->psz_uri, "cdda:", 4 ) &&
496                 strncmp( p_current->psz_uri, "dvd:", 4 ) &&
497                 strncmp( p_current->psz_uri, "v4l:", 4 ) &&
498                 strncmp( p_current->psz_uri, "dshow:", 6 ) )
499             {
500                 b_preparsed = VLC_TRUE;
501                 stats_TimerStart( p_playlist, "Preparse run",
502                                   STATS_TIMER_PREPARSE );
503                 PL_UNLOCK;
504                 input_Preparse( p_playlist, p_current );
505                 PL_LOCK;
506                 stats_TimerStop( p_playlist, STATS_TIMER_PREPARSE );
507             }
508             PL_UNLOCK;
509             if( b_preparsed )
510             {
511                 p_current->p_meta->i_status |= ITEM_PREPARSED;
512                 var_SetInteger( p_playlist, "item-change", p_current->i_id );
513             }
514             PL_LOCK;
515
516             /* If we haven't retrieved enough meta, add to secondary queue
517              * which will run the "meta fetchers"
518              * TODO:
519              *  don't do this for things we won't get meta for, like
520              *  videos
521              */
522             if( !input_MetaSatisfied( p_playlist, p_current, &i_m, &i_o,
523                                       VLC_TRUE ) )
524             {
525                 preparse_item_t p;
526                 p.p_item = p_current;
527                 p.b_fetch_art = VLC_FALSE;
528                 vlc_mutex_lock( &p_playlist->p_secondary_preparse->object_lock);
529                 INSERT_ELEM( p_playlist->p_secondary_preparse->p_waiting,
530                              p_playlist->p_secondary_preparse->i_waiting,
531                              p_playlist->p_secondary_preparse->i_waiting,
532                              p );
533                 vlc_mutex_unlock(
534                             &p_playlist->p_secondary_preparse->object_lock);
535                 vlc_cond_signal(
536                             &p_playlist->p_secondary_preparse->object_wait );
537             }
538             else
539                 vlc_gc_decref( p_current );
540             PL_UNLOCK;
541         }
542         else
543             PL_UNLOCK;
544
545         vlc_mutex_lock( &p_obj->object_lock );
546         i_activity = var_GetInteger( p_playlist, "activity" );
547         if( i_activity < 0 ) i_activity = 0;
548         vlc_mutex_unlock( &p_obj->object_lock );
549         /* Sleep at least 1ms */
550         msleep( (i_activity+1) * 1000 );
551     }
552 }
553
554 /** Main loop for secondary preparser queue */
555 void playlist_SecondaryPreparseLoop( playlist_secondary_preparse_t *p_obj )
556 {
557     playlist_t *p_playlist = (playlist_t *)p_obj->p_parent;
558     vlc_bool_t b_fetch_art;
559     input_item_t *p_item;
560     int i_activity;
561
562     while( !p_playlist->b_die )
563     {
564         vlc_mutex_lock( &p_obj->object_lock );
565         while( p_obj->i_waiting == 0 )
566         {
567             vlc_cond_wait( &p_obj->object_wait, &p_obj->object_lock );
568             if( p_playlist->b_die )
569             {
570                 vlc_mutex_unlock( &p_obj->object_lock );
571                 return;
572             }
573         }
574
575         b_fetch_art = p_obj->p_waiting->b_fetch_art;
576         p_item = p_obj->p_waiting->p_item;
577         REMOVE_ELEM( p_obj->p_waiting, p_obj->i_waiting, 0 );
578         vlc_mutex_unlock( &p_obj->object_lock );
579         if( p_item )
580         {
581             if( !b_fetch_art )
582             {
583                 input_MetaFetch( p_playlist, p_item );
584                 p_item->p_meta->i_status |= ITEM_META_FETCHED;
585                 var_SetInteger( p_playlist, "item-change", p_item->i_id );
586                 /*  Fetch right now */
587                 if( var_GetInteger( p_playlist, "album-art" ) == ALBUM_ART_ALL )
588                 {
589                     vlc_mutex_lock( &p_obj->object_lock );
590                     preparse_item_t p;
591                     p.p_item = p_item;
592                     p.b_fetch_art = VLC_TRUE;
593                     INSERT_ELEM( p_playlist->p_secondary_preparse->p_waiting,
594                                  p_playlist->p_secondary_preparse->i_waiting,
595                                  0, p );
596                     vlc_mutex_unlock( &p_obj->object_lock );
597                 }
598                 else
599                     vlc_gc_decref( p_item );
600             }
601             else
602             {
603                 input_ArtFetch( p_playlist, p_item );
604                 p_item->p_meta->i_status |= ITEM_ART_FETCHED;
605                 vlc_gc_decref( p_item );
606            }
607         }
608         vlc_mutex_lock( &p_obj->object_lock );
609         i_activity = var_GetInteger( p_playlist, "activity" );
610         if( i_activity < 0 ) i_activity = 0;
611         vlc_mutex_unlock( &p_obj->object_lock );
612         /* Sleep at least 1ms */
613         msleep( (i_activity+1) * 1000 );
614     }
615 }
616
617 static void VariablesInit( playlist_t *p_playlist )
618 {
619     vlc_value_t val;
620     /* These variables control updates */
621     var_Create( p_playlist, "intf-change", VLC_VAR_BOOL );
622     val.b_bool = VLC_TRUE;
623     var_Set( p_playlist, "intf-change", val );
624
625     var_Create( p_playlist, "item-change", VLC_VAR_INTEGER );
626     val.i_int = -1;
627     var_Set( p_playlist, "item-change", val );
628
629     var_Create( p_playlist, "item-deleted", VLC_VAR_INTEGER );
630     val.i_int = -1;
631     var_Set( p_playlist, "item-deleted", val );
632
633     var_Create( p_playlist, "item-append", VLC_VAR_ADDRESS );
634
635     var_Create( p_playlist, "playlist-current", VLC_VAR_INTEGER );
636     val.i_int = -1;
637     var_Set( p_playlist, "playlist-current", val );
638
639     var_Create( p_playlist, "intf-popupmenu", VLC_VAR_BOOL );
640
641     var_Create( p_playlist, "intf-show", VLC_VAR_BOOL );
642     val.b_bool = VLC_TRUE;
643     var_Set( p_playlist, "intf-show", val );
644
645     var_Create( p_playlist, "activity", VLC_VAR_INTEGER );
646     var_SetInteger( p_playlist, "activity", 0 );
647
648     /* Variables to control playback */
649     var_CreateGetBool( p_playlist, "play-and-stop" );
650     var_CreateGetBool( p_playlist, "play-and-exit" );
651     var_CreateGetBool( p_playlist, "random" );
652     var_CreateGetBool( p_playlist, "repeat" );
653     var_CreateGetBool( p_playlist, "loop" );
654
655     var_AddCallback( p_playlist, "random", RandomCallback, NULL );
656 }