aboutsummaryrefslogtreecommitdiffstats
path: root/al/source.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2021-06-21 09:04:33 -0700
committerChris Robinson <[email protected]>2021-06-21 09:04:33 -0700
commit8f3148ba53c5bbccf24667b2459787ce314f3efe (patch)
treed69781838fc7d196aa9711ee6de762c8cdbf8cae /al/source.cpp
parent7584458ecdea684c309007412a547777349b9f6c (diff)
Don't allocate full buffer lines in each voice
There's now effectively a 16-channel limit for buffers (as determined by the number of elements in DeviceBase::mSampleData). Any more than that are ignored when mixing.
Diffstat (limited to 'al/source.cpp')
-rw-r--r--al/source.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/al/source.cpp b/al/source.cpp
index 1ed1281f..b8278fed 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -509,17 +509,23 @@ void InitVoice(Voice *voice, ALsource *source, ALbufferQueueItem *BufferList, AL
/* Even if storing really high order ambisonics, we only mix channels for
* orders up to MaxAmbiOrder. The rest are simply dropped.
*/
- const ALuint num_channels{(buffer->mChannels == FmtUHJ2) ? 3 :
+ ALuint num_channels{(buffer->mChannels == FmtUHJ2) ? 3 :
ChannelsFromFmt(buffer->mChannels, minu(buffer->mAmbiOrder, MaxAmbiOrder))};
+ if UNLIKELY(num_channels > device->mSampleData.size())
+ {
+ ERR("Unexpected channel count: %u (limit: %zu, %d:%d)\n", num_channels,
+ device->mSampleData.size(), buffer->mChannels, buffer->mAmbiOrder);
+ num_channels = static_cast<ALuint>(device->mSampleData.size());
+ }
if(voice->mChans.capacity() > 2 && num_channels < voice->mChans.capacity())
{
decltype(voice->mChans){}.swap(voice->mChans);
- decltype(voice->mVoiceSamples){}.swap(voice->mVoiceSamples);
+ decltype(voice->mPrevSamples){}.swap(voice->mPrevSamples);
}
voice->mChans.reserve(maxu(2, num_channels));
voice->mChans.resize(num_channels);
- voice->mVoiceSamples.reserve(maxu(2, num_channels));
- voice->mVoiceSamples.resize(num_channels);
+ voice->mPrevSamples.reserve(maxu(2, num_channels));
+ voice->mPrevSamples.resize(num_channels);
voice->prepare(device);