aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2013-12-25 22:39:38 -0800
committerChris Robinson <[email protected]>2013-12-25 22:39:38 -0800
commit35f9e35aa361c6f1f05539cb2ca01508fdd1ce59 (patch)
tree4e25f5903785bccbb191c5d67f8eedafccd41023 /OpenAL32
parentb5ae424dbd400abf6287cad94bea77143d0dcc2a (diff)
Add methods to set and get sounds on a preset
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alMain.h4
-rw-r--r--OpenAL32/alPreset.c62
2 files changed, 66 insertions, 0 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 2718b6c0..1673e8be 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -35,6 +35,8 @@
#define AL_MIDI_BANK_SOFT 0x9996
#define AL_PRESETS_SIZE_SOFT 0x9995
#define AL_PRESETS_SOFT 0x9994
+#define AL_FONTSOUNDS_SIZE_SOFT 0x9993
+#define AL_FONTSOUNDS_SOFT 0x9992
#define AL_FORMAT_TYPE_SOFT 0x1991
#define AL_NOTEOFF_SOFT 0x0080
#define AL_NOTEON_SOFT 0x0090
@@ -56,6 +58,7 @@ typedef void (AL_APIENTRY*LPALDELETEPRESETSSOFT)(ALsizei n, const ALuint *ids);
typedef ALboolean (AL_APIENTRY*LPALISPRESETSOFT)(ALuint id);
typedef void (AL_APIENTRY*LPALPRESETISOFT)(ALuint id, ALenum param, ALint value);
typedef void (AL_APIENTRY*LPALPRESETIVSOFT)(ALuint id, ALenum param, const ALint *values);
+typedef void (AL_APIENTRY*LPALPRESETFONTSOUNDSSOFT)(ALuint id, ALsizei count, const ALuint *fsids);
typedef void (AL_APIENTRY*LPALGETPRESETIVSOFT)(ALuint id, ALenum param, ALint *values);
typedef void (AL_APIENTRY*LPALGENFONTSOUNDSSOFT)(ALsizei n, ALuint *ids);
typedef void (AL_APIENTRY*LPALDELETEFONTSOUNDSSOFT)(ALsizei n, const ALuint *ids);
@@ -86,6 +89,7 @@ AL_API ALboolean AL_APIENTRY alIsPresetSOFT(ALuint id);
AL_API void AL_APIENTRY alPresetiSOFT(ALuint id, ALenum param, ALint value);
AL_API void AL_APIENTRY alPresetivSOFT(ALuint id, ALenum param, const ALint *values);
AL_API void AL_APIENTRY alGetPresetivSOFT(ALuint id, ALenum param, ALint *values);
+AL_API void AL_APIENTRY alPresetFontsoundsSOFT(ALuint id, ALsizei count, const ALuint *fsids);
AL_API void AL_APIENTRY alGenFontsoundsSOFT(ALsizei n, ALuint *ids);
AL_API void AL_APIENTRY alDeleteFontsoundsSOFT(ALsizei n, const ALuint *ids);
diff --git a/OpenAL32/alPreset.c b/OpenAL32/alPreset.c
index 6592f26b..fda06e95 100644
--- a/OpenAL32/alPreset.c
+++ b/OpenAL32/alPreset.c
@@ -186,6 +186,7 @@ AL_API void AL_APIENTRY alGetPresetivSOFT(ALuint id, ALenum param, ALint *values
ALCdevice *device;
ALCcontext *context;
ALsfpreset *preset;
+ ALsizei i;
context = GetContextRef();
if(!context) return;
@@ -205,6 +206,15 @@ AL_API void AL_APIENTRY alGetPresetivSOFT(ALuint id, ALenum param, ALint *values
values[0] = preset->Bank;
break;
+ case AL_FONTSOUNDS_SIZE_SOFT:
+ values[0] = preset->NumSounds;
+ break;
+
+ case AL_FONTSOUNDS_SOFT:
+ for(i = 0;i < preset->NumSounds;i++)
+ values[i] = preset->Sounds[i]->id;
+ break;
+
default:
SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
}
@@ -213,6 +223,58 @@ done:
ALCcontext_DecRef(context);
}
+AL_API void AL_APIENTRY alPresetFontsoundsSOFT(ALuint id, ALsizei count, const ALuint *fsids)
+{
+ ALCdevice *device;
+ ALCcontext *context;
+ ALsfpreset *preset;
+ ALfontsound **sounds;
+ ALsizei i;
+
+ context = GetContextRef();
+ if(!context) return;
+
+ device = context->Device;
+ if(!(preset=LookupPreset(device, id)))
+ SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
+ if(count < 0)
+ SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+
+ if(preset->ref != 0)
+ SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done);
+
+ if(count == 0)
+ sounds = NULL;
+ else
+ {
+ sounds = calloc(count, sizeof(sounds[0]));
+ if(!sounds)
+ SET_ERROR_AND_GOTO(context, AL_OUT_OF_MEMORY, done);
+
+ for(i = 0;i < count;i++)
+ {
+ if(!(sounds[i]=LookupFontsound(device, fsids[i])))
+ {
+ free(sounds);
+ SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
+ }
+ }
+ }
+
+ for(i = 0;i < count;i++)
+ IncrementRef(&sounds[i]->ref);
+
+ sounds = ExchangePtr((XchgPtr*)&preset->Sounds, sounds);
+ count = ExchangeInt(&preset->NumSounds, count);
+
+ for(i = 0;i < count;i++)
+ DecrementRef(&sounds[i]->ref);
+ free(sounds);
+
+done:
+ ALCcontext_DecRef(context);
+}
+
/* ReleaseALPresets
*