Commit d7c8cf59 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Fluidsynth: fix block handling

parent 7e8f0d85
...@@ -128,12 +128,14 @@ static aout_buffer_t *DecodeBlock (decoder_t *p_dec, block_t **pp_block) ...@@ -128,12 +128,14 @@ static aout_buffer_t *DecodeBlock (decoder_t *p_dec, block_t **pp_block)
{ {
block_t *p_block; block_t *p_block;
decoder_sys_t *p_sys = p_dec->p_sys; decoder_sys_t *p_sys = p_dec->p_sys;
aout_buffer_t *p_out = NULL;
if (pp_block == NULL) if (pp_block == NULL)
return NULL; return NULL;
p_block = *pp_block; p_block = *pp_block;
if (p_block == NULL) if (p_block == NULL)
return NULL; return NULL;
*pp_block = NULL;
if (p_block->i_pts && !aout_DateGet (&p_sys->end_date)) if (p_block->i_pts && !aout_DateGet (&p_sys->end_date))
aout_DateSet (&p_sys->end_date, p_block->i_pts); 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) ...@@ -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)) if (p_block->i_pts < aout_DateGet (&p_sys->end_date))
{ {
msg_Warn (p_dec, "MIDI message in the past?"); msg_Warn (p_dec, "MIDI message in the past?");
block_Release (p_block); goto drop;
return NULL;
} }
if (p_block->i_buffer < 1) if (p_block->i_buffer < 1)
return NULL; goto drop;
uint8_t channel = p_block->p_buffer[0] & 0xf; uint8_t channel = p_block->p_buffer[0] & 0xf;
uint8_t p1 = (p_block->i_buffer > 1) ? (p_block->p_buffer[1] & 0x7f) : 0; 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) ...@@ -178,17 +179,16 @@ static aout_buffer_t *DecodeBlock (decoder_t *p_dec, block_t **pp_block)
if (samples == 0) if (samples == 0)
return NULL; return NULL;
aout_buffer_t *p_out = decoder_NewAudioBuffer (p_dec, samples); p_out = decoder_NewAudioBuffer (p_dec, samples);
if (p_out == NULL) if (p_out == NULL)
{ goto drop;
block_Release (p_block);
return NULL;
}
p_out->start_date = aout_DateGet (&p_sys->end_date ); p_out->start_date = aout_DateGet (&p_sys->end_date );
p_out->end_date = aout_DateIncrement (&p_sys->end_date, samples); p_out->end_date = aout_DateIncrement (&p_sys->end_date, samples);
fluid_synth_write_float (p_sys->synth, samples, fluid_synth_write_float (p_sys->synth, samples,
p_out->p_buffer, 0, 2, p_out->p_buffer, 0, 2,
p_out->p_buffer, 1, 2); p_out->p_buffer, 1, 2);
drop:
block_Release (p_block);
return p_out; return p_out;
} }
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