input: remove input_LegacyVarStop
authorThomas Guillem <thomas@gllm.fr>
Thu, 12 Jul 2018 16:27:33 +0000 (18:27 +0200)
committerThomas Guillem <thomas@gllm.fr>
Thu, 12 Jul 2018 16:48:44 +0000 (18:48 +0200)
This code path is way too racy (even before
2ef7696e96f5c55a4801335820c79df7f1a52fd0): input_priv(p_input)->i_title is not
protected and the variables were not cleaned if i_title changed from 1 to 0.

This function was useless anyway since it was always called before
input_Close() that destroyed the input thread object and all variables /
callbacks.

include/vlc_input.h
lib/media_player.c
modules/services_discovery/podcast.c
src/input/var.c
src/input/vlm.c
src/libvlccore.sym
src/playlist/thread.c

index 2efbbd9..623fad3 100644 (file)
@@ -575,7 +575,6 @@ VLC_API void input_SetPosition( input_thread_t *, float f_position, bool b_fast
 
 VLC_API void input_LegacyEvents(input_thread_t *, void *, const struct vlc_input_event * );
 VLC_API void input_LegacyVarInit ( input_thread_t * );
-VLC_API void input_LegacyVarStop( input_thread_t * );
 
 /**
  * Get the input item for an input thread
index 9173486..270d3b8 100644 (file)
@@ -179,7 +179,6 @@ static void release_input_thread( libvlc_media_player_t *p_mi )
     var_DelCallback( p_input_thread, "intf-event",
                      input_event_changed, p_mi );
     del_es_callbacks( p_input_thread, p_mi );
-    input_LegacyVarStop( p_input_thread );
 
     /* We owned this one */
     input_Stop( p_input_thread );
@@ -1013,7 +1012,6 @@ int libvlc_media_player_play( libvlc_media_player_t *p_mi )
         var_DelCallback( p_input_thread, "can-pause", input_pausable_changed, p_mi );
         var_DelCallback( p_input_thread, "program-scrambled", input_scrambled_changed, p_mi );
         var_DelCallback( p_input_thread, "can-seek", input_seekable_changed, p_mi );
-        input_LegacyVarStop( p_input_thread );
         input_Close( p_input_thread );
         media_detach_preparsed_event( p_mi->p_md );
         libvlc_printerr( "Input initialization failure" );
index b8af6e5..4ae6666 100644 (file)
@@ -188,7 +188,6 @@ static void Close( vlc_object_t *p_this )
         if( !p_input )
             continue;
 
-        input_LegacyVarStop( p_input );
         input_Stop( p_input );
         input_Close( p_input );
 
@@ -258,7 +257,6 @@ noreturn static void *Run( void *data )
 
             if( state == END_S || state == ERROR_S )
             {
-                input_LegacyVarStop( p_input );
                 input_Stop( p_input );
                 input_Close( p_input );
 
index 9c33d2d..2dbb8b7 100644 (file)
@@ -114,15 +114,6 @@ static const vlc_input_callback_t p_input_callbacks[] =
 
     CALLBACK( NULL, NULL )
 };
-static const vlc_input_callback_t p_input_title_navigation_callbacks[] =
-{
-    CALLBACK( "next-title", TitleCallback ),
-    CALLBACK( "prev-title", TitleCallback ),
-    CALLBACK( "menu-popup", TitleCallback ),
-    CALLBACK( "menu-title", TitleCallback ),
-
-    CALLBACK( NULL, NULL )
-};
 #undef CALLBACK
 
 static void Trigger( input_thread_t *p_input, int i_type )
@@ -530,33 +521,6 @@ void input_LegacyVarInit ( input_thread_t *p_input )
 }
 
 /*****************************************************************************
- * input_LegacyVarStop:
- *****************************************************************************/
-void input_LegacyVarStop( input_thread_t *p_input )
-{
-    if( !input_priv(p_input)->b_preparsing )
-        InputDelCallbacks( p_input, p_input_callbacks );
-
-    if( input_priv(p_input)->i_title > 1 )
-        InputDelCallbacks( p_input, p_input_title_navigation_callbacks );
-
-    for( int i = 0; i < input_priv(p_input)->i_title; i++ )
-    {
-        char name[sizeof("title ") + 3 * sizeof (int)];
-
-        sprintf( name, "title %2u", i );
-        var_DelCallback( p_input, name, NavigationCallback, (void *)(intptr_t)i );
-    }
-
-    if( var_Type( p_input, "next-chapter" ) != 0 )
-    {
-        assert( var_Type( p_input, "prev-chapter" ) != 0 );
-        var_Destroy( p_input, "next-chapter" );
-        var_Destroy( p_input, "prev-chapter" );
-    }
-}
-
-/*****************************************************************************
  * input_LegacyVarNavigation:
  *  Create all remaining control object variables
  *****************************************************************************/
index f1efa7d..05d4533 100644 (file)
@@ -645,7 +645,6 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media )
 
                 var_DelCallback( p_input, "intf-event", InputEventPreparse,
                                  &preparse );
-                input_LegacyVarStop( p_input );
 
                 input_Stop( p_input );
                 input_Close( p_input );
@@ -886,7 +885,6 @@ static void vlm_MediaInstanceDelete( vlm_t *p_vlm, int64_t id, vlm_media_instanc
     input_thread_t *p_input = p_instance->p_input;
     if( p_input )
     {
-        input_LegacyVarStop( p_input );
         input_Stop( p_input );
         input_Close( p_input );
 
@@ -975,7 +973,6 @@ static int vlm_ControlMediaInstanceStart( vlm_t *p_vlm, int64_t id, const char *
             return VLC_SUCCESS;
         }
 
-        input_LegacyVarStop( p_input );
         input_Stop( p_input );
         input_Close( p_input );
 
@@ -1013,7 +1010,6 @@ static int vlm_ControlMediaInstanceStart( vlm_t *p_vlm, int64_t id, const char *
             if( input_Start( p_instance->p_input ) != VLC_SUCCESS )
             {
                 var_DelCallback( p_instance->p_input, "intf-event", InputEvent, p_media );
-                input_LegacyVarStop( p_instance->p_input );
                 input_Close( p_instance->p_input );
                 p_instance->p_input = NULL;
             }
index ec43e57..aa60639 100644 (file)
@@ -209,7 +209,6 @@ input_vaControl
 input_SetTime
 input_SetPosition
 input_LegacyVarInit
-input_LegacyVarStop
 input_LegacyEvents
 vlc_readdir_helper_init
 vlc_readdir_helper_finish
index 0aa539b..b072d72 100644 (file)
@@ -231,7 +231,6 @@ static bool PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
         {
             var_DelCallback( p_input_thread, "intf-event",
                              InputEvent, p_playlist );
-            input_LegacyVarStop( p_input_thread );
             vlc_object_release( p_input_thread );
             p_input_thread = NULL;
         }
@@ -456,7 +455,6 @@ static void LoopInput( playlist_t *p_playlist )
     if( !var_InheritBool( p_input, "sout-keep" ) )
         input_resource_TerminateSout( p_sys->p_input_resource );
     var_DelCallback( p_input, "intf-event", InputEvent, p_playlist );
-    input_LegacyVarStop( p_input );
     input_Close( p_input );
     PL_LOCK;
 }