[vlc-devel] commit: wmafixed: handle error cases (fixes #2474) (Jean-Paul Saman )
git version control
git at videolan.org
Sat Feb 7 16:33:40 CET 2009
vlc | branch: master | Jean-Paul Saman <jean-paul.saman at m2x.nl> | Sat Feb 7 16:25:34 2009 +0100| [9bca33b943a8e79c19644a593da8a67440814811] | committer: Jean-Paul Saman
wmafixed: handle error cases (fixes #2474)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9bca33b943a8e79c19644a593da8a67440814811
---
modules/codec/wmafixed/wma.c | 32 +++++++++++++++++++++++++++-----
1 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/modules/codec/wmafixed/wma.c b/modules/codec/wmafixed/wma.c
index ba66158..9ceee09 100644
--- a/modules/codec/wmafixed/wma.c
+++ b/modules/codec/wmafixed/wma.c
@@ -198,13 +198,23 @@ static aout_buffer_t *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
{
decoder_sys_t *p_sys = p_dec->p_sys;
block_t *p_block;
- mtime_t start = mdate(); /* for statistics */
aout_buffer_t *p_aout_buffer = NULL;
+#ifdef NDEBUG
+ mtime_t start = mdate(); /* for statistics */
+#endif
if( !pp_block || !*pp_block ) return NULL;
p_block = *pp_block;
+ if( p_block->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
+ {
+ aout_DateSet( &p_sys->end_date, 0 );
+ block_Release( p_block );
+ *pp_block = NULL;
+ return NULL;
+ }
+
if( p_block->i_buffer <= 0 )
{
/* we already decoded the samples, just feed a few to aout */
@@ -235,8 +245,14 @@ static aout_buffer_t *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
return NULL;
}
- wma_decode_superframe_init( &p_sys->wmadec, p_block->p_buffer,
- p_block->i_buffer );
+ if( wma_decode_superframe_init( &p_sys->wmadec, p_block->p_buffer,
+ p_block->i_buffer ) == 0 )
+ {
+ msg_Err( p_dec, "failed initializing wmafixed decoder" );
+ block_Release( p_block );
+ *pp_block = NULL;
+ return NULL;
+ }
if( p_sys->wmadec.nb_frames <= 0 )
{
@@ -248,6 +264,8 @@ static aout_buffer_t *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
/* worst case */
size_t i_buffer = BLOCK_MAX_SIZE * MAX_CHANNELS * p_sys->wmadec.nb_frames;
+ if( p_sys->p_output )
+ free( p_sys->p_output );
p_sys->p_output = malloc(i_buffer * sizeof(int32_t) );
p_sys->p_samples = (int8_t*)p_sys->p_output;
@@ -269,10 +287,14 @@ static aout_buffer_t *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
p_block->p_buffer, p_block->i_buffer );
if( i_samples < 0 )
+ {
msg_Warn( p_dec,
"wma_decode_superframe_frame() failed for frame %d", i );
- else
- p_sys->i_samples += i_samples; /* advance in the samples buffer */
+ free( p_sys->p_output );
+ p_sys->p_output = NULL;
+ return NULL;
+ }
+ p_sys->i_samples += i_samples; /* advance in the samples buffer */
}
p_block->i_buffer = 0; /* this block has been decoded */
More information about the vlc-devel
mailing list