1 /*****************************************************************************
2 * intf_beos.cpp: beos interface
3 *****************************************************************************
4 * Copyright (C) 1999, 2000, 2001 VideoLAN
5 * $Id: intf_beos.cpp,v 1.33 2001/11/28 15:08:05 massiot Exp $
7 * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
8 * Samuel Hocevar <sam@zoy.org>
9 * Tony Castley <tony@castley.net>
10 * Richard Shepherd <richard@rshepherd.demon.co.uk>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
25 *****************************************************************************/
27 #define MODULE_NAME beos
28 #include "modules_inner.h"
30 /*****************************************************************************
32 *****************************************************************************/
36 #include <stdlib.h> /* malloc(), free() */
37 #include <InterfaceKit.h>
48 #include "stream_control.h"
49 #include "interface.h"
50 #include "input_ext-intf.h"
53 #include "modules_export.h"
56 #include "InterfaceWindow.h"
58 /*****************************************************************************
59 * intf_sys_t: description and status of FB interface
60 *****************************************************************************/
61 typedef struct intf_sys_s
63 InterfaceWindow * p_window;
71 /*****************************************************************************
73 *****************************************************************************/
74 static int intf_Probe ( probedata_t *p_data );
75 static int intf_Open ( intf_thread_t *p_intf );
76 static void intf_Close ( intf_thread_t *p_intf );
77 static void intf_Run ( intf_thread_t *p_intf );
79 /*****************************************************************************
80 * Functions exported as capabilities. They are declared as static so that
81 * we don't pollute the namespace too much.
82 *****************************************************************************/
83 void _M( intf_getfunctions )( function_list_t * p_function_list )
85 p_function_list->pf_probe = intf_Probe;
86 p_function_list->functions.intf.pf_open = intf_Open;
87 p_function_list->functions.intf.pf_close = intf_Close;
88 p_function_list->functions.intf.pf_run = intf_Run;
91 /*****************************************************************************
92 * intf_Probe: probe the interface and return a score
93 *****************************************************************************
94 * This function tries to initialize Gnome and returns a score to the
95 * plugin manager so that it can select the best plugin.
96 *****************************************************************************/
97 static int intf_Probe( probedata_t *p_data )
99 if( TestMethod( INTF_METHOD_VAR, "beos" ) )
107 /*****************************************************************************
108 * intf_Open: initialize interface
109 *****************************************************************************/
110 static int intf_Open( intf_thread_t *p_intf )
113 screen = new BScreen();
114 BRect rect = screen->Frame();
115 rect.top = rect.bottom-100;
118 rect.right = rect.left + 350;
121 /* Allocate instance and initialize some members */
122 p_intf->p_sys = (intf_sys_t*) malloc( sizeof( intf_sys_t ) );
123 if( p_intf->p_sys == NULL )
125 intf_ErrMsg("error: %s", strerror(ENOMEM));
128 p_intf->p_sys->i_key = -1;
130 /* Create the interface window */
131 p_intf->p_sys->p_window =
132 new InterfaceWindow( rect,
133 VOUT_TITLE " (BeOS interface)", p_intf );
134 if( p_intf->p_sys->p_window == 0 )
136 free( p_intf->p_sys );
137 intf_ErrMsg( "error: cannot allocate memory for InterfaceWindow" );
144 /*****************************************************************************
145 * intf_Close: destroy dummy interface
146 *****************************************************************************/
147 static void intf_Close( intf_thread_t *p_intf )
149 /* Destroy the interface window */
150 p_intf->p_sys->p_window->Lock();
151 p_intf->p_sys->p_window->Quit();
153 /* Destroy structure */
154 free( p_intf->p_sys );
158 /*****************************************************************************
159 * intf_Run: event loop
160 *****************************************************************************/
161 static void intf_Run( intf_thread_t *p_intf )
164 while( !p_intf->b_die )
166 /* Manage core vlc functions through the callback */
167 p_intf->pf_manage( p_intf );
169 /* Manage the slider */
170 if( p_intf->p_input != NULL && p_intf->p_sys->p_window != NULL)
172 p_intf->p_sys->p_window->updateInterface();
176 msleep( INTF_IDLE_SLEEP );