[vlc-devel] commit: Fluidsynth: fix block handling ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat May 23 16:02:50 CEST 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat May 23 14:14:32 2009 +0300| [d7c8cf59f3f31faaa3cdb29ca95ed488e84cedb7] | committer: Rémi Denis-Courmont 

Fluidsynth: fix block handling

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d7c8cf59f3f31faaa3cdb29ca95ed488e84cedb7
---

 modules/codec/fluidsynth.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/modules/codec/fluidsynth.c b/modules/codec/fluidsynth.c
index f0ef618..66c62d0 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;
 }




More information about the vlc-devel mailing list