Commit b95ba5d2 authored by Laurent Aimar's avatar Laurent Aimar

Made event_thread_t live as long as the vout.

The thread used by it can still be restarted, but it will allow to move
some variable from vout_sys_t to event_thread_t.
parent b3f43c1d
...@@ -97,7 +97,10 @@ int CommonInit( vout_thread_t *p_vout ) ...@@ -97,7 +97,10 @@ int CommonInit( vout_thread_t *p_vout )
p_sys->i_window_width = p_vout->i_window_width; p_sys->i_window_width = p_vout->i_window_width;
p_sys->i_window_height = p_vout->i_window_height; p_sys->i_window_height = p_vout->i_window_height;
if( !CreateEventThread( p_vout ) ) p_sys->p_event = EventThreadCreate( p_vout );
if( !p_sys->p_event )
return VLC_EGENERIC;
if( EventThreadStart( p_sys->p_event ) )
return VLC_EGENERIC; return VLC_EGENERIC;
/* Variable to indicate if the window should be on top of others */ /* Variable to indicate if the window should be on top of others */
...@@ -116,8 +119,16 @@ int CommonInit( vout_thread_t *p_vout ) ...@@ -116,8 +119,16 @@ int CommonInit( vout_thread_t *p_vout )
/* */ /* */
void CommonClean( vout_thread_t *p_vout ) void CommonClean( vout_thread_t *p_vout )
{ {
StopEventThread( p_vout ); vout_sys_t *p_sys = p_vout->p_sys;
vlc_mutex_destroy( &p_vout->p_sys->lock );
ExitFullscreen( p_vout );
if( p_sys->p_event )
{
EventThreadStop( p_sys->p_event );
EventThreadDestroy( p_sys->p_event );
}
vlc_mutex_destroy( &p_sys->lock );
#if !defined(UNDER_CE) && !defined(MODULE_NAME_IS_glwin32) #if !defined(UNDER_CE) && !defined(MODULE_NAME_IS_glwin32)
RestoreScreensaver( p_vout ); RestoreScreensaver( p_vout );
...@@ -412,6 +423,17 @@ static int ControlParentWindow( vout_thread_t *p_vout, int i_query, ... ) ...@@ -412,6 +423,17 @@ static int ControlParentWindow( vout_thread_t *p_vout, int i_query, ... )
} }
#endif #endif
void ExitFullscreen( vout_thread_t *p_vout )
{
if( p_vout->b_fullscreen )
{
msg_Dbg( p_vout, "Quitting fullscreen" );
Win32ToggleFullscreen( p_vout );
/* Force fullscreen in the core for the next video */
var_SetBool( p_vout, "fullscreen", true );
}
}
void Win32ToggleFullscreen( vout_thread_t *p_vout ) void Win32ToggleFullscreen( vout_thread_t *p_vout )
{ {
HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ? HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ?
......
...@@ -365,14 +365,17 @@ static int Manage( vout_thread_t *p_vout ) ...@@ -365,14 +365,17 @@ static int Manage( vout_thread_t *p_vout )
{ {
/* Close the direct3d instance attached to the current output window. */ /* Close the direct3d instance attached to the current output window. */
End( p_vout ); End( p_vout );
StopEventThread( p_vout );
ExitFullscreen( p_vout );
EventThreadStop( p_vout->p_sys->p_event );
/* Open the direct3d output and attaches it to the new window */ /* Open the direct3d output and attaches it to the new window */
p_vout->p_sys->b_desktop = !p_vout->p_sys->b_desktop; p_vout->p_sys->b_desktop = !p_vout->p_sys->b_desktop;
p_vout->pf_display = FirstDisplay; p_vout->pf_display = FirstDisplay;
vlc_mutex_init( &p_vout->p_sys->lock );
CreateEventThread( p_vout ); EventThreadStart( p_vout->p_sys->p_event );
Init( p_vout ); Init( p_vout );
/* Reset the flag */ /* Reset the flag */
......
...@@ -895,7 +895,7 @@ static int DirectXConvertKey( int i_key ) ...@@ -895,7 +895,7 @@ static int DirectXConvertKey( int i_key )
return 0; return 0;
} }
static event_thread_t *EventThreadCreate( vout_thread_t *p_vout ) event_thread_t *EventThreadCreate( vout_thread_t *p_vout )
{ {
/* Create the Vout EventThread, this thread is created by us to isolate /* Create the Vout EventThread, this thread is created by us to isolate
* the Win32 PeekMessage function calls. We want to do this because * the Win32 PeekMessage function calls. We want to do this because
...@@ -916,14 +916,14 @@ static event_thread_t *EventThreadCreate( vout_thread_t *p_vout ) ...@@ -916,14 +916,14 @@ static event_thread_t *EventThreadCreate( vout_thread_t *p_vout )
return p_event; return p_event;
} }
static void EventThreadDestroy( event_thread_t *p_event ) void EventThreadDestroy( event_thread_t *p_event )
{ {
vlc_cond_destroy( &p_event->wait ); vlc_cond_destroy( &p_event->wait );
vlc_mutex_destroy( &p_event->lock ); vlc_mutex_destroy( &p_event->lock );
free( p_event ); free( p_event );
} }
static int EventThreadStart( event_thread_t *p_event ) int EventThreadStart( event_thread_t *p_event )
{ {
p_event->b_ready = false; p_event->b_ready = false;
p_event->b_done = false; p_event->b_done = false;
...@@ -952,7 +952,7 @@ static int EventThreadStart( event_thread_t *p_event ) ...@@ -952,7 +952,7 @@ static int EventThreadStart( event_thread_t *p_event )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static void EventThreadStop( event_thread_t *p_event ) void EventThreadStop( event_thread_t *p_event )
{ {
if( !p_event->b_ready ) if( !p_event->b_ready )
return; return;
...@@ -973,35 +973,3 @@ static void EventThreadStop( event_thread_t *p_event ) ...@@ -973,35 +973,3 @@ static void EventThreadStop( event_thread_t *p_event )
p_event->p_vout->p_sys->i_changes = 0; p_event->p_vout->p_sys->i_changes = 0;
} }
/* */
int CreateEventThread( vout_thread_t *p_vout )
{
event_thread_t *p_event =
p_vout->p_sys->p_event = EventThreadCreate( p_vout );
if( !p_event )
return 0;
if( EventThreadStart( p_event ) )
return 0;
return 1;
}
void StopEventThread( vout_thread_t *p_vout )
{
if( p_vout->b_fullscreen )
{
msg_Dbg( p_vout, "Quitting fullscreen" );
Win32ToggleFullscreen( p_vout );
/* Force fullscreen in the core for the next video */
var_SetBool( p_vout, "fullscreen", true );
}
event_thread_t *p_event = p_vout->p_sys->p_event;
if( p_event )
{
EventThreadStop( p_event );
EventThreadDestroy( p_event );
p_vout->p_sys->p_event = NULL;
}
}
...@@ -261,8 +261,10 @@ int DirectDrawUpdateOverlay( vout_thread_t *p_vout ); ...@@ -261,8 +261,10 @@ int DirectDrawUpdateOverlay( vout_thread_t *p_vout );
/***************************************************************************** /*****************************************************************************
* Prototypes from events.c * Prototypes from events.c
*****************************************************************************/ *****************************************************************************/
int CreateEventThread( vout_thread_t *p_vout ); event_thread_t *EventThreadCreate( vout_thread_t * );
void StopEventThread ( vout_thread_t *p_vout ); void EventThreadDestroy( event_thread_t * );
int EventThreadStart( event_thread_t * );
void EventThreadStop( event_thread_t * );
/***************************************************************************** /*****************************************************************************
* Prototypes from common.c * Prototypes from common.c
...@@ -274,6 +276,7 @@ int Control( vout_thread_t *p_vout, int i_query, va_list args ); ...@@ -274,6 +276,7 @@ int Control( vout_thread_t *p_vout, int i_query, va_list args );
void UpdateRects ( vout_thread_t *p_vout, bool b_force ); void UpdateRects ( vout_thread_t *p_vout, bool b_force );
void Win32ToggleFullscreen ( vout_thread_t *p_vout ); void Win32ToggleFullscreen ( vout_thread_t *p_vout );
void ExitFullscreen( vout_thread_t *p_vout );
#ifndef UNDER_CE #ifndef UNDER_CE
void DisableScreensaver ( vout_thread_t *p_vout ); void DisableScreensaver ( vout_thread_t *p_vout );
void RestoreScreensaver ( vout_thread_t *p_vout ); void RestoreScreensaver ( vout_thread_t *p_vout );
......
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