]> git.sesse.net Git - vlc/blobdiff - modules/video_output/msw/wingdi.c
Used VLC_CODEC_* and vlc_fourcc_GetCodec when suitable.
[vlc] / modules / video_output / msw / wingdi.c
index a1448deea9def90ef06bd258f8fd36f6864c0a94..706aded1725d59e795381d183d84c8e4e55f4842 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * wingdi.c : Win32 / WinCE GDI video output plugin for vlc
  *****************************************************************************
- * Copyright (C) 2002 the VideoLAN team
+ * Copyright (C) 2002-2009 the VideoLAN team
  * $Id$
  *
  * Authors: Gildas Bazin <gbazin@videolan.org>
@@ -36,6 +36,8 @@
 #include <vlc_playlist.h>
 #include <vlc_vout.h>
 
+#include <windows.h>
+#include <tchar.h>
 #include <commctrl.h>
 
 /*#ifdef MODULE_NAME_IS_wingapi
@@ -69,7 +71,7 @@
 #       define kfDirect444      0x200
 #       define kfDirectInverted 0x400
 #   endif
-#endif /* MODULE_NAME_IS_wingapi */
+#endif */ /* MODULE_NAME_IS_wingapi */
 
 #include "vout.h"
 
@@ -117,15 +119,7 @@ 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
 
@@ -153,11 +147,9 @@ vlc_module_end ()
 static int OpenVideo ( vlc_object_t *p_this )
 {
     vout_thread_t * p_vout = (vout_thread_t *)p_this;
-    vlc_value_t val;
 
-    p_vout->p_sys = (vout_sys_t *)malloc( sizeof(vout_sys_t) );
+    p_vout->p_sys = (vout_sys_t *)calloc( 1, sizeof(vout_sys_t) );
     if( !p_vout->p_sys ) return VLC_ENOMEM;
-    memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );
 
 #ifdef MODULE_NAME_IS_wingapi
     /* Load GAPI */
@@ -250,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",
-                           EventThread, 0, 1 ) )
+    p_vout->p_sys->p_event->window_ready = CreateEvent( NULL, TRUE, FALSE, NULL );
+    if( vlc_thread_create( p_vout->p_sys->p_event, "Vout Events Thread",
+                           EventThread, 0 ) )
     {
         msg_Err( p_vout, "cannot create Vout EventThread" );
+        CloseHandle( p_vout->p_sys->p_event->window_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->window_ready, INFINITE );
+    CloseHandle( p_vout->p_sys->p_event->window_ready );
 
     if( p_vout->p_sys->p_event->b_error )
     {
@@ -272,15 +268,13 @@ static int OpenVideo ( vlc_object_t *p_this )
 #ifndef UNDER_CE
     /* Variable to indicate if the window should be on top of others */
     /* Trigger a callback right now */
-    var_Get( p_vout, "video-on-top", &val );
-    var_Set( p_vout, "video-on-top", val );
+    var_TriggerCallback( p_vout, "video-on-top" );
 
     /* disable screensaver by temporarily changing system settings */
     p_vout->p_sys->i_spi_lowpowertimeout = 0;
     p_vout->p_sys->i_spi_powerofftimeout = 0;
     p_vout->p_sys->i_spi_screensavetimeout = 0;
-    var_Get( p_vout, "disable-screensaver", &val);
-    if( val.b_bool ) {
+    if( var_GetBool( p_vout, "disable-screensaver" ) ) {
         msg_Dbg(p_vout, "disabling screen saver");
         SystemParametersInfo(SPI_GETLOWPOWERTIMEOUT,
             0, &(p_vout->p_sys->i_spi_lowpowertimeout), 0);
@@ -385,29 +379,29 @@ static int Init( vout_thread_t *p_vout )
     switch( p_vout->p_sys->i_depth )
     {
     case 8:
-        p_vout->output.i_chroma = VLC_FOURCC('R','G','B','2');
+        p_vout->output.i_chroma = VLC_CODEC_RGB8;
         p_vout->output.pf_setpalette = SetPalette;
         break;
     case 15:
-        p_vout->output.i_chroma = VLC_FOURCC('R','V','1','5');
+        p_vout->output.i_chroma = VLC_CODEC_RGB15;
         p_vout->output.i_rmask  = 0x7c00;
         p_vout->output.i_gmask  = 0x03e0;
         p_vout->output.i_bmask  = 0x001f;
         break;
     case 16:
-        p_vout->output.i_chroma = VLC_FOURCC('R','V','1','6');
+        p_vout->output.i_chroma = VLC_CODEC_RGB16;
         p_vout->output.i_rmask  = 0xf800;
         p_vout->output.i_gmask  = 0x07e0;
         p_vout->output.i_bmask  = 0x001f;
         break;
     case 24:
-        p_vout->output.i_chroma = VLC_FOURCC('R','V','2','4');
+        p_vout->output.i_chroma = VLC_CODEC_RGB24;
         p_vout->output.i_rmask  = 0x00ff0000;
         p_vout->output.i_gmask  = 0x0000ff00;
         p_vout->output.i_bmask  = 0x000000ff;
         break;
     case 32:
-        p_vout->output.i_chroma = VLC_FOURCC('R','V','3','2');
+        p_vout->output.i_chroma = VLC_CODEC_RGB32;
         p_vout->output.i_rmask  = 0x00ff0000;
         p_vout->output.i_gmask  = 0x0000ff00;
         p_vout->output.i_bmask  = 0x000000ff;
@@ -526,6 +520,28 @@ static int Manage( vout_thread_t *p_vout )
         vlc_mutex_unlock( &p_vout->p_sys->lock );
     }
 
+    /* autoscale toggle */
+    if( p_vout->i_changes & VOUT_SCALE_CHANGE )
+    {
+        p_vout->i_changes &= ~VOUT_SCALE_CHANGE;
+
+        p_vout->b_autoscale = var_GetBool( p_vout, "autoscale" );
+        p_vout->i_zoom = (int) ZOOM_FP_FACTOR;
+
+        UpdateRects( p_vout, true );
+    }
+
+    /* scaling factor */
+    if( p_vout->i_changes & VOUT_ZOOM_CHANGE )
+    {
+        p_vout->i_changes &= ~VOUT_ZOOM_CHANGE;
+
+        p_vout->b_autoscale = false;
+        p_vout->i_zoom =
+            (int)( ZOOM_FP_FACTOR * var_GetFloat( p_vout, "scale" ) );
+        UpdateRects( p_vout, true );
+    }
+
     /* Check for cropping / aspect changes */
     if( p_vout->i_changes & VOUT_CROP_CHANGE ||
         p_vout->i_changes & VOUT_ASPECT_CHANGE )