[vlc-devel] commit: Almost wait-free snapshot handling in the vout thread ( Rémi Denis-Courmont )
git version control
git at videolan.org
Wed Mar 11 20:55:50 CET 2009
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Mar 10 22:44:23 2009 +0200| [8610a92bc466ae368ad9a078650c5397e52c90bc] | committer: Rémi Denis-Courmont
Almost wait-free snapshot handling in the vout thread
Using vlc_mutex_trylock(), we make sure that the video output thread
will not yield because of an incomplete snapshot request. It can still
yield in the very unlikely case that a thread is doing a snapshot
request while the video output thread finishes sorting SPUs _and_ there
already was a pending snapshot earlier.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8610a92bc466ae368ad9a078650c5397e52c90bc
---
src/video_output/video_output.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 27aad54..eeeb8c7 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 ) == 0 )
+ {
+ 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
More information about the vlc-devel
mailing list