00001 /***************************************************************************** 00002 * intf_beos.cpp: beos interface 00003 ***************************************************************************** 00004 * Copyright (C) 1999, 2000, 2001 the VideoLAN team 00005 * $Id: Interface.cpp 11664 2005-07-09 06:17:09Z courmisch $ 00006 * 00007 * Authors: Jean-Marc Dressler <[email protected]> 00008 * Samuel Hocevar <[email protected]> 00009 * Tony Castley <[email protected]> 00010 * Richard Shepherd <[email protected]> 00011 * Stephan Aßmus <[email protected]> 00012 * Eric Petit <[email protected]> 00013 * 00014 * This program is free software; you can redistribute it and/or modify 00015 * it under the terms of the GNU General Public License as published by 00016 * the Free Software Foundation; either version 2 of the License, or 00017 * (at your option) any later version. 00018 * 00019 * This program is distributed in the hope that it will be useful, 00020 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 * GNU General Public License for more details. 00023 * 00024 * You should have received a copy of the GNU General Public License 00025 * along with this program; if not, write to the Free Software 00026 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. 00027 *****************************************************************************/ 00028 00029 /***************************************************************************** 00030 * Preamble 00031 *****************************************************************************/ 00032 #include <stdio.h> 00033 #include <stdlib.h> /* malloc(), free() */ 00034 #include <InterfaceKit.h> 00035 #include <Application.h> 00036 #include <Message.h> 00037 #include <string.h> 00038 00039 #include <vlc/vlc.h> 00040 #include <vlc/intf.h> 00041 #include <vlc/aout.h> 00042 #include <aout_internal.h> 00043 00044 #include "InterfaceWindow.h" 00045 #include "MsgVals.h" 00046 00047 /***************************************************************************** 00048 * intf_sys_t: internal variables of the BeOS interface 00049 *****************************************************************************/ 00050 struct intf_sys_t 00051 { 00052 InterfaceWindow * p_window; 00053 }; 00054 00055 /***************************************************************************** 00056 * Local prototype 00057 *****************************************************************************/ 00058 static void Run ( intf_thread_t *p_intf ); 00059 00060 /***************************************************************************** 00061 * intf_Open: initialize interface 00062 *****************************************************************************/ 00063 int E_(OpenIntf) ( vlc_object_t *p_this ) 00064 { 00065 intf_thread_t * p_intf = (intf_thread_t*) p_this; 00066 00067 /* Allocate instance and initialize some members */ 00068 p_intf->p_sys = (intf_sys_t*) malloc( sizeof( intf_sys_t ) ); 00069 if( !p_intf->p_sys ) 00070 { 00071 msg_Err( p_intf, "out of memory" ); 00072 return VLC_EGENERIC; 00073 } 00074 00075 p_intf->pf_run = Run; 00076 00077 /* Create the interface window */ 00078 BScreen screen( B_MAIN_SCREEN_ID ); 00079 BRect rect = screen.Frame(); 00080 rect.top = rect.bottom - 100; 00081 rect.bottom -= 50; 00082 rect.left += 50; 00083 rect.right = rect.left + 350; 00084 p_intf->p_sys->p_window = 00085 new InterfaceWindow( p_intf, rect, "VLC " VERSION ); 00086 if( !p_intf->p_sys->p_window ) 00087 { 00088 free( p_intf->p_sys ); 00089 msg_Err( p_intf, "cannot allocate InterfaceWindow" ); 00090 return VLC_EGENERIC; 00091 } 00092 00093 /* Make the be_app aware the interface has been created */ 00094 BMessage message( INTERFACE_CREATED ); 00095 message.AddPointer( "window", p_intf->p_sys->p_window ); 00096 be_app->PostMessage( &message ); 00097 00098 return VLC_SUCCESS; 00099 } 00100 00101 /***************************************************************************** 00102 * intf_Close: destroy dummy interface 00103 *****************************************************************************/ 00104 void E_(CloseIntf) ( vlc_object_t *p_this ) 00105 { 00106 intf_thread_t *p_intf = (intf_thread_t*) p_this; 00107 00108 /* Destroy the interface window */ 00109 if( p_intf->p_sys->p_window->Lock() ) 00110 p_intf->p_sys->p_window->Quit(); 00111 00112 /* Destroy structure */ 00113 free( p_intf->p_sys ); 00114 } 00115 00116 00117 /***************************************************************************** 00118 * intf_Run: event loop 00119 *****************************************************************************/ 00120 static void Run( intf_thread_t *p_intf ) 00121 { 00122 while( !p_intf->b_die ) 00123 { 00124 p_intf->p_sys->p_window->UpdateInterface(); 00125 msleep( INTF_IDLE_SLEEP ); 00126 } 00127 }