[vlc-commits] input: replace vlc_object_alive() with a dedicated getter
Rémi Denis-Courmont
git at videolan.org
Sun Jun 7 21:43:50 CEST 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jun 7 22:40:43 2015 +0300| [6563f89cc337882bd0d32459316c4d018ac1630e] | committer: Rémi Denis-Courmont
input: replace vlc_object_alive() with a dedicated getter
This is interlocked with the control queue as it most probably should.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6563f89cc337882bd0d32459316c4d018ac1630e
---
src/input/es_out.c | 6 ++++--
src/input/input.c | 44 +++++++++++++++++++++++++-------------------
src/input/input_internal.h | 2 ++
3 files changed, 31 insertions(+), 21 deletions(-)
diff --git a/src/input/es_out.c b/src/input/es_out.c
index ec7d655..3756b14 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -2036,8 +2036,10 @@ static void EsOutDel( es_out_t *out, es_out_id_t *es )
/* We don't try to reselect */
if( es->p_dec )
- {
- while( vlc_object_alive(p_sys->p_input) && !p_sys->b_buffering )
+ { /* FIXME: This might hold the ES output caller (i.e. the demux), and
+ * the corresponding thread (typically the input thread), for a little
+ * bit too long if the ES is deleted in the middle of a stream. */
+ while( !input_Stopped(p_sys->p_input) && !p_sys->b_buffering )
{
if( input_DecoderIsEmpty( es->p_dec ) &&
( !es->p_dec_record || input_DecoderIsEmpty( es->p_dec_record ) ))
diff --git a/src/input/input.c b/src/input/input.c
index 9fa344e..a1a9032 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -548,6 +548,17 @@ static void *Run( void *obj )
return NULL;
}
+bool input_Stopped( input_thread_t *input )
+{
+ input_thread_private_t *sys = input->p;
+ bool ret;
+
+ vlc_mutex_lock( &sys->lock_control );
+ ret = sys->is_stopped;
+ vlc_mutex_unlock( &sys->lock_control );
+ return ret;
+}
+
/*****************************************************************************
* Main loop: Fill buffers from access, and demux
*****************************************************************************/
@@ -698,7 +709,7 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
bool b_pause_after_eof = b_interactive &&
var_InheritBool( p_input, "play-and-pause" );
- while( vlc_object_alive( p_input ) && p_input->p->i_state != ERROR_S )
+ while( !input_Stopped( p_input ) && p_input->p->i_state != ERROR_S )
{
mtime_t i_wakeup = -1;
bool b_paused = p_input->p->i_state == PAUSE_S;
@@ -2247,14 +2258,11 @@ static int InputSourceInit( input_thread_t *p_input,
psz_access, psz_demux, psz_path );
if( p_access == NULL )
{
- if( vlc_object_alive( p_input ) )
- {
- msg_Err( p_input, "open of `%s' failed", psz_mrl );
- if( !b_in_can_fail )
- dialog_Fatal( p_input, _("Your input can't be opened"),
- _("VLC is unable to open the MRL '%s'."
- " Check the log for details."), psz_mrl );
- }
+ msg_Err( p_input, "open of `%s' failed", psz_mrl );
+ if( !b_in_can_fail && !input_Stopped( p_input ) )
+ dialog_Fatal( p_input, _("Your input can't be opened"),
+ _("VLC is unable to open the MRL '%s'."
+ " Check the log for details."), psz_mrl );
goto error;
}
@@ -2358,16 +2366,14 @@ static int InputSourceInit( input_thread_t *p_input,
if( in->p_demux == NULL )
{
- if( vlc_object_alive( p_input ) )
- {
- msg_Err( p_input, "no suitable demux module for `%s/%s://%s'",
- psz_access, psz_demux, psz_path );
- if( !b_in_can_fail )
- dialog_Fatal( VLC_OBJECT( p_input ),
- _("VLC can't recognize the input's format"),
- _("The format of '%s' cannot be detected. "
- "Have a look at the log for details."), psz_mrl );
- }
+ msg_Err( p_input, "no suitable demux module for `%s/%s://%s'",
+ psz_access, psz_demux, psz_path );
+ if( !b_in_can_fail && !input_Stopped( p_input ) )
+ dialog_Fatal( VLC_OBJECT( p_input ),
+ _("VLC can't recognize the input's format"),
+ _("The format of '%s' cannot be detected. "
+ "Have a look at the log for details."),
+ psz_mrl );
stream_Delete( p_stream );
goto error;
}
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index e49f295..f1a242a 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -219,6 +219,8 @@ enum input_control_e
*/
void input_ControlPush( input_thread_t *, int i_type, vlc_value_t * );
+bool input_Stopped( input_thread_t * );
+
/* Bound pts_delay */
#define INPUT_PTS_DELAY_MAX INT64_C(60000000)
More information about the vlc-commits
mailing list