Make LoadData return an error if the dst format is not valid or compatible

This commit is contained in:
Chris Robinson
2011-03-16 19:39:31 -07:00
parent be37f10fed
commit 898b245bb2
+4 -9
View File
@@ -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);