embedded snapshot: guard against spurious vlc_object_wait wakeups.
authorOlivier Aubert <olivier.aubert@liris.cnrs.fr>
Mon, 8 Sep 2008 16:31:27 +0000 (18:31 +0200)
committerOlivier Aubert <olivier.aubert@liris.cnrs.fr>
Mon, 8 Sep 2008 16:31:27 +0000 (18:31 +0200)
Thanks courmisch for noticing this.
It still uses the old, and soon to be deprecated I imagine, vlc_object_wait API, but well, we cannot go faster than the music, can we?

src/control/mediacontrol_audio_video.c
src/video_output/vout_intf.c

index 3552098..e0a6f7c 100644 (file)
@@ -88,18 +88,9 @@ mediacontrol_snapshot( mediacontrol_Instance *self,
     var_SetString( p_vout, "snapshot-path", path );
     var_SetString( p_vout, "snapshot-format", "png" );
 
-    
     vlc_object_lock( p_cache );
-    /* Initialize p_cache->p_private with p_cache own value, to be
-       used as a sentinel against spurious vlc_object_wait wakeups.
-
-       If a legitimate wakeup occurs, then p_cache->p_private will hold either
-       NULL (in case of error) or a pointer to a p_snapshot data structure.
-    */
-    p_cache->p_private = p_cache;
     vout_Control( p_vout, VOUT_SNAPSHOT );
-    while ( p_cache->p_private == p_cache )
-        vlc_object_wait( p_cache );
+    vlc_object_wait( p_cache );
     vlc_object_release( p_vout );
 
     p_snapshot = ( snapshot_t* ) p_cache->p_private;
index 15fddce..332c834 100644 (file)
@@ -632,17 +632,16 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
         snapshot_t *p_snapshot;
         size_t i_size;
 
-        /* Object must be locked by the caller function. We will
-           unlock it once we get the snapshot and have written it to
-           p_cache->p_private. */
-       
+        /* Object must be locked. We will unlock it once we get the
+           snapshot and written it to p_private */
+        p_dest->p_private = NULL;
+
         /* Save the snapshot to a memory zone */
         p_block = image_Write( p_image, p_pic, &fmt_in, &fmt_out );
         if( !p_block )
         {
             msg_Err( p_vout, "Could not get snapshot" );
             image_HandlerDelete( p_image );
-           p_dest->p_private = NULL;
             vlc_object_signal_unlocked( p_dest );
             vlc_object_release( p_dest );
             return VLC_EGENERIC;
@@ -655,7 +654,6 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
         {
             block_Release( p_block );
             image_HandlerDelete( p_image );
-           p_dest->p_private = NULL;
             vlc_object_signal_unlocked( p_dest );
             vlc_object_release( p_dest );
             return VLC_ENOMEM;
@@ -673,7 +671,6 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
             block_Release( p_block );
             free( p_snapshot );
             image_HandlerDelete( p_image );
-           p_dest->p_private = NULL;
             vlc_object_signal_unlocked( p_dest );
             vlc_object_release( p_dest );
             return VLC_ENOMEM;