X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmisc%2Fbeos_specific.cpp;h=51c70cf8a8182b9caeb871e1b55dab9c037c16f0;hb=12ade3e3bc975d5426ba4af155b7372c31093b31;hp=dab984350afa3587017e9c9b499c517308f1794a;hpb=0e5978dc5b84ec3e8d526bea56e69f32f2272c55;p=vlc diff --git a/src/misc/beos_specific.cpp b/src/misc/beos_specific.cpp index dab984350a..51c70cf8a8 100644 --- a/src/misc/beos_specific.cpp +++ b/src/misc/beos_specific.cpp @@ -1,8 +1,8 @@ /***************************************************************************** - * beos_init.cpp: Initialization for BeOS specific features + * beos_init.cpp: Initialization for BeOS specific features ***************************************************************************** - * Copyright (C) 1999-2001 VideoLAN - * $Id: beos_specific.cpp,v 1.27 2002/10/09 01:14:18 titer Exp $ + * Copyright (C) 1999-2004 the VideoLAN team + * $Id$ * * Authors: Jean-Marc Dressler * @@ -10,7 +10,7 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #include #include @@ -29,11 +29,16 @@ #include #include /* strdup() */ -#include /* free() */ +#include /* free() */ extern "C" { -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include "../libvlc.h" } /***************************************************************************** @@ -51,19 +56,22 @@ public: virtual void AboutRequested(); virtual void RefsReceived(BMessage* message); virtual void MessageReceived(BMessage* message); - + virtual bool QuitRequested(); + private: BWindow* fInterfaceWindow; BMessage* fRefsMessage; + bool fReadyToQuit; }; /***************************************************************************** * Static vars *****************************************************************************/ -static char * psz_program_path; -//const uint32 INTERFACE_CREATED = 'ifcr'; /* message sent from interface */ #include "../../modules/gui/beos/MsgVals.h" +#define REALLY_QUIT 'requ' + +static vlc_object_t *p_appthread; extern "C" { @@ -71,49 +79,40 @@ extern "C" /***************************************************************************** * Local prototypes. *****************************************************************************/ -static void AppThread( vlc_object_t *p_appthread ); +static void* AppThread( vlc_object_t *p_appthread ); /***************************************************************************** * system_Init: create a BApplication object and fill in program path. *****************************************************************************/ -void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] ) +void system_Init( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv[] ) { - p_this->p_libvlc->p_appthread = + p_appthread = (vlc_object_t *)vlc_object_create( p_this, sizeof(vlc_object_t) ); /* Create the BApplication thread and wait for initialization */ - vlc_thread_create( p_this->p_libvlc->p_appthread, "app thread", AppThread, - VLC_THREAD_PRIORITY_LOW, VLC_TRUE ); + vlc_thread_create( p_appthread, "app thread", AppThread, + VLC_THREAD_PRIORITY_LOW, true ); } /***************************************************************************** * system_Configure: check for system specific configuration options. *****************************************************************************/ -void system_Configure( vlc_t * ) +void system_Configure( libvlc_int_t *, int *pi_argc, const char *ppsz_argv[] ) { - } /***************************************************************************** * system_End: destroy the BApplication object. *****************************************************************************/ -void system_End( vlc_t *p_this ) +void system_End( libvlc_int_t *p_this ) { /* Tell the BApplication to die */ - be_app->PostMessage( B_QUIT_REQUESTED ); + be_app->PostMessage( REALLY_QUIT ); - vlc_thread_join( p_this->p_libvlc->p_appthread ); - vlc_object_destroy( p_this->p_libvlc->p_appthread ); + vlc_thread_join( p_appthread ); + vlc_object_release( p_appthread ); - free( psz_program_path ); -} - -/***************************************************************************** - * system_GetProgramPath: get the full path to the program. - *****************************************************************************/ -char * system_GetProgramPath( void ) -{ - return( psz_program_path ); + free( psz_vlcpath ); } /* following functions are local */ @@ -121,14 +120,18 @@ char * system_GetProgramPath( void ) /***************************************************************************** * AppThread: the BApplication thread. *****************************************************************************/ -static void AppThread( vlc_object_t * p_this ) +static void* AppThread( vlc_object_t * p_this ) { - VlcApplication *BeApp = new VlcApplication("application/x-vnd.Ink-vlc"); - vlc_object_attach( p_this, p_this->p_vlc ); + int canc = vlc_savecancel (); + VlcApplication * BeApp = + new VlcApplication("application/x-vnd.videolan-vlc"); + vlc_object_attach( p_this, p_this->p_libvlc ); BeApp->p_this = p_this; BeApp->Run(); vlc_object_detach( p_this ); delete BeApp; + vlc_restorecancel (canc); + return NULL; } } /* extern "C" */ @@ -139,7 +142,8 @@ static void AppThread( vlc_object_t * p_this ) VlcApplication::VlcApplication( char * psz_mimetype ) :BApplication( psz_mimetype ), fInterfaceWindow( NULL ), - fRefsMessage( NULL ) + fRefsMessage( NULL ), + fReadyToQuit( false ) { /* Nothing to do, we use the default constructor */ } @@ -159,9 +163,9 @@ VlcApplication::~VlcApplication( ) void VlcApplication::AboutRequested( ) { BAlert *alert; - alert = new BAlert( VOUT_TITLE, - "BeOS " VOUT_TITLE "\n\n", - "Ok" ); + alert = new BAlert( "VLC " PACKAGE_VERSION, + "VLC " PACKAGE_VERSION " for BeOS\n\n" + "", "OK"); alert->Go( NULL ); } @@ -171,14 +175,14 @@ void VlcApplication::AboutRequested( ) void VlcApplication::ReadyToRun( ) { BPath path; - app_info info; + app_info info; /* Get the program path */ - be_app->GetAppInfo( &info ); - BEntry entry( &info.ref ); - entry.GetPath( &path ); + be_app->GetAppInfo( &info ); + BEntry entry( &info.ref ); + entry.GetPath( &path ); path.GetParent( &path ); - psz_program_path = strdup( path.Path() ); + psz_vlcpath = strdup( path.Path() ); /* Tell the main thread we are finished initializing the BApplication */ vlc_thread_ready( p_this ); @@ -190,12 +194,12 @@ void VlcApplication::ReadyToRun( ) *****************************************************************************/ void VlcApplication::RefsReceived(BMessage* message) { - if (fInterfaceWindow) - fInterfaceWindow->PostMessage(message); - else { - delete fRefsMessage; - fRefsMessage = new BMessage(*message); - } + if (fInterfaceWindow) + fInterfaceWindow->PostMessage(message); + else { + delete fRefsMessage; + fRefsMessage = new BMessage(*message); + } } /***************************************************************************** @@ -211,20 +215,38 @@ void VlcApplication::RefsReceived(BMessage* message) *****************************************************************************/ void VlcApplication::MessageReceived(BMessage* message) { - switch (message->what) { - case INTERFACE_CREATED: { - BWindow* interfaceWindow; - if (message->FindPointer("window", (void**)&interfaceWindow) == B_OK) { - fInterfaceWindow = interfaceWindow; - if (fRefsMessage) { - fInterfaceWindow->PostMessage(fRefsMessage); - delete fRefsMessage; - fRefsMessage = NULL; - } - } - break; - } - default: - BApplication::MessageReceived(message); - } + switch (message->what) { + case INTERFACE_CREATED: { + BWindow* interfaceWindow; + if (message->FindPointer("window", (void**)&interfaceWindow) == B_OK) { + fInterfaceWindow = interfaceWindow; + if (fRefsMessage) { + fInterfaceWindow->PostMessage(fRefsMessage); + delete fRefsMessage; + fRefsMessage = NULL; + } + } + break; + } + + case REALLY_QUIT: + fReadyToQuit = true; + PostMessage( B_QUIT_REQUESTED ); + break; + + default: + BApplication::MessageReceived(message); + } +} + +bool VlcApplication::QuitRequested() +{ + if( !fReadyToQuit ) + { + libvlc_Quit( p_this->p_libvlc ); + return false; + } + + BApplication::QuitRequested(); + return true; }