]> git.sesse.net Git - vlc/blob - plugins/beos/intf_beos.cpp
b1d0ca78a3a380db46e8629b0ad5237b15ddd004
[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.38 2002/02/15 13:32:52 sam 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_Open      ( intf_thread_t *p_intf );
64 static void intf_Close     ( intf_thread_t *p_intf );
65 static void intf_Run       ( intf_thread_t *p_intf );
66
67 /*****************************************************************************
68  * Functions exported as capabilities. They are declared as static so that
69  * we don't pollute the namespace too much.
70  *****************************************************************************/
71 void _M( intf_getfunctions )( function_list_t * p_function_list )
72 {
73     p_function_list->functions.intf.pf_open  = intf_Open;
74     p_function_list->functions.intf.pf_close = intf_Close;
75     p_function_list->functions.intf.pf_run   = intf_Run;
76 }
77
78 /*****************************************************************************
79  * intf_Open: initialize interface
80  *****************************************************************************/
81 static int intf_Open( intf_thread_t *p_intf )
82 {
83     BScreen *screen;
84     screen = new BScreen();
85     BRect rect = screen->Frame();
86     rect.top = rect.bottom-100;
87     rect.bottom -= 50;
88     rect.left += 50;
89     rect.right = rect.left + 350;
90     delete screen;
91
92     /* Allocate instance and initialize some members */
93     p_intf->p_sys = (intf_sys_t*) malloc( sizeof( intf_sys_t ) );
94     if( p_intf->p_sys == NULL )
95     {
96         intf_ErrMsg("error: %s", strerror(ENOMEM));
97         return( 1 );
98     }
99     p_intf->p_sys->i_key = -1;
100
101     /* Create the interface window */
102     p_intf->p_sys->p_window =
103         new InterfaceWindow( rect,
104                              VOUT_TITLE " (BeOS interface)", p_intf );
105     if( p_intf->p_sys->p_window == 0 )
106     {
107         free( p_intf->p_sys );
108         intf_ErrMsg( "error: cannot allocate memory for InterfaceWindow" );
109         return( 1 );
110     }
111
112     return( 0 );
113 }
114
115 /*****************************************************************************
116  * intf_Close: destroy dummy interface
117  *****************************************************************************/
118 static void intf_Close( intf_thread_t *p_intf )
119 {
120     /* Destroy the interface window */
121     p_intf->p_sys->p_window->Lock();
122     p_intf->p_sys->p_window->Quit();
123
124     /* Destroy structure */
125     free( p_intf->p_sys );
126 }
127
128
129 /*****************************************************************************
130  * intf_Run: event loop
131  *****************************************************************************/
132 static void intf_Run( intf_thread_t *p_intf )
133 {
134
135     while( !p_intf->b_die )
136     {
137         /* Manage core vlc functions through the callback */
138         p_intf->pf_manage( p_intf );
139
140         /* Manage the slider */
141         if( p_input_bank->pp_input[0] != NULL
142              && p_intf->p_sys->p_window != NULL)
143         {
144             p_intf->p_sys->p_window->updateInterface();
145         }
146
147         /* Wait a bit */
148         msleep( INTF_IDLE_SLEEP );
149     }
150 }
151
152 } /* extern "C" */
153