From d7c8cf59f3f31faaa3cdb29ca95ed488e84cedb7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sat, 23 May 2009 14:14:32 +0300 Subject: [PATCH] Fluidsynth: fix block handling --- modules/codec/fluidsynth.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/codec/fluidsynth.c b/modules/codec/fluidsynth.c index f0ef618cf9..66c62d0cad 100644 --- a/modules/codec/fluidsynth.c +++ b/modules/codec/fluidsynth.c @@ -128,12 +128,14 @@ static aout_buffer_t *DecodeBlock (decoder_t *p_dec, block_t **pp_block) { block_t *p_block; decoder_sys_t *p_sys = p_dec->p_sys; + aout_buffer_t *p_out = NULL; if (pp_block == NULL) return NULL; p_block = *pp_block; if (p_block == NULL) return NULL; + *pp_block = NULL; if (p_block->i_pts && !aout_DateGet (&p_sys->end_date)) aout_DateSet (&p_sys->end_date, p_block->i_pts); @@ -141,12 +143,11 @@ static aout_buffer_t *DecodeBlock (decoder_t *p_dec, block_t **pp_block) if (p_block->i_pts < aout_DateGet (&p_sys->end_date)) { msg_Warn (p_dec, "MIDI message in the past?"); - block_Release (p_block); - return NULL; + goto drop; } if (p_block->i_buffer < 1) - return NULL; + goto drop; uint8_t channel = p_block->p_buffer[0] & 0xf; uint8_t p1 = (p_block->i_buffer > 1) ? (p_block->p_buffer[1] & 0x7f) : 0; @@ -178,17 +179,16 @@ static aout_buffer_t *DecodeBlock (decoder_t *p_dec, block_t **pp_block) if (samples == 0) return NULL; - aout_buffer_t *p_out = decoder_NewAudioBuffer (p_dec, samples); + p_out = decoder_NewAudioBuffer (p_dec, samples); if (p_out == NULL) - { - block_Release (p_block); - return NULL; - } + goto drop; p_out->start_date = aout_DateGet (&p_sys->end_date ); p_out->end_date = aout_DateIncrement (&p_sys->end_date, samples); fluid_synth_write_float (p_sys->synth, samples, p_out->p_buffer, 0, 2, p_out->p_buffer, 1, 2); +drop: + block_Release (p_block); return p_out; } -- 2.39.2