mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-02-26 05:40:49 +00:00
Fix buffering bug in fluid_synth_process().
The old buffering code assumes that synth->cur is between 0 and FLUID_BUFSIZE. However since fluid_synth_process() can render more than one buffer at a time this isn't always true, and the new code handles other values properly. Closes #527
This commit is contained in:
parent
68db8f4a80
commit
f791162569
1 changed files with 4 additions and 3 deletions
|
@ -3645,7 +3645,7 @@ fluid_synth_process_LOCAL(fluid_synth_t *synth, int len, int nfx, float *fx[],
|
||||||
int nfxchan, nfxunits, naudchan;
|
int nfxchan, nfxunits, naudchan;
|
||||||
|
|
||||||
double time = fluid_utime();
|
double time = fluid_utime();
|
||||||
int i, f, num, count;
|
int i, f, num, count, buffered_blocks;
|
||||||
|
|
||||||
float cpu_load;
|
float cpu_load;
|
||||||
|
|
||||||
|
@ -3669,9 +3669,10 @@ fluid_synth_process_LOCAL(fluid_synth_t *synth, int len, int nfx, float *fx[],
|
||||||
count = 0;
|
count = 0;
|
||||||
num = synth->cur;
|
num = synth->cur;
|
||||||
|
|
||||||
if(synth->cur < FLUID_BUFSIZE)
|
buffered_blocks = (synth->cur + FLUID_BUFSIZE - 1) / FLUID_BUFSIZE;
|
||||||
|
if(synth->cur < buffered_blocks * FLUID_BUFSIZE)
|
||||||
{
|
{
|
||||||
int available = FLUID_BUFSIZE - synth->cur;
|
int available = (buffered_blocks * FLUID_BUFSIZE) - synth->cur;
|
||||||
num = (available > len) ? len : available;
|
num = (available > len) ? len : available;
|
||||||
|
|
||||||
if(nout != 0)
|
if(nout != 0)
|
||||||
|
|
Loading…
Reference in a new issue