[vlc-devel] [PATCH] input: fix non thread safe titles update (#21363)
Francois Cartegnie
fcvlcdev at free.fr
Tue Oct 23 11:52:57 CEST 2018
race with INPUT_GET_FULL_TITLE_INFO
---
src/input/input.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/input/input.c b/src/input/input.c
index 57e029ebb3..f659c77d20 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -885,7 +885,8 @@ static int InitSout( input_thread_t * p_input )
}
#endif
-static void InitTitle( input_thread_t * p_input, bool had_titles )
+static void InitTitle( input_thread_t * p_input, bool had_titles,
+ bool b_with_lock )
{
input_thread_private_t *priv = input_priv(p_input);
input_source_t *p_master = priv->master;
@@ -893,7 +894,8 @@ static void InitTitle( input_thread_t * p_input, bool had_titles )
if( priv->b_preparsing )
return;
- vlc_mutex_lock( &priv->p_item->lock );
+ if(b_with_lock)
+ vlc_mutex_lock( &priv->p_item->lock );
/* Create global title (from master) */
priv->i_title = p_master->i_title;
priv->title = p_master->title;
@@ -904,7 +906,8 @@ static void InitTitle( input_thread_t * p_input, bool had_titles )
priv->b_can_pace_control = p_master->b_can_pace_control;
priv->b_can_pause = p_master->b_can_pause;
priv->b_can_rate_control = p_master->b_can_rate_control;
- vlc_mutex_unlock( &priv->p_item->lock );
+ if(b_with_lock)
+ vlc_mutex_unlock( &priv->p_item->lock );
/* Send event only if the count is valid or if titles are gone */
if (had_titles || p_master->i_title > 0)
@@ -1358,7 +1361,7 @@ static int Init( input_thread_t * p_input )
goto error;
priv->master = master;
- InitTitle( p_input, false );
+ InitTitle( p_input, false, true );
/* Load master infos */
/* Init length */
@@ -2452,6 +2455,7 @@ static void UpdateTitleListfromDemux( input_thread_t *p_input )
/* Delete the preexisting titles */
bool had_titles = false;
+ vlc_mutex_lock( &priv->p_item->lock );
if( in->i_title > 0 )
{
had_titles = true;
@@ -2471,7 +2475,9 @@ static void UpdateTitleListfromDemux( input_thread_t *p_input )
else
in->b_title_demux = true;
- InitTitle( p_input, had_titles );
+ InitTitle( p_input, had_titles, false );
+
+ vlc_mutex_unlock( &priv->p_item->lock );
}
static int
--
2.17.2
More information about the vlc-devel
mailing list