From 6145c593052d6254ef09a65e33f95684d775328c Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Mon, 20 Oct 2014 10:17:48 +0200 Subject: [PATCH] fluid-fun: Don't dlclose libfluidsynth, ever Some versions of the library do nasty things with thread local storage without cleaning up after themselves. --- src/fluid-fun.cpp | 8 +------- src/fluid-fun.h | 1 - src/sharedmidistate.h | 6 +++--- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/fluid-fun.cpp b/src/fluid-fun.cpp index 845a8c4..84323f6 100644 --- a/src/fluid-fun.cpp +++ b/src/fluid-fun.cpp @@ -61,13 +61,7 @@ fail: Debug() << "Failed to load " FLUID_LIB ". Midi playback is disabled."; memset(&fluid, 0, sizeof(fluid)); - finiFluidFunctions(); -#endif -} - -void finiFluidFunctions() -{ -#ifndef SHARED_FLUID SDL_UnloadObject(so); + so = 0; #endif } diff --git a/src/fluid-fun.h b/src/fluid-fun.h index 2aff2e2..c28a5f3 100644 --- a/src/fluid-fun.h +++ b/src/fluid-fun.h @@ -55,6 +55,5 @@ struct FluidFunctions extern FluidFunctions fluid; void initFluidFunctions(); -void finiFluidFunctions(); #endif // FLUIDFUN_H diff --git a/src/sharedmidistate.h b/src/sharedmidistate.h index 455e4b0..00de6dc 100644 --- a/src/sharedmidistate.h +++ b/src/sharedmidistate.h @@ -53,7 +53,9 @@ struct SharedMidiState ~SharedMidiState() { - if (!HAVE_FLUID || !inited) + /* We might have initialized, but if the consecutive libfluidsynth + * load failed, no resources will have been allocated */ + if (!inited || !HAVE_FLUID) return; fluid.delete_settings(flSettings); @@ -63,8 +65,6 @@ struct SharedMidiState assert(!synths[i].inUse); fluid.delete_synth(synths[i].synth); } - - finiFluidFunctions(); } void initIfNeeded(const Config &conf)