Commit 885583cc authored by Gildas Bazin's avatar Gildas Bazin

* fixed a bug in the directx window creation function. We register a window
   class once per process so we must be careful not to free the associated
   resources.
parent 7adf5042
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_directx.c: Windows DirectX video output display method * vout_directx.c: Windows DirectX video output display method
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: vout_directx.c,v 1.33 2002/05/18 13:30:28 gbazin Exp $ * $Id: vout_directx.c,v 1.34 2002/05/18 15:34:04 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -1026,7 +1026,7 @@ static int NewPictureVec( vout_thread_t *p_vout, picture_t *p_pic, ...@@ -1026,7 +1026,7 @@ static int NewPictureVec( vout_thread_t *p_vout, picture_t *p_pic,
} }
else else
{ {
intf_ErrMsg( "vout error: can't create YUV overlay surface." ); intf_WarnMsg( 3, "vout: can't create an YUV overlay surface." );
p_vout->p_sys->b_using_overlay = 0; p_vout->p_sys->b_using_overlay = 0;
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_events.c: Windows DirectX video output events handler * vout_events.c: Windows DirectX video output events handler
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: vout_events.c,v 1.16 2002/05/18 13:30:28 gbazin Exp $ * $Id: vout_events.c,v 1.17 2002/05/18 15:34:04 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -287,12 +287,11 @@ static int DirectXCreateWindow( vout_thread_t *p_vout ) ...@@ -287,12 +287,11 @@ static int DirectXCreateWindow( vout_thread_t *p_vout )
ReleaseDC( p_vout->p_sys->hwnd, hdc ); ReleaseDC( p_vout->p_sys->hwnd, hdc );
/* Get the Icon from the main app */ /* Get the Icon from the main app */
vlc_icon = NULL;
if( GetModuleFileName( NULL, vlc_path, _MAX_PATH ) ) if( GetModuleFileName( NULL, vlc_path, _MAX_PATH ) )
{ {
vlc_icon = ExtractIcon( hInstance, vlc_path, 0 ); vlc_icon = ExtractIcon( hInstance, vlc_path, 0 );
} }
if( !vlc_icon )
vlc_icon = LoadIcon( NULL, IDI_APPLICATION );
/* fill in the window class structure */ /* fill in the window class structure */
...@@ -302,18 +301,29 @@ static int DirectXCreateWindow( vout_thread_t *p_vout ) ...@@ -302,18 +301,29 @@ static int DirectXCreateWindow( vout_thread_t *p_vout )
wc.cbClsExtra = 0; /* no extra class data */ wc.cbClsExtra = 0; /* no extra class data */
wc.cbWndExtra = 0; /* no extra window data */ wc.cbWndExtra = 0; /* no extra window data */
wc.hInstance = hInstance; /* instance */ wc.hInstance = hInstance; /* instance */
wc.hIcon = CopyIcon( vlc_icon ); /* load the vlc icon */ wc.hIcon = vlc_icon; /* load the vlc icon */
wc.hCursor = LoadCursor(NULL, IDC_ARROW); /* load a default cursor */ wc.hCursor = LoadCursor(NULL, IDC_ARROW); /* load a default cursor */
wc.hbrBackground = p_vout->p_sys->hbrush; /* background color */ wc.hbrBackground = p_vout->p_sys->hbrush; /* background color */
wc.lpszMenuName = NULL; /* no menu */ wc.lpszMenuName = NULL; /* no menu */
wc.lpszClassName = "VLC DirectX"; /* use a special class */ wc.lpszClassName = "VLC DirectX"; /* use a special class */
wc.hIconSm = CopyIcon( vlc_icon ); /* load the vlc icon */ wc.hIconSm = vlc_icon; /* load the vlc icon */
/* register the window class */ /* register the window class */
if (!RegisterClassEx(&wc)) if (!RegisterClassEx(&wc))
{ {
/* Check why it failed. If it's because one already exists then fine */
WNDCLASS wndclass; WNDCLASS wndclass;
/* free window background brush */
if( p_vout->p_sys->hbrush )
{
DeleteObject( p_vout->p_sys->hbrush );
p_vout->p_sys->hbrush = NULL;
}
if( vlc_icon )
DestroyIcon( vlc_icon );
/* Check why it failed. If it's because one already exists then fine */
if( !GetClassInfo( hInstance, "VLC DirectX", &wndclass ) ) if( !GetClassInfo( hInstance, "VLC DirectX", &wndclass ) )
{ {
intf_ErrMsg( "vout: DirectXCreateWindow RegisterClass FAILED" ); intf_ErrMsg( "vout: DirectXCreateWindow RegisterClass FAILED" );
...@@ -371,20 +381,13 @@ static void DirectXCloseWindow( vout_thread_t *p_vout ) ...@@ -371,20 +381,13 @@ static void DirectXCloseWindow( vout_thread_t *p_vout )
intf_WarnMsg( 3, "vout: DirectXCloseWindow" ); intf_WarnMsg( 3, "vout: DirectXCloseWindow" );
if( p_vout->p_sys->hwnd != NULL ) if( p_vout->p_sys->hwnd != NULL )
{ {
DestroyWindow( p_vout->p_sys->hwnd); DestroyWindow( p_vout->p_sys->hwnd );
p_vout->p_sys->hwnd = NULL; p_vout->p_sys->hwnd = NULL;
} }
/* We don't unregister the Window Class because it could lead to race /* We don't unregister the Window Class because it could lead to race
* conditions and it will be done anyway by the system when the app will * conditions and it will be done anyway by the system when the app will
* exit */ * exit */
/* free window background brush */
if( p_vout->p_sys->hbrush != NULL )
{
DeleteObject( p_vout->p_sys->hbrush );
p_vout->p_sys->hbrush = NULL;
}
} }
/***************************************************************************** /*****************************************************************************
...@@ -529,14 +532,6 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message, ...@@ -529,14 +532,6 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
return 0; return 0;
break; break;
/* the window has been closed so shut down everything now */
case WM_DESTROY:
intf_WarnMsg( 4, "vout: WinProc WM_DESTROY" );
/* just destroy the window */
PostQuitMessage( 0 );
return 0;
break;
case WM_SYSCOMMAND: case WM_SYSCOMMAND:
switch (wParam) switch (wParam)
{ {
......
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