Commit 22599f01 authored by Rémi Duraffort's avatar Rémi Duraffort

add mutex to the sdl video_output

parent 5388d5c1
...@@ -69,6 +69,8 @@ struct vout_sys_t ...@@ -69,6 +69,8 @@ struct vout_sys_t
vlc_bool_t b_cursor_autohidden; vlc_bool_t b_cursor_autohidden;
mtime_t i_lastmoved; mtime_t i_lastmoved;
mtime_t i_lastpressed; /* to track dbl-clicks */ mtime_t i_lastpressed; /* to track dbl-clicks */
vlc_mutex_t lock;
}; };
/***************************************************************************** /*****************************************************************************
...@@ -151,6 +153,9 @@ static int Open ( vlc_object_t *p_this ) ...@@ -151,6 +153,9 @@ static int Open ( vlc_object_t *p_this )
return VLC_ENOMEM; return VLC_ENOMEM;
} }
vlc_mutex_init( p_vout, &p_vout->p_sys->lock );
/* Check if SDL video module has been initialized */
if( SDL_WasInit( SDL_INIT_VIDEO ) != 0 ) if( SDL_WasInit( SDL_INIT_VIDEO ) != 0 )
{ {
vlc_mutex_unlock( lock ); vlc_mutex_unlock( lock );
...@@ -159,7 +164,6 @@ static int Open ( vlc_object_t *p_this ) ...@@ -159,7 +164,6 @@ static int Open ( vlc_object_t *p_this )
} }
/* Allocate structure */ /* Allocate structure */
p_vout->pf_init = Init; p_vout->pf_init = Init;
p_vout->pf_end = End; p_vout->pf_end = End;
p_vout->pf_manage = Manage; p_vout->pf_manage = Manage;
...@@ -326,6 +330,8 @@ static void Close ( vlc_object_t *p_this ) ...@@ -326,6 +330,8 @@ static void Close ( vlc_object_t *p_this )
CloseDisplay( p_vout ); CloseDisplay( p_vout );
SDL_QuitSubSystem( SDL_INIT_VIDEO ); SDL_QuitSubSystem( SDL_INIT_VIDEO );
vlc_mutex_destroy( &p_vout->p_sys->lock );
free( p_vout->p_sys ); free( p_vout->p_sys );
} }
...@@ -341,6 +347,8 @@ static int Manage( vout_thread_t *p_vout ) ...@@ -341,6 +347,8 @@ static int Manage( vout_thread_t *p_vout )
vlc_value_t val; vlc_value_t val;
unsigned int i_width, i_height, i_x, i_y; unsigned int i_width, i_height, i_x, i_y;
vlc_mutex_lock( &p_vout->p_sys->lock );
/* Process events */ /* Process events */
while( SDL_PollEvent( &event ) ) while( SDL_PollEvent( &event ) )
{ {
...@@ -588,6 +596,8 @@ static int Manage( vout_thread_t *p_vout ) ...@@ -588,6 +596,8 @@ static int Manage( vout_thread_t *p_vout )
SDL_ShowCursor( 0 ); SDL_ShowCursor( 0 );
} }
vlc_mutex_unlock( &p_vout->p_sys->lock );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -667,6 +677,8 @@ static void Display( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -667,6 +677,8 @@ static void Display( vout_thread_t *p_vout, picture_t *p_pic )
unsigned int x, y, w, h; unsigned int x, y, w, h;
SDL_Rect disp; SDL_Rect disp;
vlc_mutex_lock( &p_vout->p_sys->lock );
vout_PlacePicture( p_vout, p_vout->p_sys->i_width, p_vout->p_sys->i_height, vout_PlacePicture( p_vout, p_vout->p_sys->i_width, p_vout->p_sys->i_height,
&x, &y, &w, &h ); &x, &y, &w, &h );
disp.x = x; disp.x = x;
...@@ -686,6 +698,8 @@ static void Display( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -686,6 +698,8 @@ static void Display( vout_thread_t *p_vout, picture_t *p_pic )
SDL_DisplayYUVOverlay( p_pic->p_sys->p_overlay , &disp ); SDL_DisplayYUVOverlay( p_pic->p_sys->p_overlay , &disp );
SDL_LockYUVOverlay( p_pic->p_sys->p_overlay); SDL_LockYUVOverlay( p_pic->p_sys->p_overlay);
} }
vlc_mutex_unlock( &p_vout->p_sys->lock );
} }
/* following functions are local */ /* following functions are local */
......
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