[vlc-commits] transcode: fix logic/code when reinitialize filter on channel/rate change

Ilkka Ollakka git at videolan.org
Sat Apr 19 10:32:08 CEST 2014


vlc/vlc-2.1 | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Mon Oct 28 18:47:37 2013 +0200| [e40a4a1a54be2b69e4e001451f0dd91f3857a976] | committer: Rafaël Carré

transcode: fix logic/code when reinitialize filter on channel/rate change

Only check samplerate and physical_channels for now

(cherry picked from commit 26989ea2d98380eef28843ffa8ca490e8f9d6dae)
Signed-off-by: Rafaël Carré <funman at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.1.git/?a=commit;h=e40a4a1a54be2b69e4e001451f0dd91f3857a976
---

 modules/stream_out/transcode/audio.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/modules/stream_out/transcode/audio.c b/modules/stream_out/transcode/audio.c
index 83e9556..5d313db 100644
--- a/modules/stream_out/transcode/audio.c
+++ b/modules/stream_out/transcode/audio.c
@@ -93,7 +93,8 @@ static int transcode_audio_initialize_filters( sout_stream_t *p_stream, sout_str
         id->p_decoder->p_module = NULL;
         return VLC_EGENERIC;
     }
-    memcpy( fmt_last, &p_sys->fmt_audio, sizeof( audio_sample_format_t ) );
+    p_sys->fmt_audio.i_rate = fmt_last->i_rate;
+    p_sys->fmt_audio.i_physical_channels = fmt_last->i_physical_channels;
     return VLC_SUCCESS;
 }
 
@@ -264,11 +265,17 @@ int transcode_audio_process( sout_stream_t *p_stream,
         p_audio_buf->i_dts = p_audio_buf->i_pts;
 
         /* Check if audio format has changed, and filters need reinit */
-        if( unlikely( AOUT_FMTS_IDENTICAL( &id->p_decoder->fmt_out.audio, &p_sys->fmt_audio ) ) )
+        if( unlikely( ( id->p_decoder->fmt_out.audio.i_rate != p_sys->fmt_audio.i_rate ) ||
+                      ( id->p_decoder->fmt_out.audio.i_physical_channels != p_sys->fmt_audio.i_physical_channels ) ) )
         {
-            msg_Dbg( p_stream, "Audio changed, trying to reinitialize filters" );
+            msg_Info( p_stream, "Audio changed, trying to reinitialize filters" );
             if( id->p_af_chain != NULL )
                 aout_FiltersDelete( (vlc_object_t *)NULL, id->p_af_chain );
+
+            /* decoders don't set audio.i_format, but audio filters use it */
+            id->p_decoder->fmt_out.audio.i_format = id->p_decoder->fmt_out.i_codec;
+            aout_FormatPrepare( &id->p_decoder->fmt_out.audio );
+
             if( transcode_audio_initialize_filters( p_stream, id, p_sys, &id->p_decoder->fmt_out.audio ) != VLC_SUCCESS )
                 return VLC_EGENERIC;
 



More information about the vlc-commits mailing list