[vlc-devel] commit: Made event_thread_t live as long as the vout. (Laurent Aimar )

git version control git at videolan.org
Mon Sep 14 20:20:04 CEST 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Wed Sep  9 22:36:16 2009 +0200| [b95ba5d21d897ef795365b5c91083191a31c06a4] | committer: 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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b95ba5d21d897ef795365b5c91083191a31c06a4
---

 modules/video_output/msw/common.c   |   28 +++++++++++++++++++++--
 modules/video_output/msw/direct3d.c |    9 +++++--
 modules/video_output/msw/events.c   |   40 +++-------------------------------
 modules/video_output/msw/vout.h     |    7 ++++-
 4 files changed, 40 insertions(+), 44 deletions(-)

diff --git a/modules/video_output/msw/common.c b/modules/video_output/msw/common.c
index 3a83e72..eefcae9 100644
--- a/modules/video_output/msw/common.c
+++ b/modules/video_output/msw/common.c
@@ -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_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;
 
     /* Variable to indicate if the window should be on top of others */
@@ -116,8 +119,16 @@ int CommonInit( vout_thread_t *p_vout )
 /* */
 void CommonClean( vout_thread_t *p_vout )
 {
-    StopEventThread( p_vout );
-    vlc_mutex_destroy( &p_vout->p_sys->lock );
+    vout_sys_t *p_sys = p_vout->p_sys;
+
+    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)
     RestoreScreensaver( p_vout );
@@ -412,6 +423,17 @@ static int ControlParentWindow( vout_thread_t *p_vout, int i_query, ... )
 }
 #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 )
 {
     HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ?
diff --git a/modules/video_output/msw/direct3d.c b/modules/video_output/msw/direct3d.c
index 50a8df6..0abb633 100644
--- a/modules/video_output/msw/direct3d.c
+++ b/modules/video_output/msw/direct3d.c
@@ -365,14 +365,17 @@ static int Manage( vout_thread_t *p_vout )
     {
         /* Close the direct3d instance attached to the current output window. */
         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 */
         p_vout->p_sys->b_desktop = !p_vout->p_sys->b_desktop;
         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 );
 
         /* Reset the flag */
diff --git a/modules/video_output/msw/events.c b/modules/video_output/msw/events.c
index af2dc9b..774cc94 100644
--- a/modules/video_output/msw/events.c
+++ b/modules/video_output/msw/events.c
@@ -895,7 +895,7 @@ static int DirectXConvertKey( int i_key )
     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
      * 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 )
     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_mutex_destroy( &p_event->lock );
     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_done  = false;
@@ -952,7 +952,7 @@ static int EventThreadStart( event_thread_t *p_event )
     return VLC_SUCCESS;
 }
 
-static void EventThreadStop( event_thread_t *p_event )
+void EventThreadStop( event_thread_t *p_event )
 {
     if( !p_event->b_ready )
         return;
@@ -973,35 +973,3 @@ static void EventThreadStop( event_thread_t *p_event )
     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;
-    }
-}
-
diff --git a/modules/video_output/msw/vout.h b/modules/video_output/msw/vout.h
index 2ed551b..d01fde0 100644
--- a/modules/video_output/msw/vout.h
+++ b/modules/video_output/msw/vout.h
@@ -261,8 +261,10 @@ int DirectDrawUpdateOverlay( vout_thread_t *p_vout );
 /*****************************************************************************
  * Prototypes from events.c
  *****************************************************************************/
-int CreateEventThread( vout_thread_t *p_vout );
-void StopEventThread ( vout_thread_t *p_vout );
+event_thread_t *EventThreadCreate( vout_thread_t * );
+void            EventThreadDestroy( event_thread_t * );
+int             EventThreadStart( event_thread_t * );
+void            EventThreadStop( event_thread_t * );
 
 /*****************************************************************************
  * Prototypes from common.c
@@ -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 Win32ToggleFullscreen ( vout_thread_t *p_vout );
+void ExitFullscreen( vout_thread_t *p_vout );
 #ifndef UNDER_CE
 void DisableScreensaver ( vout_thread_t *p_vout );
 void RestoreScreensaver ( vout_thread_t *p_vout );




More information about the vlc-devel mailing list