1 /*****************************************************************************
2 * beos_init.cpp: Initialization for BeOS specific features
3 *****************************************************************************
4 * Copyright (C) 1999-2001 VideoLAN
5 * $Id: beos_specific.cpp,v 1.18 2002/04/26 05:43:37 sam Exp $
7 * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
23 #include <Application.h>
28 #include <string.h> /* strdup() */
29 #include <malloc.h> /* free() */
33 #include <videolan/vlc.h>
36 /*****************************************************************************
37 * The VlcApplication class
38 *****************************************************************************/
39 class VlcApplication : public BApplication
42 VlcApplication(char* );
45 virtual void ReadyToRun();
46 virtual void AboutRequested();
49 /*****************************************************************************
51 *****************************************************************************/
52 static vlc_thread_t app_thread;
53 static vlc_mutex_t app_lock;
54 static vlc_cond_t app_wait;
55 static char *psz_program_path;
60 /*****************************************************************************
62 *****************************************************************************/
63 static void system_AppThread( void * args );
65 /*****************************************************************************
66 * system_Init: create a BApplication object and fill in program path.
67 *****************************************************************************/
68 void system_Init( int *pi_argc, char *ppsz_argv[], char *ppsz_env[] )
70 /* Prepare the lock/wait before launching the BApplication thread */
71 vlc_mutex_init( &app_lock );
72 vlc_cond_init( &app_wait );
73 vlc_mutex_lock( &app_lock );
75 /* Create the BApplication thread */
76 vlc_thread_create( &app_thread, "app thread",
77 (vlc_thread_func_t)system_AppThread, 0 );
79 /* Wait for the application to be initialized */
80 vlc_cond_wait( &app_wait, &app_lock );
81 vlc_mutex_unlock( &app_lock );
83 /* Destroy the locks */
84 vlc_mutex_destroy( &app_lock );
85 vlc_cond_destroy( &app_wait );
88 /*****************************************************************************
89 * system_Configure: check for system specific configuration options.
90 *****************************************************************************/
91 void system_Configure( void )
96 /*****************************************************************************
97 * system_End: destroy the BApplication object.
98 *****************************************************************************/
99 void system_End( void )
101 free( psz_program_path );
103 /* Tell the BApplication to die */
104 be_app->PostMessage( B_QUIT_REQUESTED );
105 vlc_thread_join( app_thread );
108 /*****************************************************************************
109 * system_GetProgramPath: get the full path to the program.
110 *****************************************************************************/
111 char * system_GetProgramPath( void )
113 return( psz_program_path );
116 /* following functions are local */
118 /*****************************************************************************
119 * system_AppThread: the BApplication thread.
120 *****************************************************************************/
121 static void system_AppThread( void * args )
123 VlcApplication *BeApp = new VlcApplication("application/x-vnd.Ink-vlc");
130 /*****************************************************************************
131 * VlcApplication: application constructor
132 *****************************************************************************/
133 VlcApplication::VlcApplication( char * psz_mimetype )
134 :BApplication( psz_mimetype )
136 /* Nothing to do, we use the default constructor */
139 /*****************************************************************************
140 * ~VlcApplication: application destructor
141 *****************************************************************************/
142 VlcApplication::~VlcApplication( )
144 /* Nothing to do, we use the default destructor */
147 /*****************************************************************************
148 * AboutRequested: called by the system on B_ABOUT_REQUESTED
149 *****************************************************************************/
150 void VlcApplication::AboutRequested( )
153 alert = new BAlert( VOUT_TITLE,
154 "BeOS " VOUT_TITLE "\n\n<www.videolan.org>",
159 /*****************************************************************************
160 * ReadyToRun: called when the BApplication is initialized
161 *****************************************************************************/
162 void VlcApplication::ReadyToRun( )
167 /* Get the program path */
168 be_app->GetAppInfo( &info );
169 BEntry entry( &info.ref );
170 entry.GetPath( &path );
171 path.GetParent( &path );
172 psz_program_path = strdup( path.Path() );
174 /* Tell the main thread we are finished initializing the BApplication */
175 vlc_mutex_lock( &app_lock );
176 vlc_cond_signal( &app_wait );
177 vlc_mutex_unlock( &app_lock );