]> git.sesse.net Git - vlc/blob - modules/gui/beos/Interface.cpp
Remove _GNU_SOURCE and string.h too
[vlc] / modules / gui / beos / Interface.cpp
1 /*****************************************************************************
2  * intf_beos.cpp: beos interface
3  *****************************************************************************
4  * Copyright (C) 1999, 2000, 2001 the VideoLAN team
5  * $Id$
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  *          Eric Petit <titer@videolan.org>
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
27  *****************************************************************************/
28
29 /*****************************************************************************
30  * Preamble
31  *****************************************************************************/
32 #include <stdio.h>
33 #include <InterfaceKit.h>
34 #include <Application.h>
35 #include <Message.h>
36
37 #include <vlc/vlc.h>
38 #include <vlc_interface.h>
39 #include <vlc_aout.h>
40 #include <aout_internal.h>
41
42 #include "InterfaceWindow.h"
43 #include "MsgVals.h"
44
45 /*****************************************************************************
46  * intf_sys_t: internal variables of the BeOS interface
47  *****************************************************************************/
48 struct intf_sys_t
49 {
50     InterfaceWindow * p_window;
51 };
52
53 /*****************************************************************************
54  * Local prototype
55  *****************************************************************************/
56 static void Run       ( intf_thread_t *p_intf );
57
58 /*****************************************************************************
59  * intf_Open: initialize interface
60  *****************************************************************************/
61 int E_(OpenIntf) ( vlc_object_t *p_this )
62 {
63     intf_thread_t * p_intf = (intf_thread_t*) p_this;
64
65     /* Allocate instance and initialize some members */
66     p_intf->p_sys = (intf_sys_t*) malloc( sizeof( intf_sys_t ) );
67     if( !p_intf->p_sys )
68     {
69         msg_Err( p_intf, "out of memory" );
70         return VLC_EGENERIC;
71     }
72     
73     p_intf->pf_run = Run;
74
75     /* Create the interface window */
76     BScreen screen( B_MAIN_SCREEN_ID );
77     BRect rect   = screen.Frame();
78     rect.top     = rect.bottom - 100;
79     rect.bottom -= 50;
80     rect.left   += 50;
81     rect.right   = rect.left + 350;
82     p_intf->p_sys->p_window =
83         new InterfaceWindow( p_intf, rect, "VLC " VERSION );
84     if( !p_intf->p_sys->p_window )
85     {
86         free( p_intf->p_sys );
87         msg_Err( p_intf, "cannot allocate InterfaceWindow" );
88         return VLC_EGENERIC;
89     }
90
91     /* Make the be_app aware the interface has been created */
92     BMessage message( INTERFACE_CREATED );
93     message.AddPointer( "window", p_intf->p_sys->p_window );
94     be_app->PostMessage( &message );
95
96     return VLC_SUCCESS;
97 }
98
99 /*****************************************************************************
100  * intf_Close: destroy dummy interface
101  *****************************************************************************/
102 void E_(CloseIntf) ( vlc_object_t *p_this )
103 {
104     intf_thread_t *p_intf = (intf_thread_t*) p_this;
105
106     /* Destroy the interface window */
107     if( p_intf->p_sys->p_window->Lock() )
108         p_intf->p_sys->p_window->Quit();
109
110     /* Destroy structure */
111     free( p_intf->p_sys );
112 }
113
114
115 /*****************************************************************************
116  * intf_Run: event loop
117  *****************************************************************************/
118 static void Run( intf_thread_t *p_intf )
119 {
120     while( !intf_ShouldDie( p_intf ) )
121     {
122         p_intf->p_sys->p_window->UpdateInterface();
123         msleep( INTF_IDLE_SLEEP );
124     }
125 }