diff options
author | Chris Robinson <[email protected]> | 2014-03-03 17:05:08 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-03-03 17:05:08 -0800 |
commit | c442c93a934a7c29c2d5450e0d2ca96ea766ea65 (patch) | |
tree | bbe4034ec7885e14be47bd92b160c07c7fbf4144 /OpenAL32/alBuffer.c | |
parent | ea8a85b19ce3c9786defaf22eab4dc4fd5011486 (diff) |
Store the original frame size alignment in the buffer
Diffstat (limited to 'OpenAL32/alBuffer.c')
-rw-r--r-- | OpenAL32/alBuffer.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index d9c91c2f..669fa219 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -429,10 +429,17 @@ AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer, ALenum format, cons SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done); WriteLock(&albuf->lock); - original_align = ((albuf->OriginalType == UserFmtIMA4) ? - (ChannelsFromUserFmt(albuf->OriginalChannels)*36) : - FrameSizeFromUserFmt(albuf->OriginalChannels, - albuf->OriginalType)); + if(albuf->OriginalType == UserFmtIMA4) + { + ALsizei align = (albuf->OriginalAlign-1)/2 + 4; + original_align = ChannelsFromUserFmt(albuf->OriginalChannels) * align; + } + else + { + original_align = FrameSizeFromUserFmt(albuf->OriginalChannels, + albuf->OriginalType) * + albuf->OriginalAlign; + } if(srcchannels != albuf->OriginalChannels || srctype != albuf->OriginalType) { @@ -451,8 +458,8 @@ AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer, ALenum format, cons /* offset -> byte offset, length -> sample count */ if(srctype == UserFmtIMA4) { - offset = offset/36*65 * bytes; - length = length/original_align * 65; + offset = offset/original_align * channels*bytes; + length = length/original_align * albuf->OriginalAlign; } else { @@ -1950,15 +1957,22 @@ static ALenum LoadData(ALbuffer *ALBuf, ALuint freq, ALenum NewFormat, ALsizei f ALBuf->OriginalChannels = SrcChannels; ALBuf->OriginalType = SrcType; if(SrcType == UserFmtIMA4) - ALBuf->OriginalSize = frames / 65 * 36 * ChannelsFromUserFmt(SrcChannels); + { + ALBuf->OriginalSize = frames / 65 * 36 * ChannelsFromUserFmt(SrcChannels); + ALBuf->OriginalAlign = 65; + } else - ALBuf->OriginalSize = frames * FrameSizeFromUserFmt(SrcChannels, SrcType); + { + ALBuf->OriginalSize = frames * FrameSizeFromUserFmt(SrcChannels, SrcType); + ALBuf->OriginalAlign = 1; + } } else { ALBuf->OriginalChannels = (enum UserFmtChannels)DstChannels; ALBuf->OriginalType = (enum UserFmtType)DstType; ALBuf->OriginalSize = frames * NewBytes * NewChannels; + ALBuf->OriginalAlign = 1; } ALBuf->Frequency = freq; |