]> git.sesse.net Git - vlc/blobdiff - modules/gui/beos/Interface.cpp
* use var_Set/Get "state"/"position"/"rate" instead of old functions.
[vlc] / modules / gui / beos / Interface.cpp
index 90bce24cf33370b4dfd85646c3fef8bea2e35438..4a4f8ae3599d1c8cea9c08edb54f53687401cfea 100644 (file)
@@ -2,7 +2,7 @@
  * intf_beos.cpp: beos interface
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: Interface.cpp,v 1.7 2002/12/09 13:37:38 titer Exp $
+ * $Id: Interface.cpp,v 1.16 2004/01/26 16:52:31 zorglub Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -55,15 +55,7 @@ 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 ) );
@@ -73,25 +65,34 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
         return( 1 );
     }
     
+    p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
     p_intf->p_sys->p_wrapper = new VlcWrapper( p_intf );
-
     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 );
+                             "VLC " PACKAGE_VERSION,
+                             p_intf );
     if( p_intf->p_sys->p_window == 0 )
     {
         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);
     }
-    p_intf->p_sys->i_saved_volume = AOUT_VOLUME_DEFAULT;
+    else
+    {
+        /* 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);
+    }
     p_intf->p_sys->b_loop = 0;
     p_intf->p_sys->b_mute = 0;
     
@@ -105,9 +106,11 @@ void E_(CloseIntf) ( vlc_object_t *p_this )
 {
     intf_thread_t *p_intf = (intf_thread_t*) p_this;
 
+    msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
+
     /* 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 */
     delete p_intf->p_sys->p_wrapper;
@@ -122,11 +125,11 @@ static void Run( intf_thread_t *p_intf )
 {
     while( !p_intf->b_die )
     {
-        if( p_intf->p_sys->p_wrapper->UpdateInputAndAOut() )
-        {
-            /* Manage the slider */
-            p_intf->p_sys->p_window->updateInterface();
-        }
+        /* Update VlcWrapper internals (p_input, etc) */
+        p_intf->p_sys->p_wrapper->UpdateInput();
+
+        /* Manage the slider */
+        p_intf->p_sys->p_window->UpdateInterface();
 
         /* Wait a bit */
         msleep( INTF_IDLE_SLEEP );