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

Laurent Aimar fenrir at elivagar.org
Thu Jun 7 21:06:10 CEST 2012


On Thu, Jun 07, 2012 at 06:04:29PM +0200, Aurélien Nephtali wrote:
> On Thu, Jun 7, 2012 at 5:21 PM, Ludovic Fauvet <etix at videolan.org> wrote:
> > On Thu, Jun 7, 2012 at 4:56 PM, Aurélien Nephtali
> > <aurelien.nephtali at gmail.com> wrote:
> >> From 2f977fba3eb03eca1cedff5b13e3f86f824a395e Mon Sep 17 00:00:00 2001
> >> From: Aurelien Nephtali <aurelien.nephtali at gmail.com>
> >> Date: Thu, 7 Jun 2012 16:51:03 +0200
> >> Subject: [PATCH 2/2] transcode: Reset audio filters chain if samplerate
> >>  and/or number of channels change

> 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 )
I don't think that checking against fmt_in is the right thing, it
would be better to check against the format expected by the audio
filters.

> +        {
> +            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;
And I fear that changing the decoder input format may have side effects.

> +            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;
> +            }
Sadly that's not enough when user filters are in use.
I think that one way could be to factor out the code in transcode_audio_new()
and reuse it here.

Regards,

-- 
fenrir




More information about the vlc-devel mailing list