]> git.sesse.net Git - vlc/blobdiff - modules/video_output/msw/events.c
Use pl_Release with the right argument.
[vlc] / modules / video_output / msw / events.c
index d2769ae7f02208cc2501c371f09a308831012422..60af482f5f9ecbb316253ac027b20855a3d7a4aa 100644 (file)
@@ -37,7 +37,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_interface.h>
 #include <vlc_playlist.h>
 #include <vlc_vout.h>
@@ -75,17 +75,11 @@ static long FAR PASCAL DirectXEventProc( HWND, UINT, WPARAM, LPARAM );
 
 static int Control( vout_thread_t *p_vout, int i_query, va_list args );
 
-static void DirectXPopupMenu( event_thread_t *p_event, vlc_bool_t b_open )
+static void DirectXPopupMenu( event_thread_t *p_event, bool b_open )
 {
-    playlist_t *p_playlist =
-        vlc_object_find( p_event, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-    if( p_playlist != NULL )
-    {
-        vlc_value_t val;
-        val.b_bool = b_open;
-        var_Set( p_playlist, "intf-popupmenu", val );
-        vlc_object_release( p_playlist );
-    }
+    vlc_value_t val;
+    val.b_bool = b_open;
+    var_Set( p_event->p_libvlc, "intf-popupmenu", val );
 }
 
 static int DirectXConvertKey( int i_key );
@@ -98,7 +92,7 @@ static int DirectXConvertKey( int i_key );
  * The main goal of this thread is to isolate the Win32 PeekMessage function
  * because this one can block for a long time.
  *****************************************************************************/
-void E_(EventThread)( event_thread_t *p_event )
+void EventThread( event_thread_t *p_event )
 {
     MSG msg;
     POINT old_mouse_pos = {0,0}, mouse_pos;
@@ -113,10 +107,7 @@ void E_(EventThread)( event_thread_t *p_event )
     /* Creating a window under Windows also initializes the thread's event
      * message queue */
     if( DirectXCreateWindow( p_event->p_vout ) )
-    {
-        msg_Err( p_event, "out of memory" );
-        p_event->b_dead = VLC_TRUE;
-    }
+        p_event->b_dead = true;
 
     /* Signal the creation of the window */
     vlc_thread_ready( p_event );
@@ -140,10 +131,10 @@ void E_(EventThread)( event_thread_t *p_event )
 
     /* Main loop */
     /* GetMessage will sleep if there's no message in the queue */
-    while( !p_event->b_die && GetMessage( &msg, 0, 0, 0 ) )
+    while( vlc_object_alive (p_event) && GetMessage( &msg, 0, 0, 0 ) )
     {
         /* Check if we are asked to exit */
-        if( p_event->b_die )
+        if( !vlc_object_alive (p_event) )
             break;
 
         switch( msg.message )
@@ -172,7 +163,7 @@ void E_(EventThread)( event_thread_t *p_event )
                     p_event->p_vout->fmt_in.i_y_offset;
                 var_Set( p_event->p_vout, "mouse-y", val );
 
-                val.b_bool = VLC_TRUE;
+                val.b_bool = true;
                 var_Set( p_event->p_vout, "mouse-moved", val );
             }
 
@@ -194,14 +185,14 @@ void E_(EventThread)( event_thread_t *p_event )
 
         case WM_VLC_HIDE_MOUSE:
             if( p_event->p_vout->p_sys->b_cursor_hidden ) break;
-            p_event->p_vout->p_sys->b_cursor_hidden = VLC_TRUE;
+            p_event->p_vout->p_sys->b_cursor_hidden = true;
             GetCursorPos( &old_mouse_pos );
             ShowCursor( FALSE );
             break;
 
         case WM_VLC_SHOW_MOUSE:
             if( !p_event->p_vout->p_sys->b_cursor_hidden ) break;
-            p_event->p_vout->p_sys->b_cursor_hidden = VLC_FALSE;
+            p_event->p_vout->p_sys->b_cursor_hidden = false;
             GetCursorPos( &old_mouse_pos );
             ShowCursor( TRUE );
             break;
@@ -210,7 +201,7 @@ void E_(EventThread)( event_thread_t *p_event )
             var_Get( p_event->p_vout, "mouse-button-down", &val );
             val.i_int |= 1;
             var_Set( p_event->p_vout, "mouse-button-down", val );
-            DirectXPopupMenu( p_event, VLC_FALSE );
+            DirectXPopupMenu( p_event, false );
             break;
 
         case WM_LBUTTONUP:
@@ -218,7 +209,7 @@ void E_(EventThread)( event_thread_t *p_event )
             val.i_int &= ~1;
             var_Set( p_event->p_vout, "mouse-button-down", val );
 
-            val.b_bool = VLC_TRUE;
+            val.b_bool = true;
             var_Set( p_event->p_vout, "mouse-clicked", val );
             break;
 
@@ -230,7 +221,7 @@ void E_(EventThread)( event_thread_t *p_event )
             var_Get( p_event->p_vout, "mouse-button-down", &val );
             val.i_int |= 2;
             var_Set( p_event->p_vout, "mouse-button-down", val );
-            DirectXPopupMenu( p_event, VLC_FALSE );
+            DirectXPopupMenu( p_event, false );
             break;
 
         case WM_MBUTTONUP:
@@ -243,14 +234,14 @@ void E_(EventThread)( event_thread_t *p_event )
             var_Get( p_event->p_vout, "mouse-button-down", &val );
             val.i_int |= 4;
             var_Set( p_event->p_vout, "mouse-button-down", val );
-            DirectXPopupMenu( p_event, VLC_FALSE );
+            DirectXPopupMenu( p_event, false );
             break;
 
         case WM_RBUTTONUP:
             var_Get( p_event->p_vout, "mouse-button-down", &val );
             val.i_int &= ~4;
             var_Set( p_event->p_vout, "mouse-button-down", val );
-            DirectXPopupMenu( p_event, VLC_TRUE );
+            DirectXPopupMenu( p_event, true );
             break;
 
         case WM_KEYDOWN:
@@ -343,9 +334,12 @@ void E_(EventThread)( event_thread_t *p_event )
 #ifdef UNICODE
             {
                 wchar_t *psz_title = malloc( strlen(val.psz_string) * 2 + 2 );
-                mbstowcs( psz_title, val.psz_string, strlen(val.psz_string)*2);
-                psz_title[strlen(val.psz_string)] = 0;
-                free( val.psz_string ); val.psz_string = (char *)psz_title;
+                if( psz_title )
+                {
+                    mbstowcs( psz_title, val.psz_string, strlen(val.psz_string)*2);
+                    psz_title[strlen(val.psz_string)] = 0;
+                    free( val.psz_string ); val.psz_string = (char *)psz_title;
+                }
             }
 #endif
 
@@ -608,7 +602,7 @@ static void DirectXCloseWindow( vout_thread_t *p_vout )
  * its job is to update the source and destination RECTs used to display the
  * picture.
  *****************************************************************************/
-void E_(UpdateRects)( vout_thread_t *p_vout, vlc_bool_t b_force )
+void UpdateRects( vout_thread_t *p_vout, bool b_force )
 {
 #define rect_src p_vout->p_sys->rect_src
 #define rect_src_clipped p_vout->p_sys->rect_src_clipped
@@ -861,22 +855,18 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
     {
 
     case WM_WINDOWPOSCHANGED:
-        E_(UpdateRects)( p_vout, VLC_TRUE );
+        UpdateRects( p_vout, true );
         return 0;
 
     /* the user wants to close the window */
     case WM_CLOSE:
     {
-        playlist_t * p_playlist =
-            (playlist_t *)vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST,
-                                           FIND_ANYWHERE );
-        if( p_playlist == NULL )
+        playlist_t * p_playlist = pl_Yield( p_vout );
+        if( p_playlist )
         {
-            return 0;
+            playlist_Stop( p_playlist );
+            pl_Release( p_vout );
         }
-
-        playlist_Stop( p_playlist );
-        vlc_object_release( p_playlist );
         return 0;
     }
 
@@ -911,7 +901,7 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
 
     case WM_KILLFOCUS:
 #ifdef MODULE_NAME_IS_wingapi
-        p_vout->p_sys->b_focus = VLC_FALSE;
+        p_vout->p_sys->b_focus = false;
         if( !p_vout->p_sys->b_parent_focus ) GXSuspend();
 #endif
 #ifdef UNDER_CE
@@ -931,7 +921,7 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
 
     case WM_SETFOCUS:
 #ifdef MODULE_NAME_IS_wingapi
-        p_vout->p_sys->b_focus = VLC_TRUE;
+        p_vout->p_sys->b_focus = true;
         GXResume();
 #endif
 #ifdef UNDER_CE
@@ -1124,7 +1114,7 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
             return vout_ControlWindow( p_vout,
                     (void *)p_vout->p_sys->hparent, i_query, args );
 
-        p_vout->p_sys->b_on_top_change = VLC_TRUE;
+        p_vout->p_sys->b_on_top_change = true;
         return VLC_SUCCESS;
 
 #ifdef MODULE_NAME_IS_wingapi
@@ -1231,22 +1221,14 @@ void Win32ToggleFullscreen( vout_thread_t *p_vout )
             ShowWindow( topLevelParent, SW_SHOW );
             SetForegroundWindow( p_vout->p_sys->hparent );
             ShowWindow( hwnd, SW_HIDE );
-
-            /* Update "video-on-top" status for main interface window, it
-            needs to be updated as we were hiding VOUT_SET_STAY_ON_TOP
-            queries from it while we were in fullscreen mode */
-            int b_ontop = var_GetBool( p_vout, "video-on-top" );
-            ControlParentWindow( p_vout, VOUT_SET_STAY_ON_TOP, b_ontop );
         }
 
         /* Make sure the mouse cursor is displayed */
         PostMessage( p_vout->p_sys->hwnd, WM_VLC_SHOW_MOUSE, 0, 0 );
     }
 
-    {
-        vlc_value_t val;
-        /* Update the object variable and trigger callback */
-        val.b_bool = p_vout->b_fullscreen;
-        var_Set( p_vout, "fullscreen", val );
-    }
+    vlc_value_t val;
+    /* Update the object variable and trigger callback */
+    val.b_bool = p_vout->b_fullscreen;
+    var_Set( p_vout, "fullscreen", val );
 }