Commit 6355a18a authored by Rafaël Carré's avatar Rafaël Carré Committed by Jean-Baptiste Kempf

avcodec audio: factorize error case

(cherry picked from commit c99738f05e07ef0e25c3bdc353c66544b28f54ba)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent e34f42f7
...@@ -273,35 +273,26 @@ aout_buffer_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block ) ...@@ -273,35 +273,26 @@ aout_buffer_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block )
if( ffmpeg_OpenCodec( p_dec ) ) if( ffmpeg_OpenCodec( p_dec ) )
msg_Err( p_dec, "Cannot open decoder %s", p_sys->psz_namecodec ); msg_Err( p_dec, "Cannot open decoder %s", p_sys->psz_namecodec );
} }
if( p_sys->b_delayed_open ) if( p_sys->b_delayed_open )
{ goto end;
//block_Release( p_block );
return NULL;
}
if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) ) if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
{ {
//block_Release( p_block );
avcodec_flush_buffers( p_sys->p_context ); avcodec_flush_buffers( p_sys->p_context );
date_Set( &p_sys->end_date, 0 ); date_Set( &p_sys->end_date, 0 );
if( p_sys->i_codec_id == CODEC_ID_MP2 || p_sys->i_codec_id == CODEC_ID_MP3 ) if( p_sys->i_codec_id == CODEC_ID_MP2 || p_sys->i_codec_id == CODEC_ID_MP3 )
p_sys->i_reject_count = 3; p_sys->i_reject_count = 3;
return NULL;
goto end;
} }
if( !date_Get( &p_sys->end_date ) && !p_block->i_pts ) if( !date_Get( &p_sys->end_date ) && !p_block->i_pts )
{ goto end;
/* We've just started the stream, wait for the first PTS. */
//block_Release( p_block );
return NULL;
}
if( p_block->i_buffer <= 0 ) if( p_block->i_buffer <= 0 )
{ goto end;
//block_Release( p_block );
return NULL;
}
if( (p_block->i_flags & BLOCK_FLAG_PRIVATE_REALLOCATED) == 0 ) if( (p_block->i_flags & BLOCK_FLAG_PRIVATE_REALLOCATED) == 0 )
{ {
...@@ -336,8 +327,7 @@ aout_buffer_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block ) ...@@ -336,8 +327,7 @@ aout_buffer_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block )
msg_Warn( p_dec, "cannot decode one frame (%zu bytes)", msg_Warn( p_dec, "cannot decode one frame (%zu bytes)",
p_block->i_buffer ); p_block->i_buffer );
// block_Release( p_block ); goto end;
return NULL;
} }
else if( (size_t)i_used > p_block->i_buffer ) else if( (size_t)i_used > p_block->i_buffer )
{ {
...@@ -354,8 +344,7 @@ aout_buffer_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block ) ...@@ -354,8 +344,7 @@ aout_buffer_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block )
{ {
msg_Warn( p_dec, "invalid audio properties channels count %d, sample rate %d", msg_Warn( p_dec, "invalid audio properties channels count %d, sample rate %d",
p_sys->p_context->channels, p_sys->p_context->sample_rate ); p_sys->p_context->channels, p_sys->p_context->sample_rate );
//block_Release( p_block ); goto end;
return NULL;
} }
if( p_dec->fmt_out.audio.i_rate != (unsigned int)p_sys->p_context->sample_rate ) if( p_dec->fmt_out.audio.i_rate != (unsigned int)p_sys->p_context->sample_rate )
...@@ -402,6 +391,10 @@ aout_buffer_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block ) ...@@ -402,6 +391,10 @@ aout_buffer_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block )
p_sys->pi_extraction, p_dec->fmt_out.audio.i_bitspersample ); p_sys->pi_extraction, p_dec->fmt_out.audio.i_bitspersample );
return p_buffer; return p_buffer;
end:
block_Release(p_block);
return NULL;
} }
/***************************************************************************** /*****************************************************************************
......
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