[vlc-devel] playlist: fix callback leak

KO Myung-Hun komh78 at gmail.com
Sun Dec 28 02:33:25 CET 2014



Rémi Denis-Courmont wrote:
> vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Aug 16 12:51:41 2014 +0300| [9501e5253932c9a7f40d31c0f4fea2c6d26cfdd2] | committer: Rémi Denis-Courmont
> 
> playlist: fix callback leak
> 
> Note that we cannot hold the playlist lock while removing the callback,
> since the callback function takes the playlist lock.
> 
>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9501e5253932c9a7f40d31c0f4fea2c6d26cfdd2
> ---
> 
>  src/playlist/thread.c |   23 ++++++++++++++---------
>  1 file changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/src/playlist/thread.c b/src/playlist/thread.c
> index 0e51f60..ea96549 100644
> --- a/src/playlist/thread.c
> +++ b/src/playlist/thread.c
> @@ -207,20 +207,24 @@ static void PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
>      p_sys->status.i_status = PLAYLIST_RUNNING;
>  
>      assert( p_sys->p_input == NULL );
> +    PL_UNLOCK;
>  
> -    input_thread_t *p_input_thread = input_Create( p_playlist, p_input, NULL, p_sys->p_input_resource );
> -    if( p_input_thread )
> +    input_thread_t *p_input_thread = input_Create( p_playlist, p_input, NULL,
> +                                                   p_sys->p_input_resource );
> +    if( likely(p_input_thread != NULL) )
>      {
> -        p_sys->p_input = p_input_thread;
> -        var_AddCallback( p_input_thread, "intf-event", InputEvent, p_playlist );
> -
> -        var_SetAddress( p_playlist, "input-current", p_input_thread );
> +        var_AddCallback( p_input_thread, "intf-event",
> +                         InputEvent, p_playlist );
>  
> -        if( input_Start( p_sys->p_input ) )
> +        if( input_Start( p_input_thread ) )
>          {
> +            var_DelCallback( p_input_thread, "intf-event",
> +                             InputEvent, p_playlist );
>              vlc_object_release( p_input_thread );
> -            p_sys->p_input = p_input_thread = NULL;
> +            p_input_thread = NULL;
>          }
> +        else
> +            var_SetAddress( p_playlist, "input-current", p_input_thread );
>      }
>  
>      /* TODO store art policy in playlist private data */
> @@ -235,9 +239,10 @@ static void PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
>      }
>      free( psz_arturl );
>  
> -    PL_UNLOCK;
>      var_TriggerCallback( p_playlist, "activity" );
> +
>      PL_LOCK;
> +    p_sys->p_input = p_input_thread;
>  }
>  
>  /**
> 

This breaks Qt interface behaviors such as seeking and toggling FSC
while playing local files.


-- 
KO Myung-Hun

Using Mozilla SeaMonkey 2.7.2
Under OS/2 Warp 4 for Korean with FixPak #15
In VirtualBox v4.1.32 on Intel Core i7-3615QM 2.30GHz with 8GB RAM

Korean OS/2 User Community : http://www.ecomstation.co.kr




More information about the vlc-devel mailing list