diff options
author | Chris Robinson <[email protected]> | 2010-11-29 20:17:15 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-11-29 20:17:15 -0800 |
commit | 51ed22afb9ed0ac3a379432f2e457253e8a533ac (patch) | |
tree | b4ebb98a6483a624e855dd3a08fb7acbade0d011 /OpenAL32 | |
parent | 0cf32e29465830e7d79eb3d40bb85e328d43625a (diff) |
Combine two switch blocks
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/alBuffer.c | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index b6ded027..f60bd399 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -415,6 +415,8 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid */ AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const ALvoid *data,ALsizei offset,ALsizei length) { + enum SrcFmtChannels SrcChannels; + enum SrcFmtType SrcType; ALCcontext *Context; ALCdevice *device; ALbuffer *ALBuf; @@ -454,11 +456,13 @@ AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const 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: @@ -480,49 +484,36 @@ AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const case AL_FORMAT_71CHN8: case AL_FORMAT_71CHN16: case AL_FORMAT_71CHN32: - case AL_FORMAT_71CHN_MULAW: { - enum SrcFmtChannels SrcChannels; - enum SrcFmtType SrcType; - + case AL_FORMAT_71CHN_MULAW: DecomposeInputFormat(format, &SrcChannels, &SrcType); if(SrcChannels != ALBuf->OriginalChannels || SrcType != ALBuf->OriginalType) alSetError(Context, AL_INVALID_ENUM); - else + else if(SrcType == SrcFmtIMA4) { - ALuint OldBytes = BytesFromFmt(SrcType); + ALuint Channels = ChannelsFromFmt(ALBuf->FmtChannels); ALuint Bytes = BytesFromFmt(ALBuf->FmtType); - offset /= OldBytes; + /* offset -> byte offset, length -> block count */ + offset /= 36; + offset *= 65; offset *= Bytes; - length /= OldBytes; + length /= ALBuf->OriginalAlign; - ConvertData(&((ALubyte*)ALBuf->data)[offset], ALBuf->FmtType, - data, SrcType, length); + ConvertDataIMA4(&((ALubyte*)ALBuf->data)[offset], data, Channels, length); } - } break; - - case AL_FORMAT_MONO_IMA4: - case AL_FORMAT_STEREO_IMA4: { - enum SrcFmtChannels SrcChannels; - enum SrcFmtType SrcType; - - DecomposeInputFormat(format, &SrcChannels, &SrcType); - if(SrcChannels != ALBuf->OriginalChannels || SrcType != SrcFmtIMA4) - alSetError(Context, AL_INVALID_ENUM); else { - ALuint Channels = ChannelsFromFmt(ALBuf->FmtChannels); + ALuint OldBytes = BytesFromFmt(SrcType); ALuint Bytes = BytesFromFmt(ALBuf->FmtType); - /* offset -> byte offset, length -> block count */ - offset /= 36; - offset *= 65; + offset /= OldBytes; offset *= Bytes; - length /= ALBuf->OriginalAlign; + length /= OldBytes; - ConvertDataIMA4(&((ALubyte*)ALBuf->data)[offset], data, Channels, length); + ConvertData(&((ALubyte*)ALBuf->data)[offset], ALBuf->FmtType, + data, SrcType, length); } - } break; + break; default: alSetError(Context, AL_INVALID_ENUM); |