From 1be0e5ae7cc8c6085959650874fead9a1d9ae087 Mon Sep 17 00:00:00 2001 From: derselbst Date: Mon, 28 Dec 2020 18:08:16 +0100 Subject: [PATCH] Log error when audio callback function fails Addresses #724 --- src/drivers/fluid_jack.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/drivers/fluid_jack.c b/src/drivers/fluid_jack.c index 18495dfe..ee61e3e3 100644 --- a/src/drivers/fluid_jack.c +++ b/src/drivers/fluid_jack.c @@ -750,6 +750,7 @@ fluid_jack_driver_process(jack_nframes_t nframes, void *arg) } else { + int res; fluid_audio_func_t callback = (audio_driver->callback != NULL) ? audio_driver->callback : (fluid_audio_func_t) fluid_synth_process; for(i = 0; i < audio_driver->num_output_ports; i++) @@ -776,12 +777,18 @@ fluid_jack_driver_process(jack_nframes_t nframes, void *arg) FLUID_MEMSET(audio_driver->fx_bufs[k], 0, nframes * sizeof(float)); } - return callback(audio_driver->data, + res = callback(audio_driver->data, nframes, audio_driver->num_fx_ports * 2, audio_driver->fx_bufs, audio_driver->num_output_ports * 2, audio_driver->output_bufs); + if(res != FLUID_OK) + { + const char *cb_func_name = (audio_driver->callback != NULL) ? "Custom audio callback function" : "fluid_synth_process()"; + FLUID_LOG(FLUID_PANIC, "%s returned an error. As a consequence, fluidsynth will now be removed from Jack's processing loop.", cb_func_name); + } + return res; } }