Commit 8a27f191 authored by Laurent Aimar's avatar Laurent Aimar

Centralized common init/clean code (msw).

parent e17db4e3
......@@ -72,6 +72,56 @@
static int vaControlParentWindow( vout_thread_t *, int, va_list );
/* */
int CommonInit( vout_thread_t *p_vout )
{
vout_sys_t *p_sys = p_vout->p_sys;
p_sys->hwnd = NULL;
p_sys->hvideownd = NULL;
p_sys->hparent = NULL;
p_sys->hfswnd = NULL;
p_sys->i_changes = 0;
SetRectEmpty( &p_sys->rect_display );
SetRectEmpty( &p_sys->rect_parent );
p_sys->b_cursor_hidden = 0;
p_sys->i_lastmoved = mdate();
p_sys->i_mouse_hide_timeout =
var_GetInteger(p_vout, "mouse-hide-timeout") * 1000;
var_Create( p_vout, "video-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
/* Set main window's size */
p_sys->i_window_width = p_vout->i_window_width;
p_sys->i_window_height = p_vout->i_window_height;
if( !CreateEventThread( p_vout ) )
return VLC_EGENERIC;
/* Variable to indicate if the window should be on top of others */
/* Trigger a callback right now */
var_TriggerCallback( p_vout, "video-on-top" );
/* Why not with glwin32 */
#if !defined(UNDER_CE) && !defined(MODULE_NAME_IS_glwin32)
var_Create( p_vout, "disable-screensaver", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
DisableScreensaver ( p_vout );
#endif
return VLC_SUCCESS;
}
/* */
void CommonClean( vout_thread_t *p_vout )
{
StopEventThread( p_vout );
#if !defined(UNDER_CE) && !defined(MODULE_NAME_IS_glwin32)
RestoreScreensaver( p_vout );
#endif
}
/*****************************************************************************
* UpdateRects: update clipping rectangles
*****************************************************************************
......
......@@ -194,50 +194,25 @@ static int OpenVideo( vlc_object_t *p_this )
p_vout->pf_display = FirstDisplay;
p_vout->pf_control = Control;
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_desktop = false;
SetRectEmpty( &p_vout->p_sys->rect_display );
SetRectEmpty( &p_vout->p_sys->rect_parent );
if( CommonInit( p_vout ) )
goto error;
p_vout->p_sys->b_desktop = false;
var_Create( p_vout, "directx-hw-yuv", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
var_Create( p_vout, "directx-device", VLC_VAR_STRING | 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;
var_Create( p_vout, "video-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Create( p_vout, "disable-screensaver", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
/* 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;
if ( CreateEventThread( p_vout ) )
{
/* Variable to indicate if the window should be on top of others */
/* Trigger a callback right now */
var_TriggerCallback( p_vout, "video-on-top" );
/* Trigger a callback right now */
var_Create( p_vout, "direct3d-desktop", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
val.psz_string = _("Desktop");
var_Change( p_vout, "direct3d-desktop", VLC_VAR_SETTEXT, &val, NULL );
var_AddCallback( p_vout, "direct3d-desktop", DesktopCallback, NULL );
var_TriggerCallback( p_vout, "direct3d-desktop" );
/* Trigger a callback right now */
var_Create( p_vout, "direct3d-desktop", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
val.psz_string = _("Desktop");
var_Change( p_vout, "direct3d-desktop", VLC_VAR_SETTEXT, &val, NULL );
var_AddCallback( p_vout, "direct3d-desktop", DesktopCallback, NULL );
var_TriggerCallback( p_vout, "direct3d-desktop" );
DisableScreensaver ( p_vout );
return VLC_SUCCESS;
return VLC_SUCCESS;
}
else
{
CloseVideo( VLC_OBJECT(p_vout) );
return VLC_EGENERIC;
}
error:
CloseVideo( VLC_OBJECT(p_vout) );
return VLC_EGENERIC;
}
/*****************************************************************************
......@@ -251,12 +226,9 @@ static void CloseVideo( vlc_object_t *p_this )
Direct3DVoutRelease( p_vout );
StopEventThread( p_vout );
RestoreScreensaver( p_vout );
CommonClean( p_vout );
free( p_vout->p_sys );
p_vout->p_sys = NULL;
}
/*****************************************************************************
......
......@@ -227,16 +227,15 @@ static int OpenVideo( vlc_object_t *p_this )
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;
SetRectEmpty( &p_vout->p_sys->rect_display );
SetRectEmpty( &p_vout->p_sys->rect_parent );
/* Multimonitor stuff */
p_vout->p_sys->hmonitor = NULL;
......@@ -256,20 +255,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();
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;
if ( !CreateEventThread( p_vout ) )
goto error;
/* Initialise DirectDraw */
if( DirectXInitDDraw( p_vout ) )
......@@ -285,10 +270,6 @@ static int OpenVideo( vlc_object_t *p_this )
goto error;
}
/* Variable to indicate if the window should be on top of others */
/* Trigger a callback right now */
var_TriggerCallback( p_vout, "video-on-top" );
/* 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 );
......@@ -297,8 +278,6 @@ static int OpenVideo( vlc_object_t *p_this )
var_AddCallback( p_vout, "directx-wallpaper", WallpaperCallback, NULL );
var_TriggerCallback( p_vout, "directx-wallpaper" );
DisableScreensaver ( p_vout );
return VLC_SUCCESS;
error:
......@@ -438,13 +417,11 @@ static void CloseVideo( vlc_object_t *p_this )
{
vout_thread_t * p_vout = (vout_thread_t *)p_this;
StopEventThread( p_vout );
/* Make sure the wallpaper is restored */
var_DelCallback( p_vout, "directx-wallpaper", WallpaperCallback, NULL );
SwitchWallpaperMode( p_vout, false );
RestoreScreensaver( p_vout );
CommonClean( p_vout );
free( p_vout->p_sys );
}
......
......@@ -104,36 +104,14 @@ static int OpenVideo( vlc_object_t *p_this )
p_vout->pf_swap = FirstSwap;
p_vout->pf_control = Control;
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;
SetRectEmpty( &p_vout->p_sys->rect_display );
SetRectEmpty( &p_vout->p_sys->rect_parent );
if( CommonInit( p_vout ) )
goto error;
var_Create( p_vout, "video-title", VLC_VAR_STRING | 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;
if ( CreateEventThread( p_vout ) )
{
/* Variable to indicate if the window should be on top of others */
/* Trigger a callback right now */
var_TriggerCallback( p_vout, "video-on-top" );
return VLC_SUCCESS;
return VLC_SUCCESS;
}
else
{
CloseVideo( VLC_OBJECT(p_vout) );
return VLC_EGENERIC;
}
error:
CloseVideo( VLC_OBJECT(p_vout) );
return VLC_EGENERIC;
}
/*****************************************************************************
......@@ -191,10 +169,9 @@ static void CloseVideo( vlc_object_t *p_this )
{
vout_thread_t * p_vout = (vout_thread_t *)p_this;
StopEventThread( p_vout );
CommonClean( p_vout );
free( p_vout->p_sys );
p_vout->p_sys = NULL;
}
/*****************************************************************************
......
......@@ -262,6 +262,9 @@ void StopEventThread ( vout_thread_t *p_vout );
/*****************************************************************************
* Prototypes from common.c
*****************************************************************************/
int CommonInit( vout_thread_t * );
void CommonClean( vout_thread_t * );
int Control( vout_thread_t *p_vout, int i_query, va_list args );
void UpdateRects ( vout_thread_t *p_vout, bool b_force );
......
......@@ -141,13 +141,6 @@ static int OpenVideo ( vlc_object_t *p_this )
p_vout->p_sys->render_height = p_vout->render.i_height;
#endif
p_vout->p_sys->p_event = vlc_object_create( p_vout, sizeof( event_thread_t ) );
if( !p_vout->p_sys->p_event )
{
free( p_vout->p_sys );
return VLC_ENOMEM;
}
p_vout->pf_init = Init;
p_vout->pf_end = End;
p_vout->pf_manage = Manage;
......@@ -158,46 +151,18 @@ static int OpenVideo ( vlc_object_t *p_this )
p_vout->p_sys->b_focus = 0;
p_vout->p_sys->b_parent_focus = 0;
#else
p_vout->pf_display = FirstDisplayGDI;
#endif
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;
SetRectEmpty( &p_vout->p_sys->rect_display );
SetRectEmpty( &p_vout->p_sys->rect_parent );
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;
if ( CreateEventThread( p_vout ) )
{
if( CommonInit( p_vout ) )
goto error;
#ifndef UNDER_CE
/* Variable to indicate if the window should be on top of others */
/* Trigger a callback right now */
var_TriggerCallback( p_vout, "video-on-top" );
return VLC_SUCCESS;
DisableScreensaver ( p_vout );
#endif
return VLC_SUCCESS;
}
else
{
CloseVideo( VLC_OBJECT(p_vout) );
return VLC_EGENERIC;
}
error:
CloseVideo( VLC_OBJECT(p_vout) );
return VLC_EGENERIC;
}
/*****************************************************************************
......@@ -207,18 +172,13 @@ static void CloseVideo ( vlc_object_t *p_this )
{
vout_thread_t * p_vout = (vout_thread_t *)p_this;
StopEventThread( p_vout );
#ifndef UNDER_CE
RestoreScreensaver( p_vout );
#endif
CommonClean( p_vout );
#ifdef MODULE_NAME_IS_wingapi
FreeLibrary( p_vout->p_sys->gapi_dll );
#endif
free( p_vout->p_sys );
p_vout->p_sys = NULL;
}
/*****************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment