1 /*****************************************************************************
2 * intf_beos.cpp: beos interface
3 *****************************************************************************
4 * Copyright (C) 1999, 2000, 2001 VideoLAN
5 * $Id: intf_beos.cpp,v 1.37 2002/01/19 19:54:01 gbazin 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 /*****************************************************************************
29 *****************************************************************************/
31 #include <stdlib.h> /* malloc(), free() */
32 #include <InterfaceKit.h>
37 #include <videolan/vlc.h>
39 #include "stream_control.h"
41 #include "interface.h"
42 #include "input_ext-intf.h"
45 #include "InterfaceWindow.h"
47 /*****************************************************************************
48 * intf_sys_t: description and status of FB interface
49 *****************************************************************************/
50 typedef struct intf_sys_s
52 InterfaceWindow * p_window;
60 /*****************************************************************************
62 *****************************************************************************/
63 static int intf_Probe ( probedata_t *p_data );
64 static int intf_Open ( intf_thread_t *p_intf );
65 static void intf_Close ( intf_thread_t *p_intf );
66 static void intf_Run ( intf_thread_t *p_intf );
68 /*****************************************************************************
69 * Functions exported as capabilities. They are declared as static so that
70 * we don't pollute the namespace too much.
71 *****************************************************************************/
72 void _M( intf_getfunctions )( function_list_t * p_function_list )
74 p_function_list->pf_probe = intf_Probe;
75 p_function_list->functions.intf.pf_open = intf_Open;
76 p_function_list->functions.intf.pf_close = intf_Close;
77 p_function_list->functions.intf.pf_run = intf_Run;
80 /*****************************************************************************
81 * intf_Probe: probe the interface and return a score
82 *****************************************************************************
83 * This function tries to initialize Gnome and returns a score to the
84 * plugin manager so that it can select the best plugin.
85 *****************************************************************************/
86 static int intf_Probe( probedata_t *p_data )
91 /*****************************************************************************
92 * intf_Open: initialize interface
93 *****************************************************************************/
94 static int intf_Open( intf_thread_t *p_intf )
97 screen = new BScreen();
98 BRect rect = screen->Frame();
99 rect.top = rect.bottom-100;
102 rect.right = rect.left + 350;
105 /* Allocate instance and initialize some members */
106 p_intf->p_sys = (intf_sys_t*) malloc( sizeof( intf_sys_t ) );
107 if( p_intf->p_sys == NULL )
109 intf_ErrMsg("error: %s", strerror(ENOMEM));
112 p_intf->p_sys->i_key = -1;
114 /* Create the interface window */
115 p_intf->p_sys->p_window =
116 new InterfaceWindow( rect,
117 VOUT_TITLE " (BeOS interface)", p_intf );
118 if( p_intf->p_sys->p_window == 0 )
120 free( p_intf->p_sys );
121 intf_ErrMsg( "error: cannot allocate memory for InterfaceWindow" );
128 /*****************************************************************************
129 * intf_Close: destroy dummy interface
130 *****************************************************************************/
131 static void intf_Close( intf_thread_t *p_intf )
133 /* Destroy the interface window */
134 p_intf->p_sys->p_window->Lock();
135 p_intf->p_sys->p_window->Quit();
137 /* Destroy structure */
138 free( p_intf->p_sys );
142 /*****************************************************************************
143 * intf_Run: event loop
144 *****************************************************************************/
145 static void intf_Run( intf_thread_t *p_intf )
148 while( !p_intf->b_die )
150 /* Manage core vlc functions through the callback */
151 p_intf->pf_manage( p_intf );
153 /* Manage the slider */
154 if( p_input_bank->pp_input[0] != NULL
155 && p_intf->p_sys->p_window != NULL)
157 p_intf->p_sys->p_window->updateInterface();
161 msleep( INTF_IDLE_SLEEP );