[vlc-devel] [PATCH] input: Fix race condition on input item titles
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Mon Aug 28 10:26:42 CEST 2017
Fix #18727
---
src/input/input.c | 30 +++++++++++++++++++++---------
1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/src/input/input.c b/src/input/input.c
index ae5fe03f81..e6eb5c88ee 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -2269,7 +2269,20 @@ static void UpdateGenericFromDemux( input_thread_t *p_input )
static void UpdateTitleListfromDemux( input_thread_t *p_input )
{
- input_source_t *in = input_priv(p_input)->master;
+ input_thread_private_t *priv = input_priv(p_input);
+ input_source_t *in = priv->master;
+
+ input_title_t **pp_title = NULL;
+ int i_title = 0;
+ int i_offset = 0;
+ int i_seekpoint_offset = 0;
+
+ /* Get the new title list */
+ if( demux_Control( in->p_demux, DEMUX_GET_TITLE_INFO, &pp_title, &i_title,
+ &i_offset, &i_seekpoint_offset ) != VLC_SUCCESS )
+ return;
+
+ vlc_mutex_lock( &priv->p_item->lock );
/* Delete the preexisting titles */
if( in->i_title > 0 )
@@ -2277,16 +2290,15 @@ static void UpdateTitleListfromDemux( input_thread_t *p_input )
for( int i = 0; i < in->i_title; i++ )
vlc_input_title_Delete( in->title[i] );
TAB_CLEAN( in->i_title, in->title );
- in->b_title_demux = false;
}
- /* Get the new title list */
- if( demux_Control( in->p_demux, DEMUX_GET_TITLE_INFO,
- &in->title, &in->i_title,
- &in->i_title_offset, &in->i_seekpoint_offset ) )
- TAB_INIT( in->i_title, in->title );
- else
- in->b_title_demux = true;
+ in->b_title_demux = true;
+ in->title = pp_title;
+ in->i_title = i_title;
+ in->i_title_offset = i_offset;
+ in->i_seekpoint_offset = i_seekpoint_offset;
+
+ vlc_mutex_unlock( &priv->p_item->lock );
InitTitle( p_input );
}
--
2.11.0
More information about the vlc-devel
mailing list