[vlc-devel] [PATCH] player: don't invalidate input from vlc_player_Stop()

Romain Vimont rom1v at videolabs.io
Wed Jun 10 17:16:53 CEST 2020


On Tue, Jun 09, 2020 at 03:29:42PM +0200, Thomas Guillem wrote:
> This fixes the program assertion in
> lib/media_player.c:on_program_selection_changed(). This could happen very
> rarely from the libvlc_media_player test.
> 
> A valid player->input is needed to get the program information from
> vlc_player_GetSelectedProgram(), but this player->input was set to NULL after
> the user requested the player to stop. Reminder: Stopping the player is
> asynchronous and doesn't prevent upcoming events (specially to get a symmetry
> between added and removed track/program events).

In on_program_selection_changed(), the new selection is known via the
unselected_id/selected_id parameters.

So I think the program instance should be retrieved from these ids,
instead of _GetSelectedProgram() (which may return a different program
since it's asynchronous).

However, the change may still be valid (or not), depending of whether
_GetSelectedProgram() is expected to return a null or non-null value
between a _Stop() and the matching on_program_selection_changed()
callback.

> ---
>  src/player/player.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/player/player.c b/src/player/player.c
> index a1a39a28f5f..b93267834fa 100644
> --- a/src/player/player.c
> +++ b/src/player/player.c
> @@ -1207,7 +1207,6 @@ vlc_player_Stop(vlc_player_t *player)
>      player->started = false;
>  
>      vlc_player_destructor_AddInput(player, input);
> -    player->input = NULL;
>      return VLC_SUCCESS;
>  }
>  
> @@ -1885,8 +1884,11 @@ vlc_player_Delete(vlc_player_t *player)
>  {
>      vlc_mutex_lock(&player->lock);
>  
> -    if (player->input)
> +    if (player->started)
> +    {
> +        assert(player->input);
>          vlc_player_destructor_AddInput(player, player->input);
> +    }
>  
>      player->deleting = true;
>      vlc_cond_signal(&player->destructor.wait);
> -- 
> 2.20.1
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list