]> git.sesse.net Git - vlc/blob - plugins/beos/intf_beos.cpp
a4fe28cd6d1c4000606a1ea188f5c3cc838ce4c1
[vlc] / plugins / beos / intf_beos.cpp
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 $
6  *
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>
11  *
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.
16  *
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.
21  *
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  *****************************************************************************/
26
27 /*****************************************************************************
28  * Preamble
29  *****************************************************************************/
30 #include <stdio.h>
31 #include <stdlib.h>                                      /* malloc(), free() */
32 #include <InterfaceKit.h>
33 #include <string.h>
34
35 extern "C"
36 {
37 #include <videolan/vlc.h>
38
39 #include "stream_control.h"
40
41 #include "interface.h"
42 #include "input_ext-intf.h"
43 }
44
45 #include "InterfaceWindow.h"
46
47 /*****************************************************************************
48  * intf_sys_t: description and status of FB interface
49  *****************************************************************************/
50 typedef struct intf_sys_s
51 {
52     InterfaceWindow * p_window;
53     char              i_key;
54 } intf_sys_t;
55
56
57 extern "C"
58 {
59
60 /*****************************************************************************
61  * Local prototypes.
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 );
67
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 )
73 {
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;
78 }
79
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 )
87 {
88     return( 100 );
89 }
90
91 /*****************************************************************************
92  * intf_Open: initialize interface
93  *****************************************************************************/
94 static int intf_Open( intf_thread_t *p_intf )
95 {
96     BScreen *screen;
97     screen = new BScreen();
98     BRect rect = screen->Frame();
99     rect.top = rect.bottom-100;
100     rect.bottom -= 50;
101     rect.left += 50;
102     rect.right = rect.left + 350;
103     delete screen;
104
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 )
108     {
109         intf_ErrMsg("error: %s", strerror(ENOMEM));
110         return( 1 );
111     }
112     p_intf->p_sys->i_key = -1;
113
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 )
119     {
120         free( p_intf->p_sys );
121         intf_ErrMsg( "error: cannot allocate memory for InterfaceWindow" );
122         return( 1 );
123     }
124
125     return( 0 );
126 }
127
128 /*****************************************************************************
129  * intf_Close: destroy dummy interface
130  *****************************************************************************/
131 static void intf_Close( intf_thread_t *p_intf )
132 {
133     /* Destroy the interface window */
134     p_intf->p_sys->p_window->Lock();
135     p_intf->p_sys->p_window->Quit();
136
137     /* Destroy structure */
138     free( p_intf->p_sys );
139 }
140
141
142 /*****************************************************************************
143  * intf_Run: event loop
144  *****************************************************************************/
145 static void intf_Run( intf_thread_t *p_intf )
146 {
147
148     while( !p_intf->b_die )
149     {
150         /* Manage core vlc functions through the callback */
151         p_intf->pf_manage( p_intf );
152
153         /* Manage the slider */
154         if( p_input_bank->pp_input[0] != NULL
155              && p_intf->p_sys->p_window != NULL)
156         {
157             p_intf->p_sys->p_window->updateInterface();
158         }
159
160         /* Wait a bit */
161         msleep( INTF_IDLE_SLEEP );
162     }
163 }
164
165 } /* extern "C" */
166