diff options
author | Chris Robinson <[email protected]> | 2023-04-03 04:51:28 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-04-03 04:51:28 -0700 |
commit | b59b80fb17a2c4bc4e5d581207affd727a34abc7 (patch) | |
tree | 9bae342157be80f34dd78e8668473d524e661131 /al | |
parent | dfd8f11551e43470708c5b7ddf766abab4d5ac30 (diff) |
Hold the buffer sample pointer separate from the vector
Diffstat (limited to 'al')
-rw-r--r-- | al/buffer.cpp | 14 | ||||
-rw-r--r-- | al/buffer.h | 2 |
2 files changed, 9 insertions, 7 deletions
diff --git a/al/buffer.cpp b/al/buffer.cpp index c654abd7..c2aafb6f 100644 --- a/al/buffer.cpp +++ b/al/buffer.cpp @@ -357,16 +357,17 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size, * size could cause problems for apps that use AL_SIZE to try to get the * buffer's play length. */ - if(newsize != ALBuf->mData.size()) + if(newsize != ALBuf->mDataStorage.size()) { auto newdata = al::vector<al::byte,16>(newsize, al::byte{}); if((access&AL_PRESERVE_DATA_BIT_SOFT)) { - const size_t tocopy{minz(newdata.size(), ALBuf->mData.size())}; - std::copy_n(ALBuf->mData.begin(), tocopy, newdata.begin()); + const size_t tocopy{minz(newdata.size(), ALBuf->mDataStorage.size())}; + std::copy_n(ALBuf->mDataStorage.begin(), tocopy, newdata.begin()); } - newdata.swap(ALBuf->mData); + newdata.swap(ALBuf->mDataStorage); } + ALBuf->mData = ALBuf->mDataStorage; #ifdef ALSOFT_EAX eax_x_ram_clear(*context->mALDevice, *ALBuf); #endif @@ -425,8 +426,9 @@ void PrepareCallback(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, static constexpr size_t line_size{DeviceBase::MixerLineSize*MaxPitch + MaxResamplerEdge}; const size_t line_blocks{(line_size + align-1) / align}; - using BufferVectorType = decltype(ALBuf->mData); - BufferVectorType(line_blocks*BlockSize).swap(ALBuf->mData); + using BufferVectorType = decltype(ALBuf->mDataStorage); + BufferVectorType(line_blocks*BlockSize).swap(ALBuf->mDataStorage); + ALBuf->mData = ALBuf->mDataStorage; #ifdef ALSOFT_EAX eax_x_ram_clear(*context->mALDevice, *ALBuf); diff --git a/al/buffer.h b/al/buffer.h index da7da740..64ebe1f3 100644 --- a/al/buffer.h +++ b/al/buffer.h @@ -26,7 +26,7 @@ enum class EaxStorage : uint8_t { struct ALbuffer : public BufferStorage { ALbitfieldSOFT Access{0u}; - al::vector<al::byte,16> mData; + al::vector<al::byte,16> mDataStorage; ALuint OriginalSize{0}; |