From 5afc29f65dde15059e2511adbba466c15cc2e3b1 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 4 Jul 2014 11:18:32 -0700 Subject: Use a helper function to check valid MIDI controller inputs --- OpenAL32/Include/alMidi.h | 14 ++++++++++++++ OpenAL32/alFontsound.c | 5 +---- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'OpenAL32') diff --git a/OpenAL32/Include/alMidi.h b/OpenAL32/Include/alMidi.h index 76567db0..948fc319 100644 --- a/OpenAL32/Include/alMidi.h +++ b/OpenAL32/Include/alMidi.h @@ -157,6 +157,20 @@ inline struct ALsoundfont *RemoveSfont(ALCdevice *device, ALuint id) void ReleaseALSoundfonts(ALCdevice *device); + +inline ALboolean IsValidCtrlInput(int cc) +{ + /* These correspond to MIDI functions, not real controller values. */ + if(cc == 0 || cc == 6 || cc == 32 || cc == 38 || (cc >= 98 && cc <= 101) || cc >= 120) + return AL_FALSE; + /* These are the LSB components of CC0...CC31, which are automatically used when + * reading the MSB controller value. */ + if(cc >= 32 && cc <= 63) + return AL_FALSE; + /* All the rest are okay! */ + return AL_TRUE; +} + #ifdef __cplusplus } #endif diff --git a/OpenAL32/alFontsound.c b/OpenAL32/alFontsound.c index 1e2c303d..64c2a227 100644 --- a/OpenAL32/alFontsound.c +++ b/OpenAL32/alFontsound.c @@ -871,10 +871,7 @@ void ALfontsound_setModStagei(ALfontsound *self, ALCcontext *context, ALsizei st value == AL_NOTEON_KEY_SOFT || value == AL_KEYPRESSURE_SOFT || value == AL_CHANNELPRESSURE_SOFT || value == AL_PITCHBEND_SOFT || value == AL_PITCHBEND_SENSITIVITY_SOFT || - (value > 0 && value < 120 && !(value == 6 || (value >= 32 && value <= 63) || - (value >= 98 && value <= 101)) - ) - )) + IsValidCtrlInput(value))) SET_ERROR_AND_RETURN(context, AL_INVALID_VALUE); ALfontsound_getModStage(self, stage)->Source[srcidx].Input = value; break; -- cgit v1.2.3