From ef9564e000f9b1c1e0facdf85b7656cf0278a26e Mon Sep 17 00:00:00 2001 From: derselbst Date: Sun, 27 Aug 2017 12:43:24 +0200 Subject: [PATCH] always enforce enqueuing rvoice_events --- fluidsynth/src/rvoice/fluid_rvoice_event.c | 8 +++++++- fluidsynth/src/synth/fluid_synth.c | 7 ------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/fluidsynth/src/rvoice/fluid_rvoice_event.c b/fluidsynth/src/rvoice/fluid_rvoice_event.c index a62152fa..ffe28d97 100644 --- a/fluidsynth/src/rvoice/fluid_rvoice_event.c +++ b/fluidsynth/src/rvoice/fluid_rvoice_event.c @@ -233,7 +233,13 @@ new_fluid_rvoice_eventhandler(int is_threadsafe, int queuesize, eventhandler->mixer = NULL; eventhandler->queue = NULL; eventhandler->finished_voices = NULL; - eventhandler->is_threadsafe = is_threadsafe; + + /* HACK 2017-08-27: always enforce threadsafety, i.e. enforce enqueuing events + * otherwise we mess up rendering if more than one block is requested by the user + * because fluid_rvoice_eventhandler_dispatch_count() always stays zero causing + * that too many events are dispatched too early, causing incorrectly timed audio + */ + eventhandler->is_threadsafe = TRUE; eventhandler->queue_stored = 0; eventhandler->finished_voices = new_fluid_ringbuffer(finished_voices_size, diff --git a/fluidsynth/src/synth/fluid_synth.c b/fluidsynth/src/synth/fluid_synth.c index 652252ec..98c9c510 100644 --- a/fluidsynth/src/synth/fluid_synth.c +++ b/fluidsynth/src/synth/fluid_synth.c @@ -2939,17 +2939,10 @@ fluid_synth_render_blocks(fluid_synth_t* synth, int blockcount) fluid_rvoice_eventhandler_dispatch_all(synth->eventhandler); -#if 0 /* do not render more blocks than we can store internally */ maxblocks = fluid_rvoice_mixer_get_bufcount(synth->eventhandler->mixer); if (blockcount > maxblocks) blockcount = maxblocks; -#else - /* if we process more blocks, noteons will be timed incorrectly - * this bug seems to be design made, i.e. the current implementation requires to - * process all events for one block and then render whatever we just processed. */ - blockcount = 1; -#endif for (i=0; i < blockcount; i++) { fluid_sample_timer_process(synth);