From d313db553fb2bc36f2e99e7a2f0c44391033108a Mon Sep 17 00:00:00 2001 From: derselbst Date: Fri, 18 Aug 2017 17:53:12 +0200 Subject: [PATCH] do not process more blocks than we can store internally addresses #192 --- fluidsynth/src/synth/fluid_synth.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fluidsynth/src/synth/fluid_synth.c b/fluidsynth/src/synth/fluid_synth.c index 0db66df8..9421903b 100644 --- a/fluidsynth/src/synth/fluid_synth.c +++ b/fluidsynth/src/synth/fluid_synth.c @@ -2942,7 +2942,16 @@ fluid_synth_render_blocks(fluid_synth_t* synth, int blockcount) for (i=0; i < blockcount; i++) { fluid_sample_timer_process(synth); fluid_synth_add_ticks(synth, FLUID_BUFSIZE); - if (fluid_rvoice_eventhandler_dispatch_count(synth->eventhandler)) { + + /* If events have been queued waiting for fluid_rvoice_eventhandler_dispatch_all() + * (should only happen with parallel render) OR we are about to process more + * blocks than we can store internally (being at risk having already dispatched many rvoices, + * because we may not be using parallel render), stop processing and go for rendering + */ + if (fluid_rvoice_eventhandler_dispatch_count(synth->eventhandler) + || i+1 >= FLUID_MIXER_MAX_BUFFERS_DEFAULT-1 /* there actually is one 1 too many here, + but this seems to be the only way it works */ + ) { // Something has happened, we can't process more blockcount = i+1; break;