music_fluidsynth.c
changeset 786 12a659c8b902
parent 777 92882ef2ab81
child 797 b4b6adff699a
equal deleted inserted replaced
785:e391c406adbd 786:12a659c8b902
    59 static fluidsynth_loader fluidsynth = {
    59 static fluidsynth_loader fluidsynth = {
    60     0, NULL
    60     0, NULL
    61 };
    61 };
    62 
    62 
    63 #ifdef FLUIDSYNTH_DYNAMIC
    63 #ifdef FLUIDSYNTH_DYNAMIC
    64 #define FLUIDSYNTH_LOADER(FUNC, SIG) \
    64 #define FUNCTION_LOADER(FUNC, SIG) \
    65     fluidsynth.FUNC = (SIG) SDL_LoadFunction(fluidsynth.handle, #FUNC); \
    65     fluidsynth.FUNC = (SIG) SDL_LoadFunction(fluidsynth.handle, #FUNC); \
    66     if (fluidsynth.FUNC == NULL) { SDL_UnloadObject(fluidsynth.handle); return -1; }
    66     if (fluidsynth.FUNC == NULL) { SDL_UnloadObject(fluidsynth.handle); return -1; }
    67 #else
    67 #else
    68 #define FLUIDSYNTH_LOADER(FUNC, SIG) \
    68 #define FUNCTION_LOADER(FUNC, SIG) \
    69     fluidsynth.FUNC = FUNC;
    69     fluidsynth.FUNC = FUNC;
    70 #endif
    70 #endif
    71 
    71 
    72 static int FLUIDSYNTH_Load()
    72 static int FLUIDSYNTH_Load()
    73 {
    73 {
    74     if (fluidsynth.loaded == 0) {
    74     if (fluidsynth.loaded == 0) {
    75 #ifdef FLUIDSYNTH_DYNAMIC
    75 #ifdef FLUIDSYNTH_DYNAMIC
    76         fluidsynth.handle = SDL_LoadObject(FLUIDSYNTH_DYNAMIC);
    76         fluidsynth.handle = SDL_LoadObject(FLUIDSYNTH_DYNAMIC);
    77         if (fluidsynth.handle == NULL) return -1;
    77         if (fluidsynth.handle == NULL) {
       
    78             return -1;
       
    79         }
    78 #endif
    80 #endif
    79 
    81 
    80         FLUIDSYNTH_LOADER(delete_fluid_player, int (*)(fluid_player_t*));
    82         FUNCTION_LOADER(delete_fluid_player, int (*)(fluid_player_t*))
    81         FLUIDSYNTH_LOADER(delete_fluid_settings, void (*)(fluid_settings_t*));
    83         FUNCTION_LOADER(delete_fluid_settings, void (*)(fluid_settings_t*))
    82         FLUIDSYNTH_LOADER(delete_fluid_synth, int (*)(fluid_synth_t*));
    84         FUNCTION_LOADER(delete_fluid_synth, int (*)(fluid_synth_t*))
    83         FLUIDSYNTH_LOADER(fluid_player_add, int (*)(fluid_player_t*, const char*));
    85         FUNCTION_LOADER(fluid_player_add, int (*)(fluid_player_t*, const char*))
    84         FLUIDSYNTH_LOADER(fluid_player_add_mem, int (*)(fluid_player_t*, const void*, size_t));
    86         FUNCTION_LOADER(fluid_player_add_mem, int (*)(fluid_player_t*, const void*, size_t))
    85         FLUIDSYNTH_LOADER(fluid_player_get_status, int (*)(fluid_player_t*));
    87         FUNCTION_LOADER(fluid_player_get_status, int (*)(fluid_player_t*))
    86         FLUIDSYNTH_LOADER(fluid_player_play, int (*)(fluid_player_t*));
    88         FUNCTION_LOADER(fluid_player_play, int (*)(fluid_player_t*))
    87         FLUIDSYNTH_LOADER(fluid_player_set_loop, int (*)(fluid_player_t*, int));
    89         FUNCTION_LOADER(fluid_player_set_loop, int (*)(fluid_player_t*, int))
    88         FLUIDSYNTH_LOADER(fluid_player_stop, int (*)(fluid_player_t*));
    90         FUNCTION_LOADER(fluid_player_stop, int (*)(fluid_player_t*))
    89         FLUIDSYNTH_LOADER(fluid_settings_setnum, int (*)(fluid_settings_t*, const char*, double));
    91         FUNCTION_LOADER(fluid_settings_setnum, int (*)(fluid_settings_t*, const char*, double))
    90         FLUIDSYNTH_LOADER(fluid_synth_get_settings, fluid_settings_t* (*)(fluid_synth_t*));
    92         FUNCTION_LOADER(fluid_synth_get_settings, fluid_settings_t* (*)(fluid_synth_t*))
    91         FLUIDSYNTH_LOADER(fluid_synth_set_gain, void (*)(fluid_synth_t*, float));
    93         FUNCTION_LOADER(fluid_synth_set_gain, void (*)(fluid_synth_t*, float))
    92         FLUIDSYNTH_LOADER(fluid_synth_sfload, int(*)(fluid_synth_t*, const char*, int));
    94         FUNCTION_LOADER(fluid_synth_sfload, int(*)(fluid_synth_t*, const char*, int))
    93         FLUIDSYNTH_LOADER(fluid_synth_write_s16, int(*)(fluid_synth_t*, int, void*, int, int, void*, int, int));
    95         FUNCTION_LOADER(fluid_synth_write_s16, int(*)(fluid_synth_t*, int, void*, int, int, void*, int, int))
    94         FLUIDSYNTH_LOADER(new_fluid_player, fluid_player_t* (*)(fluid_synth_t*));
    96         FUNCTION_LOADER(new_fluid_player, fluid_player_t* (*)(fluid_synth_t*))
    95         FLUIDSYNTH_LOADER(new_fluid_settings, fluid_settings_t* (*)(void));
    97         FUNCTION_LOADER(new_fluid_settings, fluid_settings_t* (*)(void))
    96         FLUIDSYNTH_LOADER(new_fluid_synth, fluid_synth_t* (*)(fluid_settings_t*));
    98         FUNCTION_LOADER(new_fluid_synth, fluid_synth_t* (*)(fluid_settings_t*))
    97     }
    99     }
    98     ++fluidsynth.loaded;
   100     ++fluidsynth.loaded;
    99 
   101 
   100     return 0;
   102     return 0;
   101 }
   103 }