diff options
author | Chris Robinson <[email protected]> | 2014-03-22 01:49:03 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-03-22 01:49:03 -0700 |
commit | 22f6eb18a24c91e0e8a9c060de5690533e075429 (patch) | |
tree | 5739f13936fee434e89ab4a581c3179c0cd71692 | |
parent | d8bfd12d313372830f0e0b34fafcaa244395cf3c (diff) |
Use a void* for the MidiSynth Delete method param
-rw-r--r-- | Alc/midi/base.h | 5 | ||||
-rw-r--r-- | Alc/midi/dummy.c | 11 | ||||
-rw-r--r-- | Alc/midi/fluidsynth.c | 11 |
3 files changed, 9 insertions, 18 deletions
diff --git a/Alc/midi/base.h b/Alc/midi/base.h index 4d13a054..1e1aca4f 100644 --- a/Alc/midi/base.h +++ b/Alc/midi/base.h @@ -88,7 +88,7 @@ struct MidiSynthVtable { void (*const update)(MidiSynth *self, ALCdevice *device); void (*const process)(MidiSynth *self, ALuint samples, ALfloat (*restrict DryBuffer)[BUFFERSIZE]); - void (*const Delete)(MidiSynth *self); + void (*const Delete)(void *ptr); }; #define DEFINE_MIDISYNTH_VTABLE(T) \ @@ -100,7 +100,8 @@ DECLARE_THUNK(T, MidiSynth, void, stop) \ DECLARE_THUNK(T, MidiSynth, void, reset) \ DECLARE_THUNK1(T, MidiSynth, void, update, ALCdevice*) \ DECLARE_THUNK2(T, MidiSynth, void, process, ALuint, ALfloatBUFFERSIZE*restrict) \ -DECLARE_THUNK(T, MidiSynth, void, Delete) \ +static void T##_MidiSynth_Delete(void *ptr) \ +{ T##_Delete(STATIC_UPCAST(T, MidiSynth, ptr)); } \ \ static const struct MidiSynthVtable T##_MidiSynth_vtable = { \ T##_MidiSynth_Destruct, \ diff --git a/Alc/midi/dummy.c b/Alc/midi/dummy.c index 79f82b87..07121051 100644 --- a/Alc/midi/dummy.c +++ b/Alc/midi/dummy.c @@ -27,7 +27,7 @@ static DECLARE_FORWARD(DSynth, MidiSynth, void, stop) static DECLARE_FORWARD(DSynth, MidiSynth, void, reset) static DECLARE_FORWARD1(DSynth, MidiSynth, void, update, ALCdevice*) static void DSynth_process(DSynth *self, ALuint SamplesToDo, ALfloat (*restrict DryBuffer)[BUFFERSIZE]); -static void DSynth_Delete(DSynth *self); +DECLARE_DEFAULT_ALLOCATORS(DSynth) DEFINE_MIDISYNTH_VTABLE(DSynth); @@ -63,20 +63,15 @@ static void DSynth_process(DSynth *self, ALuint SamplesToDo, ALfloatBUFFERSIZE*r } -static void DSynth_Delete(DSynth *self) -{ - free(self); -} - - MidiSynth *DSynth_create(ALCdevice *device) { - DSynth *synth = calloc(1, sizeof(*synth)); + DSynth *synth = DSynth_New(sizeof(*synth)); if(!synth) { ERR("Failed to allocate DSynth\n"); return NULL; } + memset(synth, 0, sizeof(*synth)); DSynth_Construct(synth, device); return STATIC_CAST(MidiSynth, synth); } diff --git a/Alc/midi/fluidsynth.c b/Alc/midi/fluidsynth.c index d4e594e6..504b42ec 100644 --- a/Alc/midi/fluidsynth.c +++ b/Alc/midi/fluidsynth.c @@ -476,7 +476,7 @@ static void FSynth_reset(FSynth *self); static void FSynth_update(FSynth *self, ALCdevice *device); static void FSynth_processQueue(FSynth *self, ALuint64 time); static void FSynth_process(FSynth *self, ALuint SamplesToDo, ALfloat (*restrict DryBuffer)[BUFFERSIZE]); -static void FSynth_Delete(FSynth *self); +DECLARE_DEFAULT_ALLOCATORS(FSynth) DEFINE_MIDISYNTH_VTABLE(FSynth); static fluid_sfont_t *FSynth_loadSfont(fluid_sfloader_t *loader, const char *filename); @@ -798,20 +798,15 @@ static void FSynth_process(FSynth *self, ALuint SamplesToDo, ALfloat (*restrict } -static void FSynth_Delete(FSynth *self) -{ - free(self); -} - - MidiSynth *FSynth_create(ALCdevice *device) { - FSynth *synth = calloc(1, sizeof(*synth)); + FSynth *synth = FSynth_New(sizeof(*synth)); if(!synth) { ERR("Failed to allocate FSynth\n"); return NULL; } + memset(synth, 0, sizeof(*synth)); FSynth_Construct(synth, device); if(FSynth_init(synth, device) == AL_FALSE) |