diff options
author | Chris Robinson <[email protected]> | 2011-03-16 19:39:31 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-03-16 19:39:31 -0700 |
commit | 898b245bb2b011527a2f83d636252f4bced07a36 (patch) | |
tree | c56a10985893e41834f83f68554da16360ece971 | |
parent | be37f10feded3ed626194ed626d62bb23e010de4 (diff) |
Make LoadData return an error if the dst format is not valid or compatible
-rw-r--r-- | OpenAL32/alBuffer.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index 30402ee1..7472f4b8 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -468,8 +468,6 @@ AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer, ALuint samplerate, ALenum internalformat, ALsizei frames, ALenum channels, ALenum type, const ALvoid *data) { - enum FmtChannels DstChannels; - enum FmtType DstType; ALCcontext *Context; ALCdevice *device; ALbuffer *ALBuf; @@ -500,12 +498,8 @@ AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer, alSetError(Context, AL_INVALID_VALUE); else if(frames < 0 || samplerate == 0) alSetError(Context, AL_INVALID_VALUE); - else if(DecomposeFormat(internalformat, &DstChannels, &DstType) == AL_FALSE) - alSetError(Context, AL_INVALID_ENUM); else if(IsValidType(type) == AL_FALSE || IsValidChannels(channels) == AL_FALSE) alSetError(Context, AL_INVALID_ENUM); - else if(channels != (ALenum)DstChannels) - alSetError(Context, AL_INVALID_ENUM); else { err = AL_NO_ERROR; @@ -1710,12 +1704,13 @@ static ALenum LoadData(ALbuffer *ALBuf, ALuint freq, ALenum NewFormat, ALsizei f ALuint64 newsize; ALvoid *temp; - DecomposeFormat(NewFormat, &DstChannels, &DstType); + if(DecomposeFormat(NewFormat, &DstChannels, &DstType) == AL_FALSE || + (long)SrcChannels != (long)DstChannels) + return AL_INVALID_ENUM; + NewChannels = ChannelsFromFmt(DstChannels); NewBytes = BytesFromFmt(DstType); - assert((long)SrcChannels == (long)DstChannels); - if(SrcType == UserFmtIMA4) { ALuint OrigChannels = ChannelsFromUserFmt(SrcChannels); |