]> git.sesse.net Git - vlc/commitdiff
vlm: Avoid a deadlock when stoping the input.
authorPierre d'Herbemont <pdherbemont@free.fr>
Thu, 11 Feb 2010 17:11:24 +0000 (18:11 +0100)
committerPierre d'Herbemont <pdherbemont@free.fr>
Thu, 11 Feb 2010 18:56:42 +0000 (19:56 +0100)
We may be joining the input_thread inside the vlm lock, and try to vlm lock inside the stop event handler.

src/input/vlm.c

index fc63d217fbfd58b89c18abfdc15da2e321cde233..19f2a5635b677cb473f16fd99cf0650c203f5d6f 100644 (file)
@@ -105,6 +105,16 @@ static int InputEvent( vlc_object_t *p_this, char const *psz_cmd,
         }
         vlm_SendEventMediaInstanceState( p_vlm, p_media->cfg.id, p_media->cfg.psz_name, psz_instance_name, var_GetInteger( p_input, "state" ) );
 
+        // We have ourselves been triggering the stop event.
+        // No need to wake up our manage thread, because
+        // we'll join it just after the Stop().
+        vlc_mutex_lock( &p_input->p->lock_control );
+        bool abort = p_input->p->b_abort;
+        vlc_mutex_unlock( &p_input->p->lock_control );
+
+        if (abort)
+            return VLC_SUCCESS;
+
         vlc_mutex_lock( &p_vlm->lock );
         vlc_cond_signal( &p_vlm->wait );
         vlc_mutex_unlock( &p_vlm->lock );
@@ -609,7 +619,7 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media )
                 var_DelCallback( p_input, "intf-event", InputEventPreparse, &sem_preparse );
                 vlc_sem_destroy( &sem_preparse );
 
-                input_Stop( p_input, false );
+                input_Stop( p_input, true );
                 vlc_thread_join( p_input );
                 vlc_object_release( p_input );
             }
@@ -938,7 +948,7 @@ static int vlm_ControlMediaInstanceStart( vlm_t *p_vlm, int64_t id, const char *
             return VLC_SUCCESS;
         }
 
-        input_Stop( p_input, !p_input->b_eof && !p_input->b_error );
+        input_Stop( p_input, true );
         vlc_thread_join( p_input );
 
         p_instance->p_input_resource = input_DetachResource( p_input );