]> git.sesse.net Git - vlc/blobdiff - modules/video_output/msw/wingdi.c
Win32: get rid of vlc_thread_ready()
[vlc] / modules / video_output / msw / wingdi.c
old mode 100755 (executable)
new mode 100644 (file)
index 70aaa21..190fd90
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_interface.h>
 #include <vlc_playlist.h>
 #include <vlc_vout.h>
 
 #include <commctrl.h>
 
-#include "vout.h"
-
-#ifdef MODULE_NAME_IS_wingapi
+/*#ifdef MODULE_NAME_IS_wingapi
     typedef struct GXDisplayProperties {
         DWORD cxWidth;
         DWORD cyHeight;
@@ -72,6 +71,8 @@
 #   endif
 #endif /* MODULE_NAME_IS_wingapi */
 
+#include "vout.h"
+
 #define MAX_DIRECTBUFFERS 10
 
 #ifdef UNDER_CE
@@ -84,9 +85,9 @@
 #ifndef WS_EX_APPWINDOW
 #define WS_EX_APPWINDOW 0x40000
 #endif
-#define SetWindowLongPtr SetWindowLong
-#define GetWindowLongPtr GetWindowLong
-#define GWLP_USERDATA GWL_USERDATA
+//#define SetWindowLongPtr SetWindowLong
+//#define GetWindowLongPtr GetWindowLong
+//#define GWLP_USERDATA GWL_USERDATA
 #define AdjustWindowRect(a,b,c)
 #endif //UNDER_CE
 
@@ -116,35 +117,27 @@ static void SetPalette( vout_thread_t *, uint16_t *, uint16_t *, uint16_t * );
 
 static void InitBuffers        ( vout_thread_t * );
 
-#ifdef MODULE_NAME_IS_wingapi
-#   define GXOpenDisplay p_vout->p_sys->GXOpenDisplay
-#   define GXCloseDisplay p_vout->p_sys->GXCloseDisplay
-#   define GXBeginDraw p_vout->p_sys->GXBeginDraw
-#   define GXEndDraw p_vout->p_sys->GXEndDraw
-#   define GXGetDisplayProperties p_vout->p_sys->GXGetDisplayProperties
-#   define GXSuspend p_vout->p_sys->GXSuspend
-#   define GXResume p_vout->p_sys->GXResume
-#endif
+
 
 #define DX_POSITION_CHANGE 0x1000
 
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-vlc_module_begin();
-    set_category( CAT_VIDEO );
-    set_subcategory( SUBCAT_VIDEO_VOUT );
+vlc_module_begin ()
+    set_category( CAT_VIDEO )
+    set_subcategory( SUBCAT_VIDEO_VOUT )
 #ifdef MODULE_NAME_IS_wingapi
-    set_shortname( "Windows GAPI" );
-    set_description( _("Windows GAPI video output") );
-    set_capability( "video output", 20 );
+    set_shortname( "Windows GAPI" )
+    set_description( N_("Windows GAPI video output") )
+    set_capability( "video output", 20 )
 #else
-    set_shortname( "Windows GDI" );
-    set_description( _("Windows GDI video output") );
-    set_capability( "video output", 10 );
+    set_shortname( "Windows GDI" )
+    set_description( N_("Windows GDI video output") )
+    set_capability( "video output", 10 )
 #endif
-    set_callbacks( OpenVideo, CloseVideo );
-vlc_module_end();
+    set_callbacks( OpenVideo, CloseVideo )
+vlc_module_end ()
 
 /*****************************************************************************
  * OpenVideo: activate GDI video thread output method
@@ -198,7 +191,7 @@ static int OpenVideo ( vlc_object_t *p_this )
 #endif
 
     p_vout->p_sys->p_event = (vlc_object_t *)
-        vlc_object_create( p_vout, VLC_OBJECT_GENERIC );
+        vlc_object_create( p_vout, sizeof( vlc_object_t ) );
     if( !p_vout->p_sys->p_event )
     {
         free( p_vout->p_sys );
@@ -222,7 +215,7 @@ static int OpenVideo ( vlc_object_t *p_this )
     p_vout->p_sys->hwnd = p_vout->p_sys->hvideownd = NULL;
     p_vout->p_sys->hparent = p_vout->p_sys->hfswnd = NULL;
     p_vout->p_sys->i_changes = 0;
-    vlc_mutex_init( p_vout, &p_vout->p_sys->lock );
+    vlc_mutex_init( &p_vout->p_sys->lock );
     SetRectEmpty( &p_vout->p_sys->rect_display );
     SetRectEmpty( &p_vout->p_sys->rect_parent );
 
@@ -249,14 +242,18 @@ static int OpenVideo ( vlc_object_t *p_this )
     p_vout->p_sys->p_event =
         vlc_object_create( p_vout, sizeof(event_thread_t) );
     p_vout->p_sys->p_event->p_vout = p_vout;
-    if( vlc_thread_create( p_vout->p_sys->p_event, "VLC Vout Events Thread",
-                           E_(EventThread), 0, 1 ) )
+    p_vout->p_sys->p_event->ready = CreateEvent( NULL, TRUE, FALSE, NULL );
+    if( vlc_thread_create( p_vout->p_sys->p_event, "Vout Events Thread",
+                           EventThread, 0, false ) )
     {
         msg_Err( p_vout, "cannot create Vout EventThread" );
+        CloseHandle( p_vout->p_sys->p_event->ready );
         vlc_object_release( p_vout->p_sys->p_event );
         p_vout->p_sys->p_event = NULL;
         goto error;
     }
+    WaitForSingleObject( p_vout->p_sys->p_event->ready, INFINITE )
+    CloseHandle( p_vout->p_sys->p_event->ready );
 
     if( p_vout->p_sys->p_event->b_error )
     {
@@ -312,6 +309,14 @@ static void CloseVideo ( vlc_object_t *p_this )
 {
     vout_thread_t * p_vout = (vout_thread_t *)p_this;
 
+    if( p_vout->b_fullscreen )
+    {
+        msg_Dbg( p_vout, "Quitting fullscreen" );
+        Win32ToggleFullscreen( p_vout );
+        /* Force fullscreen in the core for the next video */
+        var_SetBool( p_vout, "fullscreen", true );
+    }
+
     if( p_vout->p_sys->p_event )
     {
         vlc_object_detach( p_vout->p_sys->p_event );
@@ -351,11 +356,8 @@ static void CloseVideo ( vlc_object_t *p_this )
     FreeLibrary( p_vout->p_sys->gapi_dll );
 #endif
 
-    if( p_vout->p_sys )
-    {
-        free( p_vout->p_sys );
-        p_vout->p_sys = NULL;
-    }
+    free( p_vout->p_sys );
+    p_vout->p_sys = NULL;
 }
 
 /*****************************************************************************
@@ -451,7 +453,7 @@ static int Init( vout_thread_t *p_vout )
 
     /* Change the window title bar text */
     PostMessage( p_vout->p_sys->hwnd, WM_VLC_CHANGE_TEXT, 0, 0 );
-    E_(UpdateRects)( p_vout, true );
+    UpdateRects( p_vout, true );
 
     return VLC_SUCCESS;
 }
@@ -535,7 +537,7 @@ static int Manage( vout_thread_t *p_vout )
         p_vout->fmt_out.i_sar_num = p_vout->fmt_in.i_sar_num;
         p_vout->fmt_out.i_sar_den = p_vout->fmt_in.i_sar_den;
         p_vout->output.i_aspect = p_vout->fmt_in.i_aspect;
-        E_(UpdateRects)( p_vout, true );
+        UpdateRects( p_vout, true );
     }
 
     /*
@@ -620,7 +622,7 @@ static int Manage( vout_thread_t *p_vout )
     }
 
     /* Check if the event thread is still running */
-    if( p_vout->p_sys->p_event->b_die )
+    if( !vlc_object_alive (p_vout->p_sys->p_event) )
     {
         return VLC_EGENERIC; /* exit */
     }
@@ -634,6 +636,8 @@ static int Manage( vout_thread_t *p_vout )
 static void Render( vout_thread_t *p_vout, picture_t *p_pic )
 {
     /* No need to do anything, the fake direct buffers stay as they are */
+    (void)p_vout;
+    (void)p_pic;
 }
 
 /*****************************************************************************
@@ -836,7 +840,6 @@ static void InitBuffers( vout_thread_t *p_vout )
 {
     BITMAPINFOHEADER *p_header = &p_vout->p_sys->bitmapinfo.bmiHeader;
     BITMAPINFO *p_info = &p_vout->p_sys->bitmapinfo;
-    int i_pixels = p_vout->render.i_height * p_vout->render.i_width;
     HDC window_dc = GetDC( p_vout->p_sys->hvideownd );
 
     /* Get screen properties */