]> git.sesse.net Git - vlc/blobdiff - modules/gui/beos/Interface.cpp
Removes trailing spaces. Removes tabs.
[vlc] / modules / gui / beos / Interface.cpp
index 06e86b661bcf97ab050c34a4d14dae70faf76974..6da022a32bf7420210df5452cc0795be77b7a947 100644 (file)
@@ -1,14 +1,15 @@
 /*****************************************************************************
  * intf_beos.cpp: beos interface
  *****************************************************************************
- * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: Interface.cpp,v 1.2 2002/09/30 18:30:27 titer Exp $
+ * Copyright (C) 1999, 2000, 2001 the VideoLAN team
+ * $Id$
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
  *          Tony Castley <tony@castley.net>
  *          Richard Shepherd <richard@rshepherd.demon.co.uk>
  *          Stephan Aßmus <stippi@yellowbites.com>
+ *          Eric Petit <titer@videolan.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdio.h>
-#include <stdlib.h>                                      /* malloc(), free() */
 #include <InterfaceKit.h>
 #include <Application.h>
 #include <Message.h>
-#include <string.h>
 
 #include <vlc/vlc.h>
-#include <vlc/intf.h>
+#include <vlc_interface.h>
+#include <vlc_aout.h>
+#include <aout_internal.h>
 
-#include "VlcWrapper.h"
 #include "InterfaceWindow.h"
 #include "MsgVals.h"
 
+/*****************************************************************************
+ * intf_sys_t: internal variables of the BeOS interface
+ *****************************************************************************/
+struct intf_sys_t
+{
+    InterfaceWindow * p_window;
+};
+
 /*****************************************************************************
  * Local prototype
  *****************************************************************************/
@@ -52,48 +59,40 @@ static void Run       ( intf_thread_t *p_intf );
  *****************************************************************************/
 int E_(OpenIntf) ( vlc_object_t *p_this )
 {
-    intf_thread_t *p_intf = (intf_thread_t*) p_this;
-    BScreen *screen;
-    screen = new BScreen();
-    BRect rect = screen->Frame();
-    rect.top = rect.bottom-100;
-    rect.bottom -= 50;
-    rect.left += 50;
-    rect.right = rect.left + 350;
-    delete screen;
+    intf_thread_t * p_intf = (intf_thread_t*) p_this;
 
     /* Allocate instance and initialize some members */
     p_intf->p_sys = (intf_sys_t*) malloc( sizeof( intf_sys_t ) );
-    if( p_intf->p_sys == NULL )
+    if( !p_intf->p_sys )
     {
         msg_Err( p_intf, "out of memory" );
-        return( 1 );
+        return VLC_EGENERIC;
     }
-    
-    p_intf->p_sys->p_input = NULL;
-
     p_intf->pf_run = Run;
 
     /* Create the interface window */
+    BScreen screen( B_MAIN_SCREEN_ID );
+    BRect rect   = screen.Frame();
+    rect.top     = rect.bottom - 100;
+    rect.bottom -= 50;
+    rect.left   += 50;
+    rect.right   = rect.left + 350;
     p_intf->p_sys->p_window =
-        new InterfaceWindow( rect,
-                             VOUT_TITLE " (BeOS interface)", p_intf );
-    if( p_intf->p_sys->p_window == 0 )
+        new InterfaceWindow( p_intf, rect, "VLC " VERSION );
+    if( !p_intf->p_sys->p_window )
     {
         free( p_intf->p_sys );
         msg_Err( p_intf, "cannot allocate InterfaceWindow" );
-        return( 1 );
-    } else {
-       BMessage message(INTERFACE_CREATED);
-       message.AddPointer("window", p_intf->p_sys->p_window);
-       be_app->PostMessage(&message);
+        return VLC_EGENERIC;
     }
-    p_intf->p_sys->b_disabled_menus = 0;
-    p_intf->p_sys->i_saved_volume = AOUT_VOLUME_DEFAULT;
-    p_intf->p_sys->b_loop = 0;
-    p_intf->p_sys->b_mute = 0;
-    
-    return( 0 );
+
+    /* Make the be_app aware the interface has been created */
+    BMessage message( INTERFACE_CREATED );
+    message.AddPointer( "window", p_intf->p_sys->p_window );
+    be_app->PostMessage( &message );
+
+    return VLC_SUCCESS;
 }
 
 /*****************************************************************************
@@ -103,14 +102,9 @@ void E_(CloseIntf) ( vlc_object_t *p_this )
 {
     intf_thread_t *p_intf = (intf_thread_t*) p_this;
 
-    if( p_intf->p_sys->p_input )
-    {
-        vlc_object_release( p_intf->p_sys->p_input );
-    }
-    
     /* Destroy the interface window */
-    p_intf->p_sys->p_window->Lock();
-    p_intf->p_sys->p_window->Quit();
+    if( p_intf->p_sys->p_window->Lock() )
+        p_intf->p_sys->p_window->Quit();
 
     /* Destroy structure */
     free( p_intf->p_sys );
@@ -122,28 +116,9 @@ void E_(CloseIntf) ( vlc_object_t *p_this )
  *****************************************************************************/
 static void Run( intf_thread_t *p_intf )
 {
-    while( !p_intf->b_die )
+    while( !intf_ShouldDie( p_intf ) )
     {
-        /* Update the input */
-        if( p_intf->p_sys->p_input != NULL )
-        {
-            if( p_intf->p_sys->p_input->b_dead )
-            {
-                vlc_object_release( p_intf->p_sys->p_input );
-                p_intf->p_sys->p_input = NULL;
-            }
-        /* Manage the slider */
-            p_intf->p_sys->p_window->updateInterface();
-        }
-    
-        if( p_intf->p_sys->p_input == NULL )
-        {
-            p_intf->p_sys->p_input = 
-                        (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
-                                                          FIND_ANYWHERE );
-        }
-
-        /* Wait a bit */
+        p_intf->p_sys->p_window->UpdateInterface();
         msleep( INTF_IDLE_SLEEP );
     }
 }