]> git.sesse.net Git - vlc/commitdiff
Fluidsynth: fix block handling
authorRémi Denis-Courmont <remi@remlab.net>
Sat, 23 May 2009 11:14:32 +0000 (14:14 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sat, 23 May 2009 11:14:32 +0000 (14:14 +0300)
modules/codec/fluidsynth.c

index f0ef618cf91cb266744a1850ce4e387e9389368e..66c62d0cad9ee9784a5a1e6cc7e62471d743e701 100644 (file)
@@ -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;
 }