Uniformize source files encoding
[vlc.git] / src / control / playlist.c
1 /*****************************************************************************
2  * playlist.c: libvlc new API playlist handling functions
3  *****************************************************************************
4  * Copyright (C) 2005 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 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 General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #include <libvlc_internal.h>
25 #include <vlc/libvlc.h>
26
27 #include <vlc/intf.h>
28
29 void libvlc_playlist_play( libvlc_instance_t *p_instance,
30                            int i_options, char **ppsz_options,
31                            libvlc_exception_t *p_exception )
32 {
33     ///\todo Handle additionnal options
34
35     if( p_instance->p_playlist->i_size == 0 )
36     {
37         libvlc_exception_raise( p_exception, "Empty playlist" );
38         return;
39     }
40     playlist_Play( p_instance->p_playlist );
41 }
42
43 void libvlc_playlist_stop( libvlc_instance_t *p_instance,
44                            libvlc_exception_t *p_exception )
45 {
46     if( playlist_Stop( p_instance->p_playlist ) != VLC_SUCCESS )
47     {
48         libvlc_exception_raise( p_exception, "Empty playlist" );
49     }
50 }
51
52 void libvlc_playlist_clear( libvlc_instance_t *p_instance,
53                            libvlc_exception_t *p_exception )
54 {
55     playlist_Clear( p_instance->p_playlist );
56 }
57
58
59 libvlc_input_t * libvlc_playlist_get_input( libvlc_instance_t *p_instance,
60                                             libvlc_exception_t *p_exception )
61 {
62     libvlc_input_t *p_input;
63
64     vlc_mutex_lock( &p_instance->p_playlist->object_lock );
65     if( p_instance->p_playlist->p_input == NULL )
66     {
67         libvlc_exception_raise( p_exception, "No active input" );
68         vlc_mutex_unlock( &p_instance->p_playlist->object_lock );
69         return NULL;
70     }
71     p_input = (libvlc_input_t *)malloc( sizeof( libvlc_input_t ) );
72
73     p_input->i_input_id = p_instance->p_playlist->p_input->i_object_id;
74     p_input->p_instance = p_instance;
75     vlc_mutex_unlock( &p_instance->p_playlist->object_lock );
76
77     return p_input;
78 }