diff options
author | Chris Robinson <chris.kcat@gmail.com> | 2023-02-12 03:15:40 -0800 |
---|---|---|
committer | Chris Robinson <chris.kcat@gmail.com> | 2023-02-12 03:15:40 -0800 |
commit | 63f840d31f09922ddef632f233342cbba46b09cf (patch) | |
tree | 79c128b3b6c6c01e9700de22afa7e5246f738584 /al/buffer.cpp | |
parent | 2001d93b03dd2af62e341b91ab2bee9b92da03bc (diff) |
Separate decoding and mixing from resampling
Diffstat (limited to 'al/buffer.cpp')
-rw-r--r-- | al/buffer.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/al/buffer.cpp b/al/buffer.cpp index 6bf3ecbc..ff416fda 100644 --- a/al/buffer.cpp +++ b/al/buffer.cpp @@ -703,9 +703,15 @@ void PrepareCallback(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, const ALuint ambiorder{IsBFormat(*DstChannels) ? ALBuf->UnpackAmbiOrder : (IsUHJ(*DstChannels) ? 1 : 0)}; - static constexpr uint line_size{BufferLineSize + MaxPostVoiceLoad}; - al::vector<al::byte,16>(FrameSizeFromFmt(*DstChannels, *DstType, ambiorder) * - size_t{line_size}).swap(ALBuf->mData); + /* The maximum number of samples a callback buffer may need to store is a + * full mixing line * max pitch * channel count, since it may need to hold + * a full line's worth of sample frames before downsampling. An additional + * MaxResamplerEdge is needed for "future" samples during resampling (the + * voice will hold a history for the past samples). + */ + static constexpr uint line_size{DeviceBase::MixerLineSize*MaxPitch + MaxResamplerEdge}; + decltype(ALBuf->mData)(FrameSizeFromFmt(*DstChannels, *DstType, ambiorder) * size_t{line_size}) + .swap(ALBuf->mData); #ifdef ALSOFT_EAX eax_x_ram_clear(*context->mALDevice, *ALBuf); |