diff options
author | Chris Robinson <[email protected]> | 2010-11-29 22:01:54 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-11-29 22:01:54 -0800 |
commit | e800f8c0a72ee2681d3660ce1b1a67a48e9d77da (patch) | |
tree | f454c8da8821e9877019a4ed032ec9996fa2d007 /OpenAL32 | |
parent | d02dbef9d2e2d346d9df886b66cdeb4ee092537a (diff) |
Let DecomposeInputType verify the format passed to alBufferSubDataSOFT
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/alBuffer.c | 90 |
1 files changed, 26 insertions, 64 deletions
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index 8562e623..50d7369f 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -416,80 +416,42 @@ AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const alSetError(Context, AL_INVALID_NAME); else if(length < 0 || offset < 0 || (length > 0 && data == NULL)) alSetError(Context, AL_INVALID_VALUE); + else if(DecomposeInputFormat(format, &SrcChannels, &SrcType) == AL_FALSE || + SrcChannels != ALBuf->OriginalChannels || + SrcType != ALBuf->OriginalType) + alSetError(Context, AL_INVALID_ENUM); else if(offset > ALBuf->OriginalSize || length > ALBuf->OriginalSize-offset || (offset%ALBuf->OriginalAlign) != 0 || (length%ALBuf->OriginalAlign) != 0) alSetError(Context, AL_INVALID_VALUE); - else switch(format) + else { - case AL_FORMAT_MONO8: - case AL_FORMAT_MONO16: - case AL_FORMAT_MONO_FLOAT32: - case AL_FORMAT_MONO_DOUBLE_EXT: - case AL_FORMAT_MONO_MULAW: - case AL_FORMAT_MONO_IMA4: - case AL_FORMAT_STEREO8: - case AL_FORMAT_STEREO16: - case AL_FORMAT_STEREO_FLOAT32: - case AL_FORMAT_STEREO_DOUBLE_EXT: - case AL_FORMAT_STEREO_MULAW: - case AL_FORMAT_STEREO_IMA4: - case AL_FORMAT_QUAD8_LOKI: - case AL_FORMAT_QUAD16_LOKI: - case AL_FORMAT_QUAD8: - case AL_FORMAT_QUAD16: - case AL_FORMAT_QUAD32: - case AL_FORMAT_QUAD_MULAW: - case AL_FORMAT_REAR8: - case AL_FORMAT_REAR16: - case AL_FORMAT_REAR32: - case AL_FORMAT_REAR_MULAW: - case AL_FORMAT_51CHN8: - case AL_FORMAT_51CHN16: - case AL_FORMAT_51CHN32: - case AL_FORMAT_51CHN_MULAW: - case AL_FORMAT_61CHN8: - case AL_FORMAT_61CHN16: - case AL_FORMAT_61CHN32: - case AL_FORMAT_61CHN_MULAW: - case AL_FORMAT_71CHN8: - case AL_FORMAT_71CHN16: - case AL_FORMAT_71CHN32: - case AL_FORMAT_71CHN_MULAW: - DecomposeInputFormat(format, &SrcChannels, &SrcType); - if(SrcChannels != ALBuf->OriginalChannels || SrcType != ALBuf->OriginalType) - alSetError(Context, AL_INVALID_ENUM); - else if(SrcType == SrcFmtIMA4) - { - ALuint Channels = ChannelsFromFmt(ALBuf->FmtChannels); - ALuint Bytes = BytesFromFmt(ALBuf->FmtType); - - /* offset -> byte offset, length -> block count */ - offset /= 36; - offset *= 65; - offset *= Bytes; - length /= ALBuf->OriginalAlign; + if(SrcType == SrcFmtIMA4) + { + ALuint Channels = ChannelsFromFmt(ALBuf->FmtChannels); + ALuint Bytes = BytesFromFmt(ALBuf->FmtType); - ConvertDataIMA4(&((ALubyte*)ALBuf->data)[offset], data, Channels, length); - } - else - { - ALuint OldBytes = BytesFromFmt(SrcType); - ALuint Bytes = BytesFromFmt(ALBuf->FmtType); + /* offset -> byte offset, length -> block count */ + offset /= 36; + offset *= 65; + offset *= Bytes; + length /= ALBuf->OriginalAlign; - offset /= OldBytes; - offset *= Bytes; - length /= OldBytes; + ConvertDataIMA4(&((ALubyte*)ALBuf->data)[offset], data, Channels, length); + } + else + { + ALuint OldBytes = BytesFromFmt(SrcType); + ALuint Bytes = BytesFromFmt(ALBuf->FmtType); - ConvertData(&((ALubyte*)ALBuf->data)[offset], ALBuf->FmtType, - data, SrcType, length); - } - break; + offset /= OldBytes; + offset *= Bytes; + length /= OldBytes; - default: - alSetError(Context, AL_INVALID_ENUM); - break; + ConvertData(&((ALubyte*)ALBuf->data)[offset], ALBuf->FmtType, + data, SrcType, length); + } } ProcessContext(Context); |