]> git.sesse.net Git - vlc/blob - modules/gui/beos/Interface.cpp
9330575da1d2913b0b04e8ec018a3e3b549008d2
[vlc] / modules / gui / beos / Interface.cpp
1 /*****************************************************************************
2  * intf.cpp: beos interface
3  *****************************************************************************
4  * Copyright (C) 1999, 2000, 2001 VideoLAN
5  * $Id: Interface.cpp,v 1.1 2002/08/04 17:23:43 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 "VlcWrapper.h"
39 #include "InterfaceWindow.h"
40
41 /*****************************************************************************
42  * Local prototype
43  *****************************************************************************/
44 static void Run       ( intf_thread_t *p_intf );
45
46 /*****************************************************************************
47  * OpenIntf: initialize interface
48  *****************************************************************************/
49 int E_(OpenIntf) ( vlc_object_t *p_this )
50 {   
51     intf_thread_t *p_intf = (intf_thread_t*) p_this;     
52     BScreen *screen;
53     screen = new BScreen();
54     BRect rect = screen->Frame();
55     rect.top = rect.bottom-100;
56     rect.bottom -= 50;
57     rect.left += 50;
58     rect.right = rect.left + 350;
59     delete screen;
60
61     /* Allocate instance and initialize some members */
62     p_intf->p_sys = (intf_sys_t*) malloc( sizeof( intf_sys_t ) );
63     if( p_intf->p_sys == NULL )
64     {
65         msg_Err( p_intf, "out of memory" );
66         return( 1 );
67     }
68 //    p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
69     p_intf->p_sys->p_input = NULL;
70
71     p_intf->pf_run = Run;
72
73     /* Create the interface window */
74     p_intf->p_sys->p_window =
75         new InterfaceWindow( rect,
76                              VOUT_TITLE " (BeOS interface)", p_intf );
77     if( p_intf->p_sys->p_window == 0 )
78     {
79         free( p_intf->p_sys );
80         msg_Err( p_intf, "cannot allocate InterfaceWindow" );
81         return( 1 );
82     }
83
84     return( 0 );
85 }
86
87 /*****************************************************************************
88  * CloseIntf: destroy interface
89  *****************************************************************************/
90 void E_(CloseIntf) ( vlc_object_t *p_this )
91 {
92     intf_thread_t *p_intf = (intf_thread_t*) p_this;
93
94     if( p_intf->p_sys->p_input )
95     {
96         vlc_object_release( p_intf->p_sys->p_input );
97     }
98
99 //    msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
100
101     /* Destroy the interface window */
102     p_intf->p_sys->p_window->Lock();
103     p_intf->p_sys->p_window->Quit();
104
105     /* Destroy structure */
106     free( p_intf->p_sys );
107 }
108
109
110 /*****************************************************************************
111  * Run: event loop
112  *****************************************************************************/
113 static void Run( intf_thread_t *p_intf )
114 {
115     while( !p_intf->b_die )
116     {
117         /* Update the input */
118         if( p_intf->p_sys->p_input != NULL )
119         {
120             if( p_intf->p_sys->p_input->b_dead )
121             {
122                 vlc_object_release( p_intf->p_sys->p_input );
123                 p_intf->p_sys->p_input = NULL;
124             }
125         /* Manage the slider */
126             p_intf->p_sys->p_window->updateInterface();
127         }
128     
129         if( p_intf->p_sys->p_input == NULL )
130         {
131             p_intf->p_sys->p_input = 
132                         (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
133                                                           FIND_ANYWHERE );
134         }
135
136
137
138         /* Wait a bit */
139         msleep( INTF_IDLE_SLEEP );
140     }
141     
142 }
143