Commit ef299372 authored by Tristan Matthews's avatar Tristan Matthews Committed by Jean-Baptiste Kempf

twolame: add error checking

(cherry picked from commit 9b196c6333e8973ba3704af22b1d8b9d600bbd6f)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 548c4b48
...@@ -286,6 +286,8 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf ) ...@@ -286,6 +286,8 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
return NULL; return NULL;
p_block = block_Alloc( i_used ); p_block = block_Alloc( i_used );
if( !p_block )
return NULL;
memcpy( p_block->p_buffer, p_sys->p_out_buffer, i_used ); memcpy( p_block->p_buffer, p_sys->p_out_buffer, i_used );
p_block->i_length = (mtime_t)1000000 * p_block->i_length = (mtime_t)1000000 *
(mtime_t)MPEG_FRAME_SIZE / (mtime_t)p_enc->fmt_out.audio.i_rate; (mtime_t)MPEG_FRAME_SIZE / (mtime_t)p_enc->fmt_out.audio.i_rate;
...@@ -314,8 +316,21 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf ) ...@@ -314,8 +316,21 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
i_used = twolame_encode_buffer_interleaved( p_sys->p_twolame, i_used = twolame_encode_buffer_interleaved( p_sys->p_twolame,
p_sys->p_buffer, MPEG_FRAME_SIZE, p_sys->p_buffer, MPEG_FRAME_SIZE,
p_sys->p_out_buffer, MAX_CODED_FRAME_SIZE ); p_sys->p_out_buffer, MAX_CODED_FRAME_SIZE );
/* On error, buffer samples and return what was already encoded */
if( i_used < 0 )
{
msg_Err( p_enc, "encoder error: %d", i_used );
break;
}
p_sys->i_nb_samples = 0; p_sys->i_nb_samples = 0;
p_block = block_Alloc( i_used ); p_block = block_Alloc( i_used );
if( !p_block )
{
if( p_chain )
block_Release( p_chain );
return NULL;
}
memcpy( p_block->p_buffer, p_sys->p_out_buffer, i_used ); memcpy( p_block->p_buffer, p_sys->p_out_buffer, i_used );
p_block->i_length = (mtime_t)1000000 * p_block->i_length = (mtime_t)1000000 *
(mtime_t)MPEG_FRAME_SIZE / (mtime_t)p_enc->fmt_out.audio.i_rate; (mtime_t)MPEG_FRAME_SIZE / (mtime_t)p_enc->fmt_out.audio.i_rate;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment