[vlc-devel] [PATCH 2/2] Wait-free snapshot handling in the vout thread
Rémi Denis-Courmont
remi at remlab.net
Tue Mar 10 21:46:58 CET 2009
Using vlc_mutex_trylock(), we make sure that the video output thread
will not yield because of an incomplete snapshot request.
---
src/video_output/video_output.c | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 27aad54..e12e033 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1191,11 +1191,13 @@ static void* RunThread( void *p_this )
p_filtered_picture = filter_chain_VideoFilter( p_vout->p->p_vf2_chain,
p_picture );
- /* FIXME it is ugly that b_snapshot is not locked but I do not
- * know which lock to use (here and in the snapshot callback) */
- vlc_mutex_lock( &p_vout->p->snapshot.lock );
- const bool b_snapshot = p_vout->p->snapshot.i_request > 0 && p_picture != NULL;
- vlc_mutex_unlock( &p_vout->p->snapshot.lock );
+ bool b_snapshot = false;
+ if( vlc_mutex_trylock( &p_vout->p->snapshot.lock ) )
+ {
+ b_snapshot = p_vout->p->snapshot.i_request > 0
+ && p_picture != NULL;
+ vlc_mutex_unlock( &p_vout->p->snapshot.lock );
+ }
/*
* Check for subpictures to display
@@ -1215,9 +1217,9 @@ static void* RunThread( void *p_this )
/*
* Take a snapshot if requested
*/
- if( p_directbuffer && b_snapshot )
+ if( p_directbuffer && b_snapshot
+ && vlc_mutex_trylock( &p_vout->p->snapshot.lock ) )
{
- vlc_mutex_lock( &p_vout->p->snapshot.lock );
assert( p_vout->p->snapshot.i_request > 0 );
while( p_vout->p->snapshot.i_request > 0 )
{
--
1.6.2
More information about the vlc-devel
mailing list