]> git.sesse.net Git - vlc/commitdiff
transcode: send NULL packet to audio encoder when closing
authorIlkka Ollakka <ileoo@videolan.org>
Fri, 19 Oct 2012 09:20:58 +0000 (12:20 +0300)
committerIlkka Ollakka <ileoo@videolan.org>
Fri, 19 Oct 2012 09:22:45 +0000 (12:22 +0300)
As with Video-encoders, audio encoder can flush buffers in that case.
Currently avcodec doesn't handle flushing and other encoders in this
changeset (flac,speex,twolame,vorbis) have only boilerplate to check
against NULL input so they don't crash.

modules/codec/avcodec/encoder.c
modules/codec/flac.c
modules/codec/speex.c
modules/codec/twolame.c
modules/codec/vorbis.c
modules/stream_out/transcode/transcode.c

index 22a369701765143c122bf0225e923bb90441ba16..a5d10bab8a38010d9e197bf6593d39f4b4d46c11 100644 (file)
@@ -1061,6 +1061,9 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
 
     block_t *p_block, *p_chain = NULL;
 
+    /*FIXME: change to use  avcodec_encode_audio2 to be able to flush*/
+    if( unlikely( !p_aout_buf ) ) return NULL;
+
     uint8_t *p_buffer = p_aout_buf->p_buffer;
     int i_samples = p_aout_buf->i_nb_samples;
     int i_samples_delay = p_sys->i_samples_delay;
index dda9fd322dec13b82ebd204d4f40fed99ef49831..64a3f9e9b41c833fb006aac4f93cc19d36578e10 100644 (file)
@@ -755,6 +755,9 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
     block_t *p_chain;
     unsigned int i;
 
+    /* FIXME: p_aout_buf is NULL when it's time to flush*/
+    if( unlikely( !p_aout_buf ) ) return NULL;
+
     p_sys->i_pts = p_aout_buf->i_pts -
                 (mtime_t)1000000 * (mtime_t)p_sys->i_samples_delay /
                 (mtime_t)p_enc->fmt_in.audio.i_rate;
index 40eac1a6db8857229d97eb169dde652952cdb949..03ccd1f1af1a9eaaadc005a4b681ca49d3d69a2e 100644 (file)
@@ -989,6 +989,9 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
     encoder_sys_t *p_sys = p_enc->p_sys;
     block_t *p_block, *p_chain = NULL;
 
+    /* Encoder gets NULL when it's time to flush */
+    if( unlikely( !p_aout_buf ) ) return NULL;
+
     unsigned char *p_buffer = p_aout_buf->p_buffer;
     int i_samples = p_aout_buf->i_nb_samples;
     int i_samples_delay = p_sys->i_samples_delay;
index 9fe366592b913f68bc8c686a0357fd5d05dd9642..fb515c712b5a8c803d64111809de1588704aada3 100644 (file)
@@ -261,6 +261,10 @@ static void Bufferize( encoder_t *p_enc, int16_t *p_in, int i_nb_samples )
 static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
 {
     encoder_sys_t *p_sys = p_enc->p_sys;
+
+    /* FIXME:p_aout_buf is NULL when it's time to flush, does twolame has buffer to flush?*/
+    if( unlikely( !p_aout_buf ) ) return NULL;
+
     int16_t *p_buffer = (int16_t *)p_aout_buf->p_buffer;
     int i_nb_samples = p_aout_buf->i_nb_samples;
     block_t *p_chain = NULL;
index 0e493771973def1b1546261413d0aac35166f044..524d79ab5984770261b294d6755d0d7cd5f857dc 100644 (file)
@@ -848,6 +848,9 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
     block_t *p_block, *p_chain = NULL;
     float **buffer;
 
+    /* FIXME: flush buffers in here */
+    if( unlikely( !p_aout_buf ) ) return NULL;
+
     mtime_t i_pts = p_aout_buf->i_pts -
                 (mtime_t)1000000 * (mtime_t)p_sys->i_samples_delay /
                 (mtime_t)p_enc->fmt_in.audio.i_rate;
index e6db2de8af537988398c245530e71727a1a9b793..568f795def9333a827e081890eb9840847d7bbb6 100644 (file)
@@ -601,6 +601,7 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
         switch( id->p_decoder->fmt_in.i_cat )
         {
         case AUDIO_ES:
+            Send( p_stream, id, NULL );
             transcode_audio_close( id );
             break;
         case VIDEO_ES: