]> git.sesse.net Git - vlc/blob - src/control/playlist.c
return NULL properly in libvlc_playlist_get_input()
[vlc] / 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�ent 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 libvlc_input_t * libvlc_playlist_get_input( libvlc_instance_t *p_instance,
44                                             libvlc_exception_t *p_exception )
45 {
46     libvlc_input_t *p_input;
47
48     vlc_mutex_lock( &p_instance->p_playlist->object_lock );
49     if( p_instance->p_playlist->p_input == NULL )
50     {
51         libvlc_exception_raise( p_exception, "No active input" );
52         vlc_mutex_unlock( &p_instance->p_playlist->object_lock );
53         return NULL;
54     }
55     p_input = (libvlc_input_t *)malloc( sizeof( libvlc_input_t ) );
56
57     p_input->i_input_id = p_instance->p_playlist->p_input->i_object_id;
58     p_input->p_instance = p_instance;
59     vlc_mutex_unlock( &p_instance->p_playlist->object_lock );
60
61     return p_input;
62 }