[vlc-commits] transcode/audio: fix audio_dec_out fmt before first encoder initialization

Thomas Guillem git at videolan.org
Wed Jan 10 19:32:27 CET 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Jan 10 19:27:06 2018 +0100| [26cf436f2a42a4e893d7adcc442ac2d21726e395] | committer: Thomas Guillem

transcode/audio: fix audio_dec_out fmt before first encoder initialization

c.f. comment.

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

 modules/stream_out/transcode/audio.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/modules/stream_out/transcode/audio.c b/modules/stream_out/transcode/audio.c
index e304a16b96..577378ecea 100644
--- a/modules/stream_out/transcode/audio.c
+++ b/modules/stream_out/transcode/audio.c
@@ -200,12 +200,27 @@ static int transcode_audio_new( sout_stream_t *p_stream,
     }
 
     vlc_mutex_lock(&id->fifo.lock);
+    /* The decoder fmt_out can be uninitialized here (since it can initialized
+     * asynchronously). Fix audio_dec_out with default values in that case.
+     * This should be enough to initialize the encoder for the first time (it
+     * will be reloaded when all informations from the decoder are available).
+     * */
     id->audio_dec_out = id->p_decoder->fmt_out.audio;
     id->audio_dec_out.i_format = id->p_decoder->fmt_out.i_codec;
+    if (id->audio_dec_out.i_format == 0)
+        id->audio_dec_out.i_format = VLC_CODEC_FL32;
     if (id->audio_dec_out.i_rate == 0)
+    {
         id->audio_dec_out.i_rate = id->p_decoder->fmt_in.audio.i_rate;
+        if (id->audio_dec_out.i_rate == 0)
+            id->audio_dec_out.i_rate = 48000;
+    }
     if (id->audio_dec_out.i_physical_channels == 0)
+    {
         id->audio_dec_out.i_physical_channels = id->p_decoder->fmt_in.audio.i_physical_channels;
+        if (id->audio_dec_out.i_physical_channels == 0)
+            id->audio_dec_out.i_physical_channels = AOUT_CHANS_STEREO;
+    }
     aout_FormatPrepare( &id->audio_dec_out );
 
     /*



More information about the vlc-commits mailing list