[vlc-commits] input: hook an interruption context to stop the input

Rémi Denis-Courmont git at videolan.org
Wed Jul 1 18:22:09 CEST 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jun 30 23:52:51 2015 +0300| [e709ac0c528c0c7478c9876f4b919a903e2656ad] | committer: Rémi Denis-Courmont

input: hook an interruption context to stop the input

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e709ac0c528c0c7478c9876f4b919a903e2656ad
---

 src/input/input.c          |    7 +++++++
 src/input/input_internal.h |    2 ++
 2 files changed, 9 insertions(+)

diff --git a/src/input/input.c b/src/input/input.c
index da88e50..3e021a8 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -236,6 +236,9 @@ void input_Stop( input_thread_t *p_input )
     sys->is_stopped = true;
     vlc_cond_signal( &sys->wait_control );
     vlc_mutex_unlock( &sys->lock_control );
+    /* Interrupt access/stream/demux/etc *after* the input is stopped.
+     * Otherwise the interruption could be mistreated as a spurious wake-up. */
+    vlc_interrupt_raise( &sys->interrupt );
 }
 
 /**
@@ -247,6 +250,7 @@ void input_Close( input_thread_t *p_input )
 {
     if( p_input->p->is_running )
         vlc_join( p_input->p->thread, NULL );
+    vlc_interrupt_deinit( &p_input->p->interrupt );
     vlc_object_release( p_input );
 }
 
@@ -419,6 +423,7 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
     vlc_mutex_init( &p_input->p->lock_control );
     vlc_cond_init( &p_input->p->wait_control );
     p_input->p->i_control = 0;
+    vlc_interrupt_init(&p_input->p->interrupt);
 
     /* Create Object Variables for private use only */
     input_ConfigVarInit( p_input );
@@ -512,6 +517,8 @@ static void *Run( void *obj )
 {
     input_thread_t *p_input = (input_thread_t *)obj;
 
+    vlc_interrupt_set(&p_input->p->interrupt);
+
     if( !Init( p_input ) )
     {
         MainLoop( p_input, true ); /* FIXME it can be wrong (like with VLM) */
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index f1a242a..cf27ff3 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -29,6 +29,7 @@
 #include <vlc_input.h>
 #include <libvlc.h>
 #include "input_interface.h"
+#include "misc/interrupt.h"
 
 /*****************************************************************************
  *  Private input fields
@@ -164,6 +165,7 @@ struct input_thread_private_t
     input_control_t control[INPUT_CONTROL_FIFO_SIZE];
 
     vlc_thread_t thread;
+    vlc_interrupt_t interrupt;
 };
 
 /***************************************************************************



More information about the vlc-commits mailing list