]> git.sesse.net Git - vlc/blob - plugins/beos/intf_beos.cpp
5d729a43ca44390199bc4cd5cfec0e6c2d4c7394
[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.43 2002/07/23 12:42:17 tcastley 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 #include <vlc/vlc.h>
36 #include <vlc/intf.h>
37
38 #include "intf_vlc_wrapper.h"
39 #include "InterfaceWindow.h"
40
41 extern "C"
42 {
43
44 /*****************************************************************************
45  * Local prototypes.
46  *****************************************************************************/
47 static int  intf_Open      ( intf_thread_t *p_intf );
48 static void intf_Close     ( intf_thread_t *p_intf );
49 static void intf_Run       ( intf_thread_t *p_intf );
50
51 /*****************************************************************************
52  * Functions exported as capabilities. They are declared as static so that
53  * we don't pollute the namespace too much.
54  *****************************************************************************/
55 void _M( intf_getfunctions )( function_list_t * p_function_list )
56 {
57     p_function_list->functions.intf.pf_open  = intf_Open;
58     p_function_list->functions.intf.pf_close = intf_Close;
59     p_function_list->functions.intf.pf_run   = intf_Run;
60 }
61
62 /*****************************************************************************
63  * intf_Open: initialize interface
64  *****************************************************************************/
65 static int intf_Open( intf_thread_t *p_intf )
66 {
67     BScreen *screen;
68     screen = new BScreen();
69     BRect rect = screen->Frame();
70     rect.top = rect.bottom-100;
71     rect.bottom -= 50;
72     rect.left += 50;
73     rect.right = rect.left + 350;
74     delete screen;
75
76     /* Allocate instance and initialize some members */
77     p_intf->p_sys = (intf_sys_t*) malloc( sizeof( intf_sys_t ) );
78     if( p_intf->p_sys == NULL )
79     {
80         msg_Err( p_intf, "out of memory" );
81         return( 1 );
82     }
83 //    p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
84     p_intf->p_sys->p_input = NULL;
85
86
87     /* Create the interface window */
88     p_intf->p_sys->p_window =
89         new InterfaceWindow( rect,
90                              VOUT_TITLE " (BeOS interface)", p_intf );
91     if( p_intf->p_sys->p_window == 0 )
92     {
93         free( p_intf->p_sys );
94         msg_Err( p_intf, "cannot allocate InterfaceWindow" );
95         return( 1 );
96     }
97
98     return( 0 );
99 }
100
101 /*****************************************************************************
102  * intf_Close: destroy dummy interface
103  *****************************************************************************/
104 static void intf_Close( intf_thread_t *p_intf )
105 {
106     if( p_intf->p_sys->p_input )
107     {
108         vlc_object_release( p_intf->p_sys->p_input );
109     }
110
111 //    msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
112
113     /* Destroy the interface window */
114     p_intf->p_sys->p_window->Lock();
115     p_intf->p_sys->p_window->Quit();
116
117     /* Destroy structure */
118     free( p_intf->p_sys );
119 }
120
121
122 /*****************************************************************************
123  * intf_Run: event loop
124  *****************************************************************************/
125 static void intf_Run( intf_thread_t *p_intf )
126 {
127     while( !p_intf->b_die )
128     {
129         /* Update the input */
130         if( p_intf->p_sys->p_input != NULL )
131         {
132             if( p_intf->p_sys->p_input->b_dead )
133             {
134                 vlc_object_release( p_intf->p_sys->p_input );
135                 p_intf->p_sys->p_input = NULL;
136             }
137         /* Manage the slider */
138             p_intf->p_sys->p_window->updateInterface();
139         }
140     
141         if( p_intf->p_sys->p_input == NULL )
142         {
143             p_intf->p_sys->p_input = 
144                         (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
145                                                           FIND_ANYWHERE );
146         }
147
148
149
150         /* Wait a bit */
151         msleep( INTF_IDLE_SLEEP );
152     }
153     
154 }
155
156 } /* extern "C" */
157