]> git.sesse.net Git - vlc/blobdiff - modules/video_output/msw/directx.c
Add a bunch of help strings. Feel free to correct them, and add more
[vlc] / modules / video_output / msw / directx.c
index e2232468f3707839c6ebff5eda6358a250ffd766..be246c9e8c7d913f496b9dbc9d37661738764877 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
- * vout.c: Windows DirectX video output display method
+ * directx.c: Windows DirectDraw video output
  *****************************************************************************
- * Copyright (C) 2001-2004 the VideoLAN team
+ * Copyright (C) 2001-2009 the VideoLAN team
  * $Id$
  *
  * Authors: Gildas Bazin <gbazin@videolan.org>
  * display video in window mode.
  *
  *****************************************************************************/
-#include <errno.h>                                                 /* ENOMEM */
-
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
-#include <vlc_interface.h>
-#include <vlc_playlist.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_vout.h>
+#include <vlc_playlist.h>   /* needed for wallpaper */
 
-#include <windows.h>
 #include <ddraw.h>
-#include <commctrl.h>
+#include <commctrl.h>       /* ListView_(Get|Set)* */
 
 #ifndef UNDER_CE
 #   include <multimon.h>
@@ -97,9 +94,9 @@ static void Display   ( vout_thread_t *, picture_t * );
 static void FirstDisplay( vout_thread_t *, picture_t * );
 static void SetPalette( vout_thread_t *, uint16_t *, uint16_t *, uint16_t * );
 
-static int  NewPictureVec  ( vout_thread_t *, picture_t *, int );
+static int  NewPictureVec  ( vout_thread_t *, picture_t * );
 static void FreePictureVec ( vout_thread_t *, picture_t *, int );
-static int  UpdatePictureStruct( vout_thread_t *, picture_t *, int );
+static int  UpdatePictureStruct( vout_thread_t *, picture_t * );
 
 static int  DirectXInitDDraw      ( vout_thread_t *p_vout );
 static void DirectXCloseDDraw     ( vout_thread_t *p_vout );
@@ -116,7 +113,7 @@ static int  DirectXUnlockSurface  ( vout_thread_t *p_vout, picture_t *p_pic );
 
 static DWORD DirectXFindColorkey( vout_thread_t *p_vout, uint32_t *i_color );
 
-void SwitchWallpaperMode( vout_thread_t *, vlc_bool_t );
+void SwitchWallpaperMode( vout_thread_t *, bool );
 
 /* Object variables callbacks */
 static int FindDevicesCallback( vlc_object_t *, char const *,
@@ -124,6 +121,14 @@ static int FindDevicesCallback( vlc_object_t *, char const *,
 static int WallpaperCallback( vlc_object_t *, char const *,
                               vlc_value_t, vlc_value_t, void * );
 
+BOOL WINAPI DirectXEnumCallback( GUID* p_guid, LPTSTR psz_desc,
+                                 LPTSTR psz_drivername, VOID* p_context,
+                                 HMONITOR hmon );
+                                 
+BOOL WINAPI DirectXEnumCallback2( GUID* p_guid, LPTSTR psz_desc,
+                                  LPTSTR psz_drivername, VOID* p_context,
+                                  HMONITOR hmon );
+                                  
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -150,42 +155,37 @@ static int WallpaperCallback( vlc_object_t *, char const *,
     "window to open on. For example, \"\\\\.\\DISPLAY1\" or " \
     "\"\\\\.\\DISPLAY2\"." )
 
-#define WALLPAPER_TEXT N_("Enable wallpaper mode ")
-#define WALLPAPER_LONGTEXT N_( \
-    "The wallpaper mode allows you to display the video as the desktop " \
-    "background. Note that this feature only works in overlay mode and " \
-    "the desktop must not already have a wallpaper." )
-
-static char *ppsz_dev[] = { "" };
-static char *ppsz_dev_text[] = { N_("Default") };
-
-vlc_module_begin();
-    set_shortname( "DirectX" );
-    set_category( CAT_VIDEO );
-    set_subcategory( SUBCAT_VIDEO_VOUT );
-    add_bool( "directx-hw-yuv", 1, NULL, HW_YUV_TEXT, HW_YUV_LONGTEXT,
-              VLC_TRUE );
-    add_bool( "directx-use-sysmem", 0, NULL, SYSMEM_TEXT, SYSMEM_LONGTEXT,
-              VLC_TRUE );
-    add_bool( "directx-3buffering", 1, NULL, TRIPLEBUF_TEXT,
-              TRIPLEBUF_LONGTEXT, VLC_TRUE );
+#define DX_HELP N_("Recommended video output for Windows XP. " \
+    "Incompatible with Vista's Aero interface" )
+
+static const char *const ppsz_dev[] = { "" };
+static const char *const ppsz_dev_text[] = { N_("Default") };
+
+vlc_module_begin ()
+    set_shortname( "DirectX" )
+    set_description( N_("DirectX (DirectDraw) video output") )
+    set_help(DX_HELP)
+    set_category( CAT_VIDEO )
+    set_subcategory( SUBCAT_VIDEO_VOUT )
+    add_bool( "directx-hw-yuv", true, NULL, HW_YUV_TEXT, HW_YUV_LONGTEXT,
+              true )
+    add_bool( "directx-use-sysmem", false, NULL, SYSMEM_TEXT, SYSMEM_LONGTEXT,
+              true )
+    add_bool( "directx-3buffering", true, NULL, TRIPLEBUF_TEXT,
+              TRIPLEBUF_LONGTEXT, true )
 
     add_string( "directx-device", "", NULL, DEVICE_TEXT, DEVICE_LONGTEXT,
-                VLC_TRUE );
-        change_string_list( ppsz_dev, ppsz_dev_text, FindDevicesCallback );
-        change_action_add( FindDevicesCallback, N_("Refresh list") );
-
-    add_bool( "directx-wallpaper", 0, NULL, WALLPAPER_TEXT, WALLPAPER_LONGTEXT,
-              VLC_TRUE );
+                true )
+        change_string_list( ppsz_dev, ppsz_dev_text, FindDevicesCallback )
+        change_action_add( FindDevicesCallback, N_("Refresh list") )
 
-    set_description( _("DirectX video output") );
-    set_capability( "video output", 100 );
-    add_shortcut( "directx" );
-    set_callbacks( OpenVideo, CloseVideo );
+    set_capability( "video output", 100 )
+    add_shortcut( "directx" )
+    set_callbacks( OpenVideo, CloseVideo )
 
     /* FIXME: Hack to avoid unregistering our window class */
-    linked_with_a_crap_library_which_uses_atexit( );
-vlc_module_end();
+    linked_with_a_crap_library_which_uses_atexit ()
+vlc_module_end ()
 
 #if 0 /* FIXME */
     /* check if we registered a window class because we need to
@@ -207,13 +207,10 @@ static int OpenVideo( vlc_object_t *p_this )
     HMODULE huser32;
 
     /* Allocate structure */
-    p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
+    p_vout->p_sys = calloc( 1, sizeof( vout_sys_t ) );
     if( p_vout->p_sys == NULL )
-    {
-        msg_Err( p_vout, "out of memory" );
         return VLC_ENOMEM;
-    }
-    memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );
+    vlc_mutex_init( &p_vout->p_sys->lock );
 
     /* Initialisations */
     p_vout->pf_init = Init;
@@ -221,18 +218,17 @@ static int OpenVideo( vlc_object_t *p_this )
     p_vout->pf_manage = Manage;
     p_vout->pf_render = NULL;
     p_vout->pf_display = FirstDisplay;
+    p_vout->pf_control = Control;
 
+    if( CommonInit( p_vout ) )
+        goto error;
+
+    /* */
     p_vout->p_sys->p_ddobject = NULL;
     p_vout->p_sys->p_display = NULL;
     p_vout->p_sys->p_current_surface = NULL;
     p_vout->p_sys->p_clipper = NULL;
-    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;
     p_vout->p_sys->b_wallpaper = 0;
-    vlc_mutex_init( p_vout, &p_vout->p_sys->lock );
-    SetRectEmpty( &p_vout->p_sys->rect_display );
-    SetRectEmpty( &p_vout->p_sys->rect_parent );
 
     /* Multimonitor stuff */
     p_vout->p_sys->hmonitor = NULL;
@@ -244,11 +240,7 @@ static int OpenVideo( vlc_object_t *p_this )
         p_vout->p_sys->MonitorFromWindow = (HMONITOR (WINAPI *)( HWND, DWORD ))
             GetProcAddress( huser32, _T("MonitorFromWindow") );
         p_vout->p_sys->GetMonitorInfo =
-#ifndef UNICODE
-            GetProcAddress( huser32, "GetMonitorInfoA" );
-#else
             GetProcAddress( huser32, _T("GetMonitorInfoW") );
-#endif
     }
 
     var_Create( p_vout, "overlay", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
@@ -256,45 +248,6 @@ static int OpenVideo( vlc_object_t *p_this )
     var_Create( p_vout, "directx-hw-yuv", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
     var_Create( p_vout, "directx-3buffering", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
     var_Create( p_vout, "directx-device", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
-    var_Create( p_vout, "video-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
-    var_Create( p_vout, "disable-screensaver", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
-
-    p_vout->p_sys->b_cursor_hidden = 0;
-    p_vout->p_sys->i_lastmoved = mdate();
-
-    /* Set main window's size */
-    p_vout->p_sys->i_window_width = p_vout->i_window_width;
-    p_vout->p_sys->i_window_height = p_vout->i_window_height;
-
-    /* Create the Vout EventThread, this thread is created by us to isolate
-     * the Win32 PeekMessage function calls. We want to do this because
-     * Windows can stay blocked inside this call for a long time, and when
-     * this happens it thus blocks vlc's video_output thread.
-     * DirectXEventThread will take care of the creation of the video
-     * window (because PeekMessage has to be called from the same thread which
-     * created the window). */
-    msg_Dbg( p_vout, "creating DirectXEventThread" );
-    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, "Vout Events Thread",
-                           E_(EventThread), 0, 1 ) )
-    {
-        msg_Err( p_vout, "cannot create Vout EventThread" );
-        vlc_object_destroy( p_vout->p_sys->p_event );
-        p_vout->p_sys->p_event = NULL;
-        goto error;
-    }
-
-    if( p_vout->p_sys->p_event->b_error )
-    {
-        msg_Err( p_vout, "Vout EventThread failed" );
-        goto error;
-    }
-
-    vlc_object_attach( p_vout->p_sys->p_event, p_vout );
-
-    msg_Dbg( p_vout, "Vout EventThread running" );
 
     /* Initialise DirectDraw */
     if( DirectXInitDDraw( p_vout ) )
@@ -312,41 +265,11 @@ static int OpenVideo( vlc_object_t *p_this )
 
     /* 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 );
-
-    /* Variable to indicate if the window should be on top of others */
-    /* Trigger a callback right now */
-    var_Create( p_vout, "directx-wallpaper", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
+    var_Create( p_vout, "video-wallpaper", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
     val.psz_string = _("Wallpaper");
-    var_Change( p_vout, "directx-wallpaper", VLC_VAR_SETTEXT, &val, NULL );
-    var_AddCallback( p_vout, "directx-wallpaper", WallpaperCallback, NULL );
-    var_Get( p_vout, "directx-wallpaper", &val );
-    var_Set( p_vout, "directx-wallpaper", val );
-
-    /* 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 ) {
-        msg_Dbg(p_vout, "disabling screen saver");
-        SystemParametersInfo(SPI_GETLOWPOWERTIMEOUT,
-            0, &(p_vout->p_sys->i_spi_lowpowertimeout), 0);
-        if( 0 != p_vout->p_sys->i_spi_lowpowertimeout ) {
-            SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT, 0, NULL, 0);
-        }
-        SystemParametersInfo(SPI_GETPOWEROFFTIMEOUT, 0,
-            &(p_vout->p_sys->i_spi_powerofftimeout), 0);
-        if( 0 != p_vout->p_sys->i_spi_powerofftimeout ) {
-            SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT, 0, NULL, 0);
-        }
-        SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0,
-            &(p_vout->p_sys->i_spi_screensavetimeout), 0);
-        if( 0 != p_vout->p_sys->i_spi_screensavetimeout ) {
-            SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, 0, NULL, 0);
-        }
-    }
+    var_Change( p_vout, "video-wallpaper", VLC_VAR_SETTEXT, &val, NULL );
+    var_AddCallback( p_vout, "video-wallpaper", WallpaperCallback, NULL );
+    var_TriggerCallback( p_vout, "video-wallpaper" );
 
     return VLC_SUCCESS;
 
@@ -364,17 +287,12 @@ static int OpenVideo( vlc_object_t *p_this )
 static int Init( vout_thread_t *p_vout )
 {
     int i_chroma_backup;
-    vlc_value_t val;
 
     /* Get a few default parameters */
-    var_Get( p_vout, "overlay", &val );
-    p_vout->p_sys->b_using_overlay = val.b_bool;
-    var_Get( p_vout, "directx-use-sysmem", &val );
-    p_vout->p_sys->b_use_sysmem = val.b_bool;
-    var_Get( p_vout, "directx-hw-yuv", &val );
-    p_vout->p_sys->b_hw_yuv = val.b_bool;
-    var_Get( p_vout, "directx-3buffering", &val );
-    p_vout->p_sys->b_3buf_overlay = val.b_bool;
+    p_vout->p_sys->b_using_overlay = var_GetBool( p_vout, "overlay" );
+    p_vout->p_sys->b_use_sysmem = var_GetBool( p_vout, "directx-use-sysmem" );
+    p_vout->p_sys->b_hw_yuv = var_GetBool( p_vout, "directx-hw-yuv" );
+    p_vout->p_sys->b_3buf_overlay = var_GetBool( p_vout, "directx-3buffering" );
 
     /* Initialise DirectDraw if not already done.
      * We do this here because on multi-monitor systems we may have to
@@ -401,7 +319,7 @@ static int Init( vout_thread_t *p_vout )
     p_vout->output.i_height = p_vout->render.i_height;
     p_vout->output.i_aspect = p_vout->render.i_aspect;
     p_vout->fmt_out = p_vout->fmt_in;
-    E_(UpdateRects)( p_vout, VLC_TRUE );
+    UpdateRects( p_vout, true );
 
 #define MAX_DIRECTBUFFERS 1
     /* Right now we use only 1 directbuffer because we don't want the
@@ -411,40 +329,43 @@ static int Init( vout_thread_t *p_vout )
     /* Choose the chroma we will try first. */
     switch( p_vout->render.i_chroma )
     {
-        case VLC_FOURCC('Y','U','Y','2'):
-        case VLC_FOURCC('Y','U','N','V'):
-            p_vout->output.i_chroma = VLC_FOURCC('Y','U','Y','2');
+        case VLC_CODEC_YUYV:
+            p_vout->output.i_chroma = VLC_CODEC_YUYV;
+            break;
+        case VLC_CODEC_UYVY:
+            p_vout->output.i_chroma = VLC_CODEC_UYVY;
             break;
-        case VLC_FOURCC('U','Y','V','Y'):
-        case VLC_FOURCC('U','Y','N','V'):
-        case VLC_FOURCC('Y','4','2','2'):
-            p_vout->output.i_chroma = VLC_FOURCC('U','Y','V','Y');
+        case VLC_CODEC_YVYU:
+            p_vout->output.i_chroma = VLC_CODEC_YVYU;
             break;
-        case VLC_FOURCC('Y','V','Y','U'):
-            p_vout->output.i_chroma = VLC_FOURCC('Y','V','Y','U');
+        case VLC_CODEC_I420:
+            p_vout->output.i_chroma = VLC_CODEC_I420;
             break;
         default:
-            p_vout->output.i_chroma = VLC_FOURCC('Y','V','1','2');
+            msg_Dbg( p_vout, "use default chroma YV12 for render " \
+                             "chroma (%4.4s)",
+                             (char *)&p_vout->render.i_chroma);
+            p_vout->output.i_chroma = VLC_CODEC_YV12;
             break;
     }
 
-    NewPictureVec( p_vout, p_vout->p_picture, MAX_DIRECTBUFFERS );
+    NewPictureVec( p_vout, p_vout->p_picture );
 
     i_chroma_backup = p_vout->output.i_chroma;
 
     if( !I_OUTPUTPICTURES )
     {
         /* hmmm, it didn't work! Let's try commonly supported chromas */
-        if( p_vout->output.i_chroma != VLC_FOURCC('I','4','2','0') )
+        if( p_vout->output.i_chroma != VLC_CODEC_I420 )
         {
-            p_vout->output.i_chroma = VLC_FOURCC('Y','V','1','2');
-            NewPictureVec( p_vout, p_vout->p_picture, MAX_DIRECTBUFFERS );
+            p_vout->output.i_chroma = VLC_CODEC_YV12;
+            NewPictureVec( p_vout, p_vout->p_picture );
         }
         if( !I_OUTPUTPICTURES )
         {
             /* hmmm, it still didn't work! Let's try another one */
-            p_vout->output.i_chroma = VLC_FOURCC('Y','U','Y','2');
-            NewPictureVec( p_vout, p_vout->p_picture, MAX_DIRECTBUFFERS );
+            p_vout->output.i_chroma = VLC_CODEC_YUYV;
+            NewPictureVec( p_vout, p_vout->p_picture );
         }
     }
 
@@ -452,14 +373,24 @@ static int Init( vout_thread_t *p_vout )
     {
         /* If it still didn't work then don't try to use an overlay */
         p_vout->output.i_chroma = i_chroma_backup;
-        p_vout->p_sys->b_using_overlay = 0;
-        NewPictureVec( p_vout, p_vout->p_picture, MAX_DIRECTBUFFERS );
+        p_vout->p_sys->b_using_overlay = false;
+        msg_Warn( p_vout, "Could not initialize directx overlay" ) ;
+        NewPictureVec( p_vout, p_vout->p_picture );
     }
 
+    p_vout->fmt_out.i_chroma = p_vout->output.i_chroma;
+
     /* Change the window title bar text */
-    PostMessage( p_vout->p_sys->hwnd, WM_VLC_CHANGE_TEXT, 0, 0 );
+    const char *psz_fallback;
+    if( p_vout->p_sys->b_using_overlay )
+        psz_fallback = VOUT_TITLE " (hardware YUV overlay DirectX output)";
+    else if( p_vout->p_sys->b_hw_yuv )
+        psz_fallback = VOUT_TITLE " (hardware YUV DirectX output)";
+    else
+        psz_fallback = VOUT_TITLE " (software RGB DirectX output)";
+    EventThreadUpdateTitle( p_vout->p_sys->p_event, psz_fallback );
+    EventThreadUseOverlay( p_vout->p_sys->p_event, p_vout->p_sys->b_using_overlay );
 
-    p_vout->fmt_out.i_chroma = p_vout->output.i_chroma;
     return VLC_SUCCESS;
 }
 
@@ -488,50 +419,14 @@ static void CloseVideo( vlc_object_t *p_this )
 {
     vout_thread_t * p_vout = (vout_thread_t *)p_this;
 
-    msg_Dbg( p_vout, "CloseVideo" );
-
-    if( p_vout->p_sys->p_event )
-    {
-        vlc_object_detach( p_vout->p_sys->p_event );
-
-        /* Kill Vout EventThread */
-        vlc_object_kill( p_vout->p_sys->p_event );
-
-        /* we need to be sure Vout EventThread won't stay stuck in
-         * GetMessage, so we send a fake message */
-        if( p_vout->p_sys->hwnd )
-        {
-            PostMessage( p_vout->p_sys->hwnd, WM_NULL, 0, 0);
-        }
-
-        vlc_thread_join( p_vout->p_sys->p_event );
-        vlc_object_destroy( p_vout->p_sys->p_event );
-    }
-
-    vlc_mutex_destroy( &p_vout->p_sys->lock );
-
     /* Make sure the wallpaper is restored */
-    SwitchWallpaperMode( p_vout, VLC_FALSE );
+    var_DelCallback( p_vout, "video-wallpaper", WallpaperCallback, NULL );
+    SwitchWallpaperMode( p_vout, false );
 
-    /* restore screensaver system settings */
-    if( 0 != p_vout->p_sys->i_spi_lowpowertimeout ) {
-        SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT,
-            p_vout->p_sys->i_spi_lowpowertimeout, NULL, 0);
-    }
-    if( 0 != p_vout->p_sys->i_spi_powerofftimeout ) {
-        SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT,
-            p_vout->p_sys->i_spi_powerofftimeout, NULL, 0);
-    }
-    if( 0 != p_vout->p_sys->i_spi_screensavetimeout ) {
-        SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT,
-            p_vout->p_sys->i_spi_screensavetimeout, NULL, 0);
-    }
+    CommonClean( p_vout );
 
-    if( p_vout->p_sys )
-    {
-        free( p_vout->p_sys );
-        p_vout->p_sys = NULL;
-    }
+    vlc_mutex_destroy( &p_vout->p_sys->lock );
+    free( p_vout->p_sys );
 }
 
 /*****************************************************************************
@@ -542,40 +437,7 @@ static void CloseVideo( vlc_object_t *p_this )
  *****************************************************************************/
 static int Manage( vout_thread_t *p_vout )
 {
-    /* If we do not control our window, we check for geometry changes
-     * ourselves because the parent might not send us its events. */
-    vlc_mutex_lock( &p_vout->p_sys->lock );
-    if( p_vout->p_sys->hparent && !p_vout->b_fullscreen )
-    {
-        RECT rect_parent;
-        POINT point;
-
-        vlc_mutex_unlock( &p_vout->p_sys->lock );
-
-        GetClientRect( p_vout->p_sys->hparent, &rect_parent );
-        point.x = point.y = 0;
-        ClientToScreen( p_vout->p_sys->hparent, &point );
-        OffsetRect( &rect_parent, point.x, point.y );
-
-        if( !EqualRect( &rect_parent, &p_vout->p_sys->rect_parent ) )
-        {
-            p_vout->p_sys->rect_parent = rect_parent;
-
-            /* This one is to force the update even if only
-             * the position has changed */
-            SetWindowPos( p_vout->p_sys->hwnd, 0, 1, 1,
-                          rect_parent.right - rect_parent.left,
-                          rect_parent.bottom - rect_parent.top, 0 );
-
-            SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
-                          rect_parent.right - rect_parent.left,
-                          rect_parent.bottom - rect_parent.top, 0 );
-        }
-    }
-    else
-    {
-        vlc_mutex_unlock( &p_vout->p_sys->lock );
-    }
+    CommonManage( p_vout );
 
     /*
      * Position Change
@@ -595,29 +457,6 @@ static int Manage( vout_thread_t *p_vout )
         }
     }
 
-    /* Check for cropping / aspect changes */
-    if( p_vout->i_changes & VOUT_CROP_CHANGE ||
-        p_vout->i_changes & VOUT_ASPECT_CHANGE )
-    {
-        p_vout->i_changes &= ~VOUT_CROP_CHANGE;
-        p_vout->i_changes &= ~VOUT_ASPECT_CHANGE;
-
-        p_vout->fmt_out.i_x_offset = p_vout->fmt_in.i_x_offset;
-        p_vout->fmt_out.i_y_offset = p_vout->fmt_in.i_y_offset;
-        p_vout->fmt_out.i_visible_width = p_vout->fmt_in.i_visible_width;
-        p_vout->fmt_out.i_visible_height = p_vout->fmt_in.i_visible_height;
-        p_vout->fmt_out.i_aspect = p_vout->fmt_in.i_aspect;
-        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, VLC_TRUE );
-    }
-
-    /* We used to call the Win32 PeekMessage function here to read the window
-     * messages. But since window can stay blocked into this function for a
-     * long time (for example when you move your window on the screen), I
-     * decided to isolate PeekMessage in another thread. */
-
     if( p_vout->p_sys->i_changes & DX_WALLPAPER_CHANGE )
     {
         SwitchWallpaperMode( p_vout, !p_vout->p_sys->b_wallpaper );
@@ -625,79 +464,6 @@ static int Manage( vout_thread_t *p_vout )
         DirectDrawUpdateOverlay( p_vout );
     }
 
-    /*
-     * Fullscreen change
-     */
-    if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE
-        || p_vout->p_sys->i_changes & VOUT_FULLSCREEN_CHANGE )
-    {
-        Win32ToggleFullscreen( p_vout );
-
-        p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
-        p_vout->p_sys->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
-    }
-
-    /*
-     * Pointer change
-     */
-    if( p_vout->b_fullscreen && !p_vout->p_sys->b_cursor_hidden &&
-        (mdate() - p_vout->p_sys->i_lastmoved) > 5000000 )
-    {
-        POINT point;
-        HWND hwnd;
-
-        /* Hide the cursor only if it is inside our window */
-        GetCursorPos( &point );
-        hwnd = WindowFromPoint(point);
-        if( hwnd == p_vout->p_sys->hwnd || hwnd == p_vout->p_sys->hvideownd )
-        {
-            PostMessage( p_vout->p_sys->hwnd, WM_VLC_HIDE_MOUSE, 0, 0 );
-        }
-        else
-        {
-            p_vout->p_sys->i_lastmoved = mdate();
-        }
-    }
-
-    /*
-     * "Always on top" status change
-     */
-    if( p_vout->p_sys->b_on_top_change )
-    {
-        vlc_value_t val;
-        HMENU hMenu = GetSystemMenu( p_vout->p_sys->hwnd, FALSE );
-
-        var_Get( p_vout, "video-on-top", &val );
-
-        /* Set the window on top if necessary */
-        if( val.b_bool && !( GetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE )
-                           & WS_EX_TOPMOST ) )
-        {
-            CheckMenuItem( hMenu, IDM_TOGGLE_ON_TOP,
-                           MF_BYCOMMAND | MFS_CHECKED );
-            SetWindowPos( p_vout->p_sys->hwnd, HWND_TOPMOST, 0, 0, 0, 0,
-                          SWP_NOSIZE | SWP_NOMOVE );
-        }
-        else
-        /* The window shouldn't be on top */
-        if( !val.b_bool && ( GetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE )
-                           & WS_EX_TOPMOST ) )
-        {
-            CheckMenuItem( hMenu, IDM_TOGGLE_ON_TOP,
-                           MF_BYCOMMAND | MFS_UNCHECKED );
-            SetWindowPos( p_vout->p_sys->hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
-                          SWP_NOSIZE | SWP_NOMOVE );
-        }
-
-        p_vout->p_sys->b_on_top_change = VLC_FALSE;
-    }
-
-    /* Check if the event thread is still running */
-    if( p_vout->p_sys->p_event->b_die )
-    {
-        return VLC_EGENERIC; /* exit */
-    }
-
     return VLC_SUCCESS;
 }
 
@@ -793,9 +559,9 @@ static void FirstDisplay( vout_thread_t *p_vout, picture_t *p_pic )
 
     if( p_vout->p_sys->b_using_overlay )
     {
+        HBRUSH brush = CreateSolidBrush( p_vout->p_sys->i_rgb_colorkey );
         /* set the colorkey as the backgound brush for the video window */
-        SetClassLong( p_vout->p_sys->hvideownd, GCL_HBRBACKGROUND,
-                      (LONG)CreateSolidBrush( p_vout->p_sys->i_rgb_colorkey ) );
+        SetClassLongPtr( p_vout->p_sys->hvideownd, GCLP_HBRBACKGROUND, (LONG_PTR)brush );
     }
     /*
     ** Video window is initially hidden, show it now since we got a
@@ -826,20 +592,20 @@ BOOL WINAPI DirectXEnumCallback( GUID* p_guid, LPTSTR psz_desc,
                                  HMONITOR hmon )
 {
     vout_thread_t *p_vout = (vout_thread_t *)p_context;
-    vlc_value_t device;
+    char *psz_device;
 
     msg_Dbg( p_vout, "DirectXEnumCallback: %s, %s", psz_desc, psz_drivername );
 
     if( hmon )
     {
-        var_Get( p_vout, "directx-device", &device );
+        psz_device = var_GetString( p_vout, "directx-device" );
 
-        if( ( !device.psz_string || !*device.psz_string ) &&
+        if( ( !psz_device || !*psz_device ) &&
             hmon == p_vout->p_sys->hmonitor )
         {
-            if( device.psz_string ) free( device.psz_string );
+            free( psz_device );
         }
-        else if( strcmp( psz_drivername, device.psz_string ) == 0 )
+        else if( strcmp( psz_drivername, psz_device ) == 0 )
         {
             MONITORINFO monitor_info;
             monitor_info.cbSize = sizeof( MONITORINFO );
@@ -863,11 +629,11 @@ BOOL WINAPI DirectXEnumCallback( GUID* p_guid, LPTSTR psz_desc,
             }
 
             p_vout->p_sys->hmonitor = hmon;
-            if( device.psz_string ) free( device.psz_string );
+            free( psz_device );
         }
         else
         {
-            if( device.psz_string ) free( device.psz_string );
+            free( psz_device );
             return TRUE; /* Keep enumerating */
         }
 
@@ -914,21 +680,17 @@ static int DirectXInitDDraw( vout_thread_t *p_vout )
 
     OurDirectDrawEnumerateEx =
       (void *)GetProcAddress( p_vout->p_sys->hddraw_dll,
-#ifndef UNICODE
-                              "DirectDrawEnumerateExA" );
-#else
                               _T("DirectDrawEnumerateExW") );
-#endif
 
     if( OurDirectDrawEnumerateEx && p_vout->p_sys->MonitorFromWindow )
     {
-        vlc_value_t device;
+        char *psz_device;
 
-        var_Get( p_vout, "directx-device", &device );
-        if( device.psz_string )
+        psz_device = var_GetString( p_vout, "directx-device" );
+        if( psz_device )
         {
-            msg_Dbg( p_vout, "directx-device: %s", device.psz_string );
-            free( device.psz_string );
+            msg_Dbg( p_vout, "directx-device: %s", psz_device );
+            free( psz_device );
         }
 
         p_vout->p_sys->hmonitor =
@@ -951,7 +713,7 @@ static int DirectXInitDDraw( vout_thread_t *p_vout )
 
     /* Get the IDirectDraw2 interface */
     dxresult = IDirectDraw_QueryInterface( p_ddobject, &IID_IDirectDraw2,
-                                        (LPVOID *)&p_vout->p_sys->p_ddobject );
+                                        &p_vout->p_sys->p_ddobject );
     /* Release the unused interface */
     IDirectDraw_Release( p_ddobject );
     if( dxresult != DD_OK )
@@ -1040,7 +802,7 @@ static int DirectXCreateDisplay( vout_thread_t *p_vout )
 
     dxresult = IDirectDrawSurface_QueryInterface( p_display,
                                          &IID_IDirectDrawSurface2,
-                                         (LPVOID *)&p_vout->p_sys->p_display );
+                                         &p_vout->p_sys->p_display );
     /* Release the old interface */
     IDirectDrawSurface_Release( p_display );
     if ( dxresult != DD_OK )
@@ -1058,7 +820,7 @@ static int DirectXCreateDisplay( vout_thread_t *p_vout )
     p_vout->p_sys->i_rgb_colorkey =
         DirectXFindColorkey( p_vout, &p_vout->p_sys->i_colorkey );
 
-    E_(UpdateRects)( p_vout, VLC_TRUE );
+    UpdateRects( p_vout, true );
 
     return VLC_SUCCESS;
 }
@@ -1172,12 +934,12 @@ static int DirectXCreateSurface( vout_thread_t *p_vout,
 
     if( !b_overlay )
     {
-        vlc_bool_t b_rgb_surface =
-            ( i_chroma == VLC_FOURCC('R','G','B','2') )
-          || ( i_chroma == VLC_FOURCC('R','V','1','5') )
-           || ( i_chroma == VLC_FOURCC('R','V','1','6') )
-            || ( i_chroma == VLC_FOURCC('R','V','2','4') )
-             || ( i_chroma == VLC_FOURCC('R','V','3','2') );
+        bool b_rgb_surface =
+            ( i_chroma == VLC_CODEC_RGB8 )
+          || ( i_chroma == VLC_CODEC_RGB15 )
+           || ( i_chroma == VLC_CODEC_RGB16 )
+            || ( i_chroma == VLC_CODEC_RGB24 )
+             || ( i_chroma == VLC_CODEC_RGB32 );
 
         memset( &ddsd, 0, sizeof( DDSURFACEDESC ) );
         ddsd.dwSize = sizeof(DDSURFACEDESC);
@@ -1257,7 +1019,7 @@ int DirectDrawUpdateOverlay( vout_thread_t *p_vout )
 
     if( p_vout->p_sys->b_wallpaper )
     {
-        int i_x, i_y, i_width, i_height;
+        unsigned i_x, i_y, i_width, i_height;
 
         rect_src.left = p_vout->fmt_out.i_x_offset;
         rect_src.top = p_vout->fmt_out.i_y_offset;
@@ -1328,11 +1090,8 @@ static void DirectXCloseDDraw( vout_thread_t *p_vout )
         p_vout->p_sys->hddraw_dll = NULL;
     }
 
-    if( p_vout->p_sys->p_display_driver != NULL )
-    {
-        free( p_vout->p_sys->p_display_driver );
-        p_vout->p_sys->p_display_driver = NULL;
-    }
+    free( p_vout->p_sys->p_display_driver );
+    p_vout->p_sys->p_display_driver = NULL;
 
     p_vout->p_sys->hmonitor = NULL;
 }
@@ -1377,12 +1136,12 @@ static void DirectXCloseSurface( vout_thread_t *p_vout,
 }
 
 /*****************************************************************************
- * NewPictureVec: allocate a vector of identical pictures
+ * NewPictureVec: allocate a picture
+ * FIXME? make it work for i_num_pic pictures...
  *****************************************************************************
  * Returns 0 on success, -1 otherwise
  *****************************************************************************/
-static int NewPictureVec( vout_thread_t *p_vout, picture_t *p_pic,
-                          int i_num_pics )
+static int NewPictureVec( vout_thread_t *p_vout, picture_t *p_pic )
 {
     int i;
     int i_ret = VLC_SUCCESS;
@@ -1485,7 +1244,7 @@ static int NewPictureVec( vout_thread_t *p_vout, picture_t *p_pic,
         {
             DWORD i_codes;
             DWORD *pi_codes;
-            vlc_bool_t b_result = VLC_FALSE;
+            bool b_result = false;
 
             /* Check if the chroma is supported first. This is required
              * because a few buggy drivers don't mind creating the surface
@@ -1501,11 +1260,12 @@ static int NewPictureVec( vout_thread_t *p_vout, picture_t *p_pic,
                     {
                         if( p_vout->output.i_chroma == pi_codes[i] )
                         {
-                            b_result = VLC_TRUE;
+                            b_result = true;
                             break;
                         }
                     }
                 }
+                free( pi_codes );
             }
 
             if( b_result )
@@ -1514,7 +1274,7 @@ static int NewPictureVec( vout_thread_t *p_vout, picture_t *p_pic,
                                               0 /* no overlay */,
                                               0 /* no back buffers */ );
             else
-                p_vout->p_sys->b_hw_yuv = VLC_FALSE;
+                p_vout->p_sys->b_hw_yuv = false;
         }
 
         if( i_ret || !p_vout->p_sys->b_hw_yuv )
@@ -1531,20 +1291,20 @@ static int NewPictureVec( vout_thread_t *p_vout, picture_t *p_pic,
                 switch( ddpfPixelFormat.dwRGBBitCount )
                 {
                 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;
                     break;
                 case 16:
-                    p_vout->output.i_chroma = VLC_FOURCC('R','V','1','6');
+                    p_vout->output.i_chroma = VLC_CODEC_RGB16;
                     break;
                 case 24:
-                    p_vout->output.i_chroma = VLC_FOURCC('R','V','2','4');
+                    p_vout->output.i_chroma = VLC_CODEC_RGB24;
                     break;
                 case 32:
-                    p_vout->output.i_chroma = VLC_FOURCC('R','V','3','2');
+                    p_vout->output.i_chroma = VLC_CODEC_RGB32;
                     break;
                 default:
                     msg_Err( p_vout, "unknown screen depth" );
@@ -1601,7 +1361,7 @@ static int NewPictureVec( vout_thread_t *p_vout, picture_t *p_pic,
     {
         p_pic[i].i_status = DESTROYED_PICTURE;
         p_pic[i].i_type   = DIRECT_PICTURE;
-        p_pic[i].b_slow   = VLC_TRUE;
+        p_pic[i].b_slow   = true;
         p_pic[i].pf_lock  = DirectXLockSurface;
         p_pic[i].pf_unlock = DirectXUnlockSurface;
         PP_OUTPUTPICTURE[i] = &p_pic[i];
@@ -1653,33 +1413,32 @@ static void FreePictureVec( vout_thread_t *p_vout, picture_t *p_pic,
  *****************************************************************************
  * This will setup stuff for use by the video_output thread
  *****************************************************************************/
-static int UpdatePictureStruct( vout_thread_t *p_vout, picture_t *p_pic,
-                                int i_chroma )
+static int UpdatePictureStruct( vout_thread_t *p_vout, picture_t *p_pic )
 {
     switch( p_vout->output.i_chroma )
     {
-        case VLC_FOURCC('R','G','B','2'):
-        case VLC_FOURCC('R','V','1','5'):
-        case VLC_FOURCC('R','V','1','6'):
-        case VLC_FOURCC('R','V','2','4'):
-        case VLC_FOURCC('R','V','3','2'):
+        case VLC_CODEC_RGB8:
+        case VLC_CODEC_RGB15:
+        case VLC_CODEC_RGB16:
+        case VLC_CODEC_RGB24:
+        case VLC_CODEC_RGB32:
             p_pic->p->p_pixels = p_pic->p_sys->ddsd.lpSurface;
             p_pic->p->i_lines = p_vout->output.i_height;
             p_pic->p->i_visible_lines = p_vout->output.i_height;
             p_pic->p->i_pitch = p_pic->p_sys->ddsd.lPitch;
             switch( p_vout->output.i_chroma )
             {
-                case VLC_FOURCC('R','G','B','2'):
+                case VLC_CODEC_RGB8:
                     p_pic->p->i_pixel_pitch = 1;
                     break;
-                case VLC_FOURCC('R','V','1','5'):
-                case VLC_FOURCC('R','V','1','6'):
+                case VLC_CODEC_RGB15:
+                case VLC_CODEC_RGB16:
                     p_pic->p->i_pixel_pitch = 2;
                     break;
-                case VLC_FOURCC('R','V','2','4'):
+                case VLC_CODEC_RGB24:
                     p_pic->p->i_pixel_pitch = 3;
                     break;
-                case VLC_FOURCC('R','V','3','2'):
+                case VLC_CODEC_RGB32:
                     p_pic->p->i_pixel_pitch = 4;
                     break;
                 default:
@@ -1690,12 +1449,12 @@ static int UpdatePictureStruct( vout_thread_t *p_vout, picture_t *p_pic,
             p_pic->i_planes = 1;
             break;
 
-        case VLC_FOURCC('Y','V','1','2'):
-        case VLC_FOURCC('I','4','2','0'):
+        case VLC_CODEC_YV12:
 
             /* U and V inverted compared to I420
              * Fixme: this should be handled by the vout core */
-            p_vout->output.i_chroma = VLC_FOURCC('I','4','2','0');
+            /* could this be right? */
+            p_vout->output.i_chroma = VLC_CODEC_I420;
 
             p_pic->Y_PIXELS = p_pic->p_sys->ddsd.lpSurface;
             p_pic->p[Y_PLANE].i_lines = p_vout->output.i_height;
@@ -1726,7 +1485,7 @@ static int UpdatePictureStruct( vout_thread_t *p_vout, picture_t *p_pic,
             p_pic->i_planes = 3;
             break;
 
-        case VLC_FOURCC('I','Y','U','V'):
+        case VLC_CODEC_I420:
 
             p_pic->Y_PIXELS = p_pic->p_sys->ddsd.lpSurface;
             p_pic->p[Y_PLANE].i_lines = p_vout->output.i_height;
@@ -1757,8 +1516,8 @@ static int UpdatePictureStruct( vout_thread_t *p_vout, picture_t *p_pic,
             p_pic->i_planes = 3;
             break;
 
-        case VLC_FOURCC('U','Y','V','Y'):
-        case VLC_FOURCC('Y','U','Y','2'):
+        case VLC_CODEC_UYVY:
+        case VLC_CODEC_YUYV:
 
             p_pic->p->p_pixels = p_pic->p_sys->ddsd.lpSurface;
             p_pic->p->i_lines = p_vout->output.i_height;
@@ -1805,7 +1564,7 @@ static void DirectXGetDDrawCaps( vout_thread_t *p_vout )
     }
     else
     {
-        vlc_bool_t bHasOverlay, bHasOverlayFourCC, bCanDeinterlace,
+        bool bHasOverlay, bHasOverlayFourCC, bCanDeinterlace,
              bHasColorKey, bCanStretch, bCanBltFourcc,
              bAlignBoundarySrc, bAlignBoundaryDest,
              bAlignSizeSrc, bAlignSizeDest;
@@ -1830,7 +1589,7 @@ static void DirectXGetDDrawCaps( vout_thread_t *p_vout )
         bAlignSizeSrc = (ddcaps.dwCaps & DDCAPS_ALIGNSIZESRC) ? 1 : 0;
         /* Determine overlay destination size alignment */
         bAlignSizeDest = (ddcaps.dwCaps & DDCAPS_ALIGNSIZEDEST) ? 1 : 0;
+
         msg_Dbg( p_vout, "DirectDraw Capabilities: overlay=%i yuvoverlay=%i "
                          "can_deinterlace_overlay=%i colorkey=%i stretch=%i "
                          "bltfourcc=%i",
@@ -1905,7 +1664,7 @@ static int DirectXLockSurface( vout_thread_t *p_vout, picture_t *p_pic )
             dxresult = IDirectDrawSurface2_Lock( p_pic->p_sys->p_surface, NULL,
                                                  &p_pic->p_sys->ddsd,
                                                  DDLOCK_WAIT, NULL);
-#if 0
+#ifndef NDEBUG
             if( dxresult == DDERR_SURFACELOST )
                 msg_Dbg( p_vout, "DirectXLockSurface: DDERR_SURFACELOST" );
 #endif
@@ -1918,7 +1677,7 @@ static int DirectXLockSurface( vout_thread_t *p_vout, picture_t *p_pic )
 
     /* Now we have a pointer to the surface memory, we can update our picture
      * structure. */
-    if( UpdatePictureStruct( p_vout, p_pic, p_vout->output.i_chroma )
+    if( UpdatePictureStruct( p_vout, p_pic )
         != VLC_SUCCESS )
     {
         DirectXUnlockSurface( p_vout, p_pic );
@@ -1933,6 +1692,8 @@ static int DirectXLockSurface( vout_thread_t *p_vout, picture_t *p_pic )
  *****************************************************************************/
 static int DirectXUnlockSurface( vout_thread_t *p_vout, picture_t *p_pic )
 {
+    VLC_UNUSED( p_vout );
+
     /* Unlock the Surface */
     if( IDirectDrawSurface2_Unlock( p_pic->p_sys->p_surface, NULL ) == DD_OK )
         return VLC_SUCCESS;
@@ -2001,7 +1762,7 @@ static DWORD DirectXFindColorkey( vout_thread_t *p_vout, uint32_t *pi_color )
 /*****************************************************************************
  * A few toolbox functions
  *****************************************************************************/
-void SwitchWallpaperMode( vout_thread_t *p_vout, vlc_bool_t b_on )
+void SwitchWallpaperMode( vout_thread_t *p_vout, bool b_on )
 {
     HWND hwnd;
 
@@ -2047,13 +1808,13 @@ BOOL WINAPI DirectXEnumCallback2( GUID* p_guid, LPTSTR psz_desc,
                                   LPTSTR psz_drivername, VOID* p_context,
                                   HMONITOR hmon )
 {
+    VLC_UNUSED( p_guid ); VLC_UNUSED( psz_desc ); VLC_UNUSED( hmon );
+
     module_config_t *p_item = (module_config_t *)p_context;
 
-    p_item->ppsz_list =
-        (char **)realloc( p_item->ppsz_list,
+    p_item->ppsz_list = xrealloc( p_item->ppsz_list,
                           (p_item->i_list+2) * sizeof(char *) );
-    p_item->ppsz_list_text =
-        (char **)realloc( p_item->ppsz_list_text,
+    p_item->ppsz_list_text = xrealloc( p_item->ppsz_list_text,
                           (p_item->i_list+2) * sizeof(char *) );
 
     p_item->ppsz_list[p_item->i_list] = strdup( psz_drivername );
@@ -2068,6 +1829,8 @@ BOOL WINAPI DirectXEnumCallback2( GUID* p_guid, LPTSTR psz_desc,
 static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
                                vlc_value_t newval, vlc_value_t oldval, void *d)
 {
+    VLC_UNUSED( newval ); VLC_UNUSED( oldval ); VLC_UNUSED( d );
+
     HRESULT (WINAPI *OurDirectDrawEnumerateEx)( LPDDENUMCALLBACKEXA, LPVOID,
                                                 DWORD );
     HINSTANCE hddraw_dll;
@@ -2098,11 +1861,7 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
     if( hddraw_dll == NULL ) return VLC_SUCCESS;
 
     OurDirectDrawEnumerateEx =
-#ifndef UNICODE
-      (void *)GetProcAddress( hddraw_dll, "DirectDrawEnumerateExA" );
-#else
       (void *)GetProcAddress( hddraw_dll, _T("DirectDrawEnumerateExW") );
-#endif
 
     if( OurDirectDrawEnumerateEx )
     {
@@ -2114,7 +1873,7 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
     FreeLibrary( hddraw_dll );
 
     /* Signal change to the interface */
-    p_item->b_dirty = VLC_TRUE;
+    p_item->b_dirty = true;
 
     return VLC_SUCCESS;
 }
@@ -2123,24 +1882,21 @@ static int WallpaperCallback( vlc_object_t *p_this, char const *psz_cmd,
                               vlc_value_t oldval, vlc_value_t newval,
                               void *p_data )
 {
+    VLC_UNUSED( psz_cmd ); VLC_UNUSED( oldval ); VLC_UNUSED( p_data );
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
 
     if( (newval.b_bool && !p_vout->p_sys->b_wallpaper) ||
         (!newval.b_bool && p_vout->p_sys->b_wallpaper) )
     {
-        playlist_t *p_playlist;
+        playlist_t *p_playlist = pl_Hold( p_vout );
 
-        p_playlist =
-            (playlist_t *)vlc_object_find( p_this, VLC_OBJECT_PLAYLIST,
-                                           FIND_PARENT );
         if( p_playlist )
         {
             /* Modify playlist as well because the vout might have to be
              * restarted */
-            var_Create( p_playlist, "directx-wallpaper", VLC_VAR_BOOL );
-            var_Set( p_playlist, "directx-wallpaper", newval );
-
-            vlc_object_release( p_playlist );
+            var_Create( p_playlist, "video-wallpaper", VLC_VAR_BOOL );
+            var_Set( p_playlist, "video-wallpaper", newval );
+            pl_Release( p_vout );
         }
 
         p_vout->p_sys->i_changes |= DX_WALLPAPER_CHANGE;
@@ -2155,5 +1911,6 @@ static int WallpaperCallback( vlc_object_t *p_this, char const *psz_cmd,
 static void SetPalette( vout_thread_t *p_vout,
                         uint16_t *red, uint16_t *green, uint16_t *blue )
 {
+    VLC_UNUSED( red ); VLC_UNUSED( green );VLC_UNUSED( blue );
     msg_Err( p_vout, "FIXME: SetPalette unimplemented" );
 }