]> git.sesse.net Git - vlc/blob - plugins/beos/intf_beos.cpp
* ALL: changed "struct foo_s" into "struct foo_t" to make greppers happy.
[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.42 2002/07/20 18:01:42 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 #include <vlc/vlc.h>
36 #include <vlc/intf.h>
37
38 #include "InterfaceWindow.h"
39
40 /*****************************************************************************
41  * intf_sys_t: description and status of FB interface
42  *****************************************************************************/
43 struct intf_sys_t
44 {
45     InterfaceWindow * p_window;
46     char              i_key;
47 };
48
49
50 extern "C"
51 {
52
53 /*****************************************************************************
54  * Local prototypes.
55  *****************************************************************************/
56 static int  intf_Open      ( intf_thread_t *p_intf );
57 static void intf_Close     ( intf_thread_t *p_intf );
58 static void intf_Run       ( intf_thread_t *p_intf );
59
60 /*****************************************************************************
61  * Functions exported as capabilities. They are declared as static so that
62  * we don't pollute the namespace too much.
63  *****************************************************************************/
64 void _M( intf_getfunctions )( function_list_t * p_function_list )
65 {
66     p_function_list->functions.intf.pf_open  = intf_Open;
67     p_function_list->functions.intf.pf_close = intf_Close;
68     p_function_list->functions.intf.pf_run   = intf_Run;
69 }
70
71 /*****************************************************************************
72  * intf_Open: initialize interface
73  *****************************************************************************/
74 static int intf_Open( intf_thread_t *p_intf )
75 {
76     BScreen *screen;
77     screen = new BScreen();
78     BRect rect = screen->Frame();
79     rect.top = rect.bottom-100;
80     rect.bottom -= 50;
81     rect.left += 50;
82     rect.right = rect.left + 350;
83     delete screen;
84
85     /* Allocate instance and initialize some members */
86     p_intf->p_sys = (intf_sys_t*) malloc( sizeof( intf_sys_t ) );
87     if( p_intf->p_sys == NULL )
88     {
89         msg_Err( p_intf, "out of memory" );
90         return( 1 );
91     }
92     p_intf->p_sys->i_key = -1;
93
94     /* Create the interface window */
95     p_intf->p_sys->p_window =
96         new InterfaceWindow( rect,
97                              VOUT_TITLE " (BeOS interface)", p_intf );
98     if( p_intf->p_sys->p_window == 0 )
99     {
100         free( p_intf->p_sys );
101         msg_Err( p_intf, "cannot allocate InterfaceWindow" );
102         return( 1 );
103     }
104
105     return( 0 );
106 }
107
108 /*****************************************************************************
109  * intf_Close: destroy dummy interface
110  *****************************************************************************/
111 static void intf_Close( intf_thread_t *p_intf )
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         /* Manage the slider */
130         if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL
131              && p_intf->p_sys->p_window != NULL)
132         {
133             p_intf->p_sys->p_window->updateInterface();
134         }
135
136         /* Wait a bit */
137         msleep( INTF_IDLE_SLEEP );
138     }
139 }
140
141 } /* extern "C" */
142