2014-09-07 03:23:10 +00:00
|
|
|
#include "fluid-fun.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <SDL_loadso.h>
|
|
|
|
#include <SDL_platform.h>
|
|
|
|
|
|
|
|
#include "debugwriter.h"
|
|
|
|
|
|
|
|
#ifdef SHARED_FLUID
|
|
|
|
#include <fluidsynth.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __LINUX__
|
|
|
|
#define FLUID_LIB "libfluidsynth.so.1"
|
|
|
|
#elif __MACOSX__
|
2014-10-01 17:19:25 +00:00
|
|
|
#define FLUID_LIB "libfluidsynth.1.dylib"
|
2014-09-07 03:23:10 +00:00
|
|
|
#elif __WINDOWS__
|
|
|
|
#define FLUID_LIB "fluidsynth.dll"
|
|
|
|
#else
|
|
|
|
#error "platform not recognized"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct FluidFunctions fluid;
|
|
|
|
|
|
|
|
static void *so;
|
|
|
|
|
|
|
|
void initFluidFunctions()
|
|
|
|
{
|
|
|
|
#ifdef SHARED_FLUID
|
|
|
|
|
|
|
|
#define FLUID_FUN(name, type) \
|
|
|
|
fluid.name = fluid_##name;
|
|
|
|
|
|
|
|
#define FLUID_FUN2(name, type, real_name) \
|
|
|
|
fluid.name = real_name;
|
|
|
|
|
|
|
|
#else
|
|
|
|
so = SDL_LoadObject(FLUID_LIB);
|
|
|
|
|
|
|
|
if (!so)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
#define FLUID_FUN(name, type) \
|
|
|
|
fluid.name = (type) SDL_LoadFunction(so, "fluid_" #name); \
|
|
|
|
if (!fluid.name) \
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
#define FLUID_FUN2(name, type, real_name) \
|
|
|
|
fluid.name = (type) SDL_LoadFunction(so, #real_name); \
|
|
|
|
if (!fluid.name) \
|
|
|
|
goto fail;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
FLUID_FUNCS
|
|
|
|
FLUID_FUNCS2
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
#ifndef SHARED_FLUID
|
|
|
|
fail:
|
|
|
|
Debug() << "Failed to load " FLUID_LIB ". Midi playback is disabled.";
|
|
|
|
|
|
|
|
memset(&fluid, 0, sizeof(fluid));
|
|
|
|
SDL_UnloadObject(so);
|
2014-10-20 08:17:48 +00:00
|
|
|
so = 0;
|
2014-09-07 03:23:10 +00:00
|
|
|
#endif
|
|
|
|
}
|