]> git.sesse.net Git - vlc/blob - modules/gui/beos/Interface.cpp
- Fixes. Most of the interface features now work again.
[vlc] / modules / gui / beos / Interface.cpp
1 /*****************************************************************************
2  * intf_beos.cpp: beos interface
3  *****************************************************************************
4  * Copyright (C) 1999, 2000, 2001 VideoLAN
5  * $Id: Interface.cpp,v 1.4 2002/10/30 06:12:27 titer 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  *          Stephan Aßmus <stippi@yellowbites.com>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
26  *****************************************************************************/
27
28 /*****************************************************************************
29  * Preamble
30  *****************************************************************************/
31 #include <stdio.h>
32 #include <stdlib.h>                                      /* malloc(), free() */
33 #include <InterfaceKit.h>
34 #include <Application.h>
35 #include <Message.h>
36 #include <string.h>
37
38 #include <vlc/vlc.h>
39 #include <vlc/intf.h>
40 #include <vlc/aout.h>
41 #include <aout_internal.h>
42
43 #include "VlcWrapper.h"
44 #include "InterfaceWindow.h"
45 #include "MsgVals.h"
46
47 /*****************************************************************************
48  * Local prototype
49  *****************************************************************************/
50 static void Run       ( intf_thread_t *p_intf );
51
52 /*****************************************************************************
53  * intf_Open: initialize interface
54  *****************************************************************************/
55 int E_(OpenIntf) ( vlc_object_t *p_this )
56 {
57     intf_thread_t *p_intf = (intf_thread_t*) p_this;
58     BScreen *screen;
59     screen = new BScreen();
60     BRect rect = screen->Frame();
61     rect.top = rect.bottom-100;
62     rect.bottom -= 50;
63     rect.left += 50;
64     rect.right = rect.left + 350;
65     delete screen;
66
67     /* Allocate instance and initialize some members */
68     p_intf->p_sys = (intf_sys_t*) malloc( sizeof( intf_sys_t ) );
69     if( p_intf->p_sys == NULL )
70     {
71         msg_Err( p_intf, "out of memory" );
72         return( 1 );
73     }
74     
75     p_intf->p_sys->p_input = NULL;
76     p_intf->p_sys->p_aout = NULL;
77     p_intf->p_sys->p_playlist =
78                 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
79                                                FIND_ANYWHERE );
80     p_intf->p_sys->p_vlc_wrapper = new Intf_VLCWrapper( p_intf );
81
82     p_intf->pf_run = Run;
83
84     /* Create the interface window */
85     p_intf->p_sys->p_window =
86         new InterfaceWindow( rect,
87                              VOUT_TITLE " (BeOS interface)", p_intf );
88     if( p_intf->p_sys->p_window == 0 )
89     {
90         free( p_intf->p_sys );
91         msg_Err( p_intf, "cannot allocate InterfaceWindow" );
92         return( 1 );
93     } else {
94         BMessage message(INTERFACE_CREATED);
95         message.AddPointer("window", p_intf->p_sys->p_window);
96         be_app->PostMessage(&message);
97     }
98     p_intf->p_sys->b_disabled_menus = 0;
99     p_intf->p_sys->i_saved_volume = AOUT_VOLUME_DEFAULT;
100     p_intf->p_sys->b_loop = 0;
101     p_intf->p_sys->b_mute = 0;
102     
103     return( 0 );
104 }
105
106 /*****************************************************************************
107  * intf_Close: destroy dummy interface
108  *****************************************************************************/
109 void E_(CloseIntf) ( vlc_object_t *p_this )
110 {
111     intf_thread_t *p_intf = (intf_thread_t*) p_this;
112
113     if( p_intf->p_sys->p_input )
114     {
115         vlc_object_release( p_intf->p_sys->p_input );
116     }
117     
118     if( p_intf->p_sys->p_playlist )
119     {
120         vlc_object_release( p_intf->p_sys->p_playlist );
121     }
122     
123     if( p_intf->p_sys->p_aout )
124     {
125         vlc_object_release( p_intf->p_sys->p_aout );
126     }
127     
128     /* Destroy the interface window */
129     p_intf->p_sys->p_window->Lock();
130     p_intf->p_sys->p_window->Quit();
131
132     /* Destroy structure */
133     free( p_intf->p_sys );
134 }
135
136
137 /*****************************************************************************
138  * intf_Run: event loop
139  *****************************************************************************/
140 static void Run( intf_thread_t *p_intf )
141 {
142     while( !p_intf->b_die )
143     {
144         if( p_intf->p_sys->p_input == NULL )
145         {
146             p_intf->p_sys->p_input = 
147                 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
148                                                    FIND_ANYWHERE );
149         }
150         if( p_intf->p_sys->p_aout == NULL )
151         {
152             p_intf->p_sys->p_aout =
153                 (aout_instance_t*)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
154                                                    FIND_ANYWHERE );
155         }
156         
157         /* Update the input */
158         if( p_intf->p_sys->p_input != NULL )
159         {
160             if( p_intf->p_sys->p_input->b_dead )
161             {
162                 vlc_object_release( p_intf->p_sys->p_input );
163                 p_intf->p_sys->p_input = NULL;
164                 
165                 if( p_intf->p_sys->p_aout )
166                 {
167                     vlc_object_release( p_intf->p_sys->p_aout );
168                     p_intf->p_sys->p_aout = NULL;
169                 }
170             }
171             /* Manage the slider */
172             p_intf->p_sys->p_window->updateInterface();
173         }
174
175         /* Wait a bit */
176         msleep( INTF_IDLE_SLEEP );
177     }
178 }