aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALc.c13
-rw-r--r--Alc/midi/base.c47
-rw-r--r--CMakeLists.txt1
-rw-r--r--OpenAL32/Include/alMain.h11
-rw-r--r--OpenAL32/Include/alMidi.h39
-rw-r--r--OpenAL32/alFontsound.c134
6 files changed, 245 insertions, 0 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index c9b46e20..f1e92cec 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -298,6 +298,9 @@ static const ALCfunction alcFunctions[] = {
DECL(alGenInstrumentsSOFT),
DECL(alDeleteInstrumentsSOFT),
DECL(alIsInstrumentSOFT),
+ DECL(alGenFontsoundsSOFT),
+ DECL(alDeleteFontsoundsSOFT),
+ DECL(alIsFontsoundSOFT),
DECL(alMidiSoundfontSOFT),
DECL(alMidiEventSOFT),
DECL(alMidiSysExSOFT),
@@ -1984,6 +1987,13 @@ static ALCvoid FreeDevice(ALCdevice *device)
}
ResetUIntMap(&device->InstrumentMap);
+ if(device->FontsoundMap.size > 0)
+ {
+ WARN("(%p) Deleting %d Fontsound(s)\n", device, device->FontsoundMap.size);
+ ReleaseALFontsounds(device);
+ }
+ ResetUIntMap(&device->FontsoundMap);
+
free(device->Bs2b);
device->Bs2b = NULL;
@@ -2923,6 +2933,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
InitUIntMap(&device->SfontMap, ~0);
InitUIntMap(&device->PresetMap, ~0);
InitUIntMap(&device->InstrumentMap, ~0);
+ InitUIntMap(&device->FontsoundMap, ~0);
//Set output format
device->FmtChans = DevFmtChannelsDefault;
@@ -3210,6 +3221,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName,
InitUIntMap(&device->SfontMap, ~0);
InitUIntMap(&device->PresetMap, ~0);
InitUIntMap(&device->InstrumentMap, ~0);
+ InitUIntMap(&device->FontsoundMap, ~0);
device->DeviceName = NULL;
@@ -3390,6 +3402,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN
InitUIntMap(&device->SfontMap, ~0);
InitUIntMap(&device->PresetMap, ~0);
InitUIntMap(&device->InstrumentMap, ~0);
+ InitUIntMap(&device->FontsoundMap, ~0);
factory = ALCloopbackFactory_getFactory();
device->Backend = V(factory,createBackend)(device, ALCbackend_Loopback);
diff --git a/Alc/midi/base.c b/Alc/midi/base.c
index 0d81952b..33c39133 100644
--- a/Alc/midi/base.c
+++ b/Alc/midi/base.c
@@ -421,6 +421,53 @@ void ALsfinstrument_Destruct(ALsfinstrument *self)
}
+void ALfontsound_Construct(ALfontsound *self)
+{
+ self->ref = 0;
+
+ self->MinKey = 0;
+ self->MaxKey = 127;
+ self->MinVelocity = 0;
+ self->MaxVelocity = 127;
+
+ self->Generators = NULL;
+ self->NumGenerators = 0;
+ self->GeneratorsMax = 0;
+
+ self->Modulators = NULL;
+ self->NumModulators = 0;
+ self->ModulatorsMax = 0;
+
+ self->Start = 0;
+ self->End = 0;
+ self->LoopStart = 0;
+ self->LoopEnd = 0;
+ self->SampleRate = 0;
+ self->PitchKey = 0;
+ self->PitchCorrection = 0;
+ self->SampleLink = 0;
+ self->SampleType = AL_NONE;
+
+ self->id = 0;
+}
+
+void ALfontsound_Destruct(ALfontsound *self)
+{
+ free(self->Modulators);
+ self->Modulators = NULL;
+ self->NumModulators = 0;
+ self->ModulatorsMax = 0;
+
+ free(self->Generators);
+ self->Generators = NULL;
+ self->NumGenerators = 0;
+ self->GeneratorsMax = 0;
+
+ FreeThunkEntry(self->id);
+ self->id = 0;
+}
+
+
void ALsfpreset_Construct(ALsfpreset *self)
{
self->ref = 0;
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c5019323..f335a899 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -491,6 +491,7 @@ SET(OPENAL_OBJS OpenAL32/alAuxEffectSlot.c
OpenAL32/alError.c
OpenAL32/alExtension.c
OpenAL32/alFilter.c
+ OpenAL32/alFontsound.c
OpenAL32/alInstrument.c
OpenAL32/alListener.c
OpenAL32/alMidi.c
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 5e3cdc4f..aafe6c90 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -60,6 +60,9 @@ typedef void (AL_APIENTRY*LPALGETPRESETIVSOFT)(ALuint id, ALenum param, ALint *v
typedef void (AL_APIENTRY*LPALGENINSTRUMENTSSOFT)(ALsizei n, ALuint *ids);
typedef void (AL_APIENTRY*LPALDELETEINSTRUMENTSSOFT)(ALsizei n, const ALuint *ids);
typedef ALboolean (AL_APIENTRY*LPALISINSTRUMENTSOFT)(ALuint id);
+typedef void (AL_APIENTRY*LPALGENFONTSOUNDSSOFT)(ALsizei n, ALuint *ids);
+typedef void (AL_APIENTRY*LPALDELETEFONTSOUNDSSOFT)(ALsizei n, const ALuint *ids);
+typedef ALboolean (AL_APIENTRY*LPALISFONTSOUNDSOFT)(ALuint id);
typedef void (AL_APIENTRY*LPALMIDISOUNDFONTSOFT)(const char *filename);
typedef void (AL_APIENTRY*LPALMIDIEVENTSOFT)(ALuint64SOFT time, ALenum event, ALsizei channel, ALsizei param1, ALsizei param2);
typedef void (AL_APIENTRY*LPALMIDISYSEXSOFT)(ALuint64SOFT time, const ALbyte *data, ALsizei size);
@@ -90,6 +93,11 @@ AL_API void AL_APIENTRY alGetPresetivSOFT(ALuint id, ALenum param, ALint *values
AL_API void AL_APIENTRY alGenInstrumentsSOFT(ALsizei n, ALuint *ids);
AL_API void AL_APIENTRY alDeleteInstrumentsSOFT(ALsizei n, const ALuint *ids);
AL_API ALboolean AL_APIENTRY alIsInstrumentSOFT(ALuint id);
+
+AL_API void AL_APIENTRY alGenFontsoundsSOFT(ALsizei n, ALuint *ids);
+AL_API void AL_APIENTRY alDeleteFontsoundsSOFT(ALsizei n, const ALuint *ids);
+AL_API ALboolean AL_APIENTRY alIsFontsoundSOFT(ALuint id);
+
AL_API void AL_APIENTRY alMidiSoundfontSOFT(const char *filename);
AL_API void AL_APIENTRY alMidiEventSOFT(ALuint64SOFT time, ALenum event, ALsizei channel, ALsizei param1, ALsizei param2);
AL_API void AL_APIENTRY alMidiSysExSOFT(ALuint64SOFT time, const ALbyte *data, ALsizei size);
@@ -472,6 +480,9 @@ struct ALCdevice_struct
// Map of Instruments for this device
UIntMap InstrumentMap;
+ // Map of Fontsounds for this device
+ UIntMap FontsoundMap;
+
/* MIDI synth engine */
struct MidiSynth *Synth;
diff --git a/OpenAL32/Include/alMidi.h b/OpenAL32/Include/alMidi.h
index b37a6546..374940c1 100644
--- a/OpenAL32/Include/alMidi.h
+++ b/OpenAL32/Include/alMidi.h
@@ -84,6 +84,45 @@ inline struct ALsfinstrument *RemoveInstrument(ALCdevice *device, ALuint id)
void ReleaseALInstruments(ALCdevice *device);
+typedef struct ALfontsound {
+ volatile RefCount ref;
+
+ ALint MinKey, MaxKey;
+ ALint MinVelocity, MaxVelocity;
+
+ ALsfgenerator *Generators;
+ ALsizei NumGenerators;
+ ALsizei GeneratorsMax;
+
+ ALsfmodulator *Modulators;
+ ALsizei NumModulators;
+ ALsizei ModulatorsMax;
+
+ ALuint Start;
+ ALuint End;
+ ALuint LoopStart;
+ ALuint LoopEnd;
+ ALuint SampleRate;
+ ALubyte PitchKey;
+ ALbyte PitchCorrection;
+ ALint SampleLink;
+ ALenum SampleType;
+
+ ALuint id;
+} ALfontsound;
+
+void ALfontsound_Construct(ALfontsound *self);
+void ALfontsound_Destruct(ALfontsound *self);
+
+
+inline struct ALfontsound *LookupFontsound(ALCdevice *device, ALuint id)
+{ return (struct ALfontsound*)LookupUIntMapKey(&device->FontsoundMap, id); }
+inline struct ALfontsound *RemoveFontsound(ALCdevice *device, ALuint id)
+{ return (struct ALfontsound*)RemoveUIntMapKey(&device->FontsoundMap, id); }
+
+void ReleaseALFontsounds(ALCdevice *device);
+
+
typedef struct ALsfpreset {
volatile RefCount ref;
diff --git a/OpenAL32/alFontsound.c b/OpenAL32/alFontsound.c
new file mode 100644
index 00000000..bfb2e6da
--- /dev/null
+++ b/OpenAL32/alFontsound.c
@@ -0,0 +1,134 @@
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "alMain.h"
+#include "alMidi.h"
+#include "alError.h"
+#include "alThunk.h"
+
+#include "midi/base.h"
+
+
+extern inline struct ALfontsound *LookupFontsound(ALCdevice *device, ALuint id);
+extern inline struct ALfontsound *RemoveFontsound(ALCdevice *device, ALuint id);
+
+
+AL_API void AL_APIENTRY alGenFontsoundsSOFT(ALsizei n, ALuint *ids)
+{
+ ALCdevice *device;
+ ALCcontext *context;
+ ALsizei cur = 0;
+ ALenum err;
+
+ context = GetContextRef();
+ if(!context) return;
+
+ if(!(n >= 0))
+ SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+
+ device = context->Device;
+ for(cur = 0;cur < n;cur++)
+ {
+ ALfontsound *inst = calloc(1, sizeof(ALfontsound));
+ if(!inst)
+ {
+ alDeleteFontsoundsSOFT(cur, ids);
+ SET_ERROR_AND_GOTO(context, AL_OUT_OF_MEMORY, done);
+ }
+ ALfontsound_Construct(inst);
+
+ err = NewThunkEntry(&inst->id);
+ if(err == AL_NO_ERROR)
+ err = InsertUIntMapEntry(&device->FontsoundMap, inst->id, inst);
+ if(err != AL_NO_ERROR)
+ {
+ ALfontsound_Destruct(inst);
+ memset(inst, 0, sizeof(*inst));
+ free(inst);
+
+ alDeleteFontsoundsSOFT(cur, ids);
+ SET_ERROR_AND_GOTO(context, err, done);
+ }
+
+ ids[cur] = inst->id;
+ }
+
+done:
+ ALCcontext_DecRef(context);
+}
+
+AL_API ALvoid AL_APIENTRY alDeleteFontsoundsSOFT(ALsizei n, const ALuint *ids)
+{
+ ALCdevice *device;
+ ALCcontext *context;
+ ALfontsound *inst;
+ ALsizei i;
+
+ context = GetContextRef();
+ if(!context) return;
+
+ if(!(n >= 0))
+ SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+
+ device = context->Device;
+ for(i = 0;i < n;i++)
+ {
+ /* Check for valid ID */
+ if((inst=LookupFontsound(device, ids[i])) == NULL)
+ SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
+ if(inst->ref != 0)
+ SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done);
+ }
+
+ for(i = 0;i < n;i++)
+ {
+ if((inst=RemoveFontsound(device, ids[i])) == NULL)
+ continue;
+
+ ALfontsound_Destruct(inst);
+
+ memset(inst, 0, sizeof(*inst));
+ free(inst);
+ }
+
+done:
+ ALCcontext_DecRef(context);
+}
+
+AL_API ALboolean AL_APIENTRY alIsFontsoundSOFT(ALuint id)
+{
+ ALCcontext *context;
+ ALboolean ret;
+
+ context = GetContextRef();
+ if(!context) return AL_FALSE;
+
+ ret = LookupFontsound(context->Device, id) ? AL_TRUE : AL_FALSE;
+
+ ALCcontext_DecRef(context);
+
+ return ret;
+}
+
+
+/* ReleaseALFontsounds
+ *
+ * Called to destroy any fontsounds that still exist on the device
+ */
+void ReleaseALFontsounds(ALCdevice *device)
+{
+ ALsizei i;
+ for(i = 0;i < device->FontsoundMap.size;i++)
+ {
+ ALfontsound *temp = device->FontsoundMap.array[i].value;
+ device->FontsoundMap.array[i].value = NULL;
+
+ ALfontsound_Destruct(temp);
+
+ memset(temp, 0, sizeof(*temp));
+ free(temp);
+ }
+}