]> git.sesse.net Git - vlc/blob - src/vlc.c
* ALL: the first libvlc commit.
[vlc] / src / vlc.c
1 /*****************************************************************************
2  * vlc.c: the vlc player
3  *****************************************************************************
4  * Copyright (C) 1998-2001 VideoLAN
5  * $Id: vlc.c,v 1.1 2002/06/01 12:32:01 sam Exp $
6  *
7  * Authors: Vincent Seguin <seguin@via.ecp.fr>
8  *          Samuel Hocevar <sam@zoy.org>
9  *          Gildas Bazin <gbazin@netcourrier.com>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
24  *****************************************************************************/
25 #include <signal.h>                               /* SIGHUP, SIGINT, SIGKILL */
26 #include <stdio.h>                                              /* fprintf() */
27 #include <stdlib.h>                                  /* putenv(), strtol(),  */
28
29 #include <vlc/vlc.h>
30
31 /*****************************************************************************
32  * main: parse command line, start interface and spawn threads
33  *****************************************************************************/
34 int main(int i_argc, char *ppsz_argv[], char *ppsz_env[])
35 {
36     vlc_t *p_vlc;
37     vlc_error_t err;
38
39 #ifdef SYS_LINUX
40 #   ifdef DEBUG
41     /* Activate malloc checking routines to detect heap corruptions. */
42     putenv( "MALLOC_CHECK_=2" );
43
44     /* Disable the ugly Gnome crash dialog so that we properly segfault */
45     putenv( "GNOME_DISABLE_CRASH_DIALOG=1" );
46 #   endif
47 #endif
48
49     /* Create the vlc structure */
50     p_vlc = vlc_create();
51     if( p_vlc == NULL )
52     {
53         return -1;
54     }
55
56     /* Initialize vlc */
57     err = vlc_init( p_vlc, i_argc, ppsz_argv );
58     if( err != VLC_SUCCESS )
59     {
60         vlc_destroy( p_vlc );
61         return err;
62     }
63
64     //vlc_add( p_vlc, "/home/sam/videolan/streams/mpeg/axe.mpeg" );
65
66     /* Run vlc, in non-blocking mode */
67     err = vlc_run( p_vlc );
68
69     /* Add background interfaces */
70     //{ int i; for( i=10; i--; ) vlc_add_intf( p_vlc, "dummy", 0 ); }
71     vlc_add_intf( p_vlc, "dummy", VLC_FALSE );
72     vlc_add_intf( p_vlc, "logger", VLC_FALSE );
73     vlc_add_intf( p_vlc, "rc", VLC_FALSE );
74
75     /* Add a blocking interface */
76     err = vlc_add_intf( p_vlc, NULL, VLC_TRUE );
77     if( err != VLC_SUCCESS )
78     {
79         vlc_end( p_vlc );
80         vlc_destroy( p_vlc );
81         return err;
82     }
83
84     /* Finish the interface */
85     vlc_stop( p_vlc );
86
87     /* Finish all threads */
88     vlc_end( p_vlc );
89
90     /* Destroy the vlc structure */
91     vlc_destroy( p_vlc );
92
93     return 0;
94 }
95