[vlc-devel] [PATCH] Fix libvlc_media_get_tracks_info()

Laurent Aimar fenrir at elivagar.org
Thu Dec 2 22:07:34 CET 2010


On Thu, Dec 02, 2010 at 10:00:12PM +0100, Rafaël Carré wrote:
> diff --git a/src/input/es_out.c b/src/input/es_out.c
> index 788f338..ed1548c 100644
> --- a/src/input/es_out.c
> +++ b/src/input/es_out.c
> @@ -2856,7 +2856,8 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *
>      const es_format_t *p_fmt_es = &es->fmt;
>      lldiv_t         div;
>  
> -    input_item_UpdateTracksInfo(input_GetItem(p_input), fmt);
> +    input_item_UpdateTracksInfo(input_GetItem(p_input), fmt, p_fmt_es,
> +                                es->i_meta_id);
 I would prefer if you simply gives a valid es_format_t to input_item_UpdateTracksInfo,
ie move all the changes you made to input_item_UpdateTracksInfo just before
calling input_item_UpdateTracksInfo(). It's not the job of
input_item_UpdateTracksInfo to do it itself.

> +    /* We don't want the decoder output format, only input */
> +    if( fmt->i_cat == orig_fmt->i_cat && fmt->i_codec != orig_fmt->i_codec )
 No, you want to update the others parameter even when the codec changes.
> +        return;
> +
> +    fmt_copy = malloc(sizeof *fmt_copy);
 No need to malloc.
>      if (!fmt_copy)
>          return;
>  
> @@ -1063,11 +1070,20 @@ void input_item_UpdateTracksInfo(input_item_t *item, const es_format_t *fmt)
>      /* XXX: we could free p_extra to save memory, we will likely not need
>       * the decoder specific data */
>  
> +    fmt_copy->i_id = meta_id;
> +    /* a decoder can change a type into another one,
> +     * the only case probably being subtitle->video with CDG tracks */
> +    if( orig_fmt->i_cat != fmt_copy->i_cat )
 Useless due to a previous check.
> +    {
> +        fmt_copy->i_codec           = orig_fmt->i_codec;
> +        fmt_copy->i_original_fourcc = orig_fmt->i_original_fourcc;
> +    }
> +
>      vlc_mutex_lock( &item->lock );
>  
>      for( i = 0; i < item->i_es; i++ )
>      {
> -        if (item->es[i]->i_id != fmt->i_id)
> +        if (item->es[i]->i_id != meta_id)
>              continue;

 I would simply replace the call to input_item_UpdateTracksInfo
in EsOutUpdateInfo by (if it works):
if( es->fmt.i_cat == fmt->i_cat )
{
	es_format_t update = *fmt;
	update.i_id = es->i_meta_id;
	update.i_codec = es->fmt.i_codec;
	update.i_original_fourcc = es->fmt.i_original_fourcc;
	input_item_UpdateTracksInfo(input_GetItem(p_input), &update);
}

Regards,

-- 
fenrir




More information about the vlc-devel mailing list