mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-02-20 18:42:17 +00:00
- Added a dlopen() version of on-demand FluidSynth loading and exposed it
to CMake through the DYN_FLUIDSYNTH option. SVN r2558 (trunk)
This commit is contained in:
parent
f389cd8b0f
commit
a68e9c8fa6
3 changed files with 33 additions and 5 deletions
|
@ -19,6 +19,8 @@ if( CMAKE_COMPILER_IS_GNUCXX )
|
||||||
endif( APPLE )
|
endif( APPLE )
|
||||||
endif( CMAKE_COMPILER_IS_GNUCXX )
|
endif( CMAKE_COMPILER_IS_GNUCXX )
|
||||||
|
|
||||||
|
option( DYN_FLUIDSYNTH "Dynamically load fluidsynth" )
|
||||||
|
|
||||||
if( CMAKE_SIZEOF_VOID_P MATCHES "8" )
|
if( CMAKE_SIZEOF_VOID_P MATCHES "8" )
|
||||||
set( X64 64 )
|
set( X64 64 )
|
||||||
endif( CMAKE_SIZEOF_VOID_P MATCHES "8" )
|
endif( CMAKE_SIZEOF_VOID_P MATCHES "8" )
|
||||||
|
@ -490,8 +492,10 @@ set( ZDOOM_LIBS ${ZDOOM_LIBS} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_L
|
||||||
include_directories( "${ZLIB_INCLUDE_DIR}" "${FMOD_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" )
|
include_directories( "${ZLIB_INCLUDE_DIR}" "${FMOD_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" )
|
||||||
|
|
||||||
if( FLUIDSYNTH_FOUND )
|
if( FLUIDSYNTH_FOUND )
|
||||||
|
if( NOT DYN_FLUIDSYNTH)
|
||||||
set( ZDOOM_LIBS ${ZDOOM_LIBS} "${FLUIDSYNTH_LIBRARIES}" )
|
set( ZDOOM_LIBS ${ZDOOM_LIBS} "${FLUIDSYNTH_LIBRARIES}" )
|
||||||
include_directories( "${FLUIDSYNTH_INCLUDE_DIR}" )
|
include_directories( "${FLUIDSYNTH_INCLUDE_DIR}" )
|
||||||
|
endif( NOT DYN_FLUIDSYNTH )
|
||||||
endif( FLUIDSYNTH_FOUND )
|
endif( FLUIDSYNTH_FOUND )
|
||||||
|
|
||||||
# Start defining source files for ZDoom
|
# Start defining source files for ZDoom
|
||||||
|
@ -587,9 +591,11 @@ else( SSE_MATTERS )
|
||||||
set( X86_SOURCES )
|
set( X86_SOURCES )
|
||||||
endif( SSE_MATTERS )
|
endif( SSE_MATTERS )
|
||||||
|
|
||||||
if( FLUIDSYNTH_FOUND )
|
if( DYN_FLUIDSYNTH )
|
||||||
|
add_definitions( -DHAVE_FLUIDSYNTH -DDYN_FLUIDSYNTH )
|
||||||
|
elseif( FLUIDSYNTH_FOUND )
|
||||||
add_definitions( -DHAVE_FLUIDSYNTH )
|
add_definitions( -DHAVE_FLUIDSYNTH )
|
||||||
endif( FLUIDSYNTH_FOUND )
|
endif( DYN_FLUIDSYNTH )
|
||||||
|
|
||||||
add_executable( zdoom WIN32
|
add_executable( zdoom WIN32
|
||||||
autostart.cpp
|
autostart.cpp
|
||||||
|
|
|
@ -347,6 +347,8 @@ protected:
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HMODULE FluidSynthDLL;
|
HMODULE FluidSynthDLL;
|
||||||
|
#else
|
||||||
|
void *FluidSynthSO;
|
||||||
#endif
|
#endif
|
||||||
bool LoadFluidSynth();
|
bool LoadFluidSynth();
|
||||||
void UnloadFluidSynth();
|
void UnloadFluidSynth();
|
||||||
|
|
|
@ -54,7 +54,9 @@
|
||||||
#define FLUIDSYNTHLIB "fluidsynth64.dll"
|
#define FLUIDSYNTHLIB "fluidsynth64.dll"
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#error "TODO: Write a dlopen() version of this code."
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
#define FLUIDSYNTHLIB "libfluidsynth.so.1"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -892,24 +894,33 @@ bool FluidSynthMIDIDevice::LoadFluidSynth()
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
FluidSynthDLL = LoadLibrary(FLUIDSYNTHLIB);
|
FluidSynthDLL = LoadLibrary(FLUIDSYNTHLIB);
|
||||||
#endif
|
|
||||||
if (FluidSynthDLL == NULL)
|
if (FluidSynthDLL == NULL)
|
||||||
{
|
{
|
||||||
Printf(TEXTCOLOR_RED"Could not load " FLUIDSYNTHLIB "\n");
|
Printf(TEXTCOLOR_RED"Could not load " FLUIDSYNTHLIB "\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
FluidSynthSO = dlopen(FLUIDSYNTHLIB, RTLD_LAZY);
|
||||||
|
if (FluidSynthSO == NULL)
|
||||||
|
{
|
||||||
|
Printf(TEXTCOLOR_RED"Could not load " FLUIDSYNTHLIB ": %s\n", dlerror());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
for (int i = 0; i < countof(imports); ++i)
|
for (int i = 0; i < countof(imports); ++i)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
FARPROC proc = GetProcAddress(FluidSynthDLL, imports[i].FuncName);
|
FARPROC proc = GetProcAddress(FluidSynthDLL, imports[i].FuncName);
|
||||||
|
#else
|
||||||
|
void *proc = dlsym(FluidSynthSO, imports[i].FuncName);
|
||||||
|
#endif
|
||||||
if (proc == NULL)
|
if (proc == NULL)
|
||||||
{
|
{
|
||||||
Printf(TEXTCOLOR_RED"Failed to find %s in %s\n", imports[i].FuncName, FLUIDSYNTHLIB);
|
Printf(TEXTCOLOR_RED"Failed to find %s in %s\n", imports[i].FuncName, FLUIDSYNTHLIB);
|
||||||
fail++;
|
fail++;
|
||||||
}
|
}
|
||||||
*imports[i].FuncPointer = proc;
|
*imports[i].FuncPointer = proc;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (fail == 0)
|
if (fail == 0)
|
||||||
{
|
{
|
||||||
|
@ -920,6 +931,9 @@ bool FluidSynthMIDIDevice::LoadFluidSynth()
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
FreeLibrary(FluidSynthDLL);
|
FreeLibrary(FluidSynthDLL);
|
||||||
FluidSynthDLL = NULL;
|
FluidSynthDLL = NULL;
|
||||||
|
#else
|
||||||
|
dlclose(FluidSynthSO);
|
||||||
|
FluidSynthSO = NULL;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -940,6 +954,12 @@ void FluidSynthMIDIDevice::UnloadFluidSynth()
|
||||||
FreeLibrary(FluidSynthDLL);
|
FreeLibrary(FluidSynthDLL);
|
||||||
FluidSynthDLL = NULL;
|
FluidSynthDLL = NULL;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (FluidSynthSO != NULL)
|
||||||
|
{
|
||||||
|
dlclose(FluidSynthSO);
|
||||||
|
FluidSynthSO = NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue