]> git.sesse.net Git - vlc/commitdiff
Almost wait-free snapshot handling in the vout thread
authorRémi Denis-Courmont <remi@remlab.net>
Tue, 10 Mar 2009 20:44:23 +0000 (22:44 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Wed, 11 Mar 2009 19:52:59 +0000 (21:52 +0200)
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.

src/video_output/video_output.c

index 27aad5424d228e16b5f03321e7bef8ee0d343df0..eeeb8c7e3a63aea547d759d4236c87fd6be12a6b 100644 (file)
@@ -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