[vlc-devel] [PATCH] transcode: Reset audio filters chain if samplerate and/or number of channels change

Rafaël Carré funman at videolan.org
Thu Jun 7 18:37:27 CEST 2012


> From c7f595c931793094db73a20637d98648ad0b73bd Mon Sep 17 00:00:00 2001
> From: Aurelien Nephtali <aurelien.nephtali at gmail.com>
> Date: Thu, 7 Jun 2012 18:02:24 +0200
> Subject: [PATCH] transcode: Reset audio filters chain if samplerate and/or
>  number of channels change
> 
> ---
>  modules/stream_out/transcode/audio.c |   20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/modules/stream_out/transcode/audio.c b/modules/stream_out/transcode/audio.c
> index a041e06..27a830c 100644
> --- a/modules/stream_out/transcode/audio.c
> +++ b/modules/stream_out/transcode/audio.c
> @@ -326,6 +326,26 @@ int transcode_audio_process( sout_stream_t *p_stream,
>      while( (p_audio_buf = id->p_decoder->pf_decode_audio( id->p_decoder,
>                                                            &in )) )
>      {
> +        if ( id->p_decoder->fmt_in.audio.i_rate != id->p_decoder->fmt_out.audio.i_rate ||
> +             id->p_decoder->fmt_in.audio.i_channels != id->p_decoder->fmt_out.audio.i_channels )

We have a video_format_IsSimilar() already, perhaps a similar function
for audio would be welcome.

> +        {
> +            msg_Warn( p_stream, "decoder changed stream specs (samplerate: %i -> %i, channels: %i -> %i)",
> +                      id->p_decoder->fmt_in.audio.i_rate, id->p_decoder->fmt_out.audio.i_rate,
> +                      id->p_decoder->fmt_in.audio.i_channels, id->p_decoder->fmt_out.audio.i_channels );
> +            id->p_decoder->fmt_in.audio.i_rate = id->p_decoder->fmt_out.audio.i_rate;
> +            id->p_decoder->fmt_in.audio.i_channels = id->p_decoder->fmt_out.audio.i_channels;
> +
> +            filter_chain_Reset( id->p_f_chain, &id->p_decoder->fmt_out, &id->p_encoder->fmt_in );
> +
> +            if( transcode_audio_filter_chain_build( p_stream, id->p_f_chain,
> +                                                    &id->p_encoder->fmt_in, &id->p_decoder->fmt_out ) )
> +            {
> +                block_Release( p_audio_buf );
> +                transcode_audio_close( id );
> +                return VLC_EGENERIC;
> +            }
> +        }
> +
>          if( p_sys->b_master_sync )
>          {
>              mtime_t i_dts = date_Get( &id->interpolated_pts ) + 1;



More information about the vlc-devel mailing list