/*****************************************************************************
- * 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_common.h>
#include <vlc_plugin.h>
-#include <vlc_interface.h>
-#include <vlc_playlist.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>
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 );
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
*****************************************************************************/
"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." )
+#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_category( CAT_VIDEO );
- set_subcategory( SUBCAT_VIDEO_VOUT );
- add_bool( "directx-hw-yuv", 1, NULL, HW_YUV_TEXT, HW_YUV_LONGTEXT,
- true );
- add_bool( "directx-use-sysmem", 0, NULL, SYSMEM_TEXT, SYSMEM_LONGTEXT,
- true );
- add_bool( "directx-3buffering", 1, NULL, TRIPLEBUF_TEXT,
- TRIPLEBUF_LONGTEXT, true );
+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,
- 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,
- true );
+ true )
+ change_string_list( ppsz_dev, ppsz_dev_text, FindDevicesCallback )
+ change_action_add( FindDevicesCallback, N_("Refresh list") )
- set_description( N_("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
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 )
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;
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_sys->lock );
- SetRectEmpty( &p_vout->p_sys->rect_display );
- SetRectEmpty( &p_vout->p_sys->rect_parent );
/* Multimonitor stuff */
p_vout->p_sys->hmonitor = NULL;
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 );
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();
- p_vout->p_sys->i_mouse_hide_timeout =
- var_GetInteger(p_vout, "mouse-hide-timeout") * 1000;
-
- /* 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",
- EventThread, 0, 1 ) )
- {
- msg_Err( p_vout, "cannot create Vout EventThread" );
- vlc_object_release( 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 ) )
/* 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;
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
/* 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 );
}
}
{
/* 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;
}
{
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_release( p_vout->p_sys->p_event );
- }
-
- vlc_mutex_destroy( &p_vout->p_sys->lock );
-
/* Make sure the wallpaper is restored */
+ 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 );
+ vlc_mutex_destroy( &p_vout->p_sys->lock );
free( p_vout->p_sys );
- p_vout->p_sys = NULL;
}
/*****************************************************************************
*****************************************************************************/
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
}
}
- /* 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;
- UpdateRects( p_vout, 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 );
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) >
- p_vout->p_sys->i_mouse_hide_timeout )
- {
- 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 = 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;
}
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
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 )
{
- 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 );
}
p_vout->p_sys->hmonitor = hmon;
- free( device.psz_string );
+ free( psz_device );
}
else
{
- free( device.psz_string );
+ free( psz_device );
return TRUE; /* Keep enumerating */
}
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 =
/* 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 )
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 )
if( !b_overlay )
{
bool 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') );
+ ( 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);
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;
}
/*****************************************************************************
- * 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;
}
}
}
+ free( pi_codes );
}
if( b_result )
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" );
*****************************************************************************
* 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:
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;
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;
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;
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",
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
/* 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 );
*****************************************************************************/
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;
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 );
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;
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 )
{
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 = vlc_object_find( p_this,
- VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
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;
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" );
}