]> git.sesse.net Git - vlc/blobdiff - modules/codec/avcodec/audio.c
Fixed non initialized date_t in some corner case with avcodec.
[vlc] / modules / codec / avcodec / audio.c
index b2cb902733e9e9e76446b7945d1f57c38b5c1915..0aaacee66d6297d07dbef08da8f3edfa9c714433 100644 (file)
@@ -217,15 +217,17 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
     p_sys->i_previous_channels = 0;
     p_sys->i_previous_layout = 0;
 
-    date_Set( &p_sys->end_date, 0 );
-    if( p_dec->fmt_in.audio.i_rate )
-        date_Init( &p_sys->end_date, p_dec->fmt_in.audio.i_rate, 1 );
-
     /* */
     p_dec->fmt_out.i_cat = AUDIO_ES;
     /* Try to set as much informations as possible but do not trust it */
     SetupOutputFormat( p_dec, false );
 
+    date_Set( &p_sys->end_date, 0 );
+    if( p_dec->fmt_out.audio.i_rate )
+        date_Init( &p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1 );
+    else if( p_dec->fmt_in.audio.i_rate )
+        date_Init( &p_sys->end_date, p_dec->fmt_in.audio.i_rate, 1 );
+
     return VLC_SUCCESS;
 }