aboutsummaryrefslogtreecommitdiffstats
path: root/alc/alc.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-09-04 23:04:55 -0700
committerChris Robinson <[email protected]>2019-09-04 23:04:55 -0700
commitef2769af03825f278b855858681e4cbe55c0734b (patch)
tree527d0ffb2be392ce90824cacfb3466ca1d409793 /alc/alc.cpp
parentc47a6d2279b80031db9b012713c27885b2d14047 (diff)
Use a normal vector for the voices array
Diffstat (limited to 'alc/alc.cpp')
-rw-r--r--alc/alc.cpp50
1 files changed, 5 insertions, 45 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp
index 7964a2b3..81afaeb0 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -2182,8 +2182,6 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
vprops = next;
}
- auto voices = context->mVoices.get();
- auto voices_end = voices->begin() + context->mVoiceCount.load(std::memory_order_relaxed);
if(device->NumAuxSends < old_sends)
{
const ALsizei num_sends{device->NumAuxSends};
@@ -2201,7 +2199,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
};
std::for_each(voice.mChans.begin(), voice.mChans.end(), clear_chan_sends);
};
- std::for_each(voices->begin(), voices_end, clear_sends);
+ std::for_each(context->mVoices.begin(), context->mVoices.end(), clear_sends);
}
auto reset_voice = [device](ALvoice &voice) -> void
{
@@ -2225,7 +2223,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
init_nfc);
}
};
- std::for_each(voices->begin(), voices_end, reset_voice);
+ std::for_each(context->mVoices.begin(), context->mVoices.end(), reset_voice);
srclock.unlock();
context->mPropsClean.test_and_set(std::memory_order_release);
@@ -2378,8 +2376,7 @@ ALCcontext::~ALCcontext()
}
TRACE("Freed %zu voice property object%s\n", count, (count==1)?"":"s");
- mVoices = nullptr;
- mVoiceCount.store(0, std::memory_order_relaxed);
+ mVoices.clear();
ALlistenerProps *lprops{mListener.Params.Update.exchange(nullptr, std::memory_order_relaxed)};
if(lprops)
@@ -2459,7 +2456,8 @@ void ALCcontext::init()
StartEventThrd(this);
- allocVoices(256);
+ mVoices.reserve(256);
+ mVoices.resize(64);
}
bool ALCcontext::deinit()
@@ -2548,44 +2546,6 @@ ContextRef GetContextRef(void)
}
-void ALCcontext::allocVoices(size_t num_voices)
-{
- const ALsizei num_sends{mDevice->NumAuxSends};
-
- if(mVoices && num_voices == mVoices->size())
- return;
-
- using ALvoiceArray = al::FlexArray<ALvoice>;
- std::unique_ptr<ALvoiceArray> voices{ALvoiceArray::Create(num_voices)};
-
- const size_t v_count{minz(mVoiceCount.load(std::memory_order_relaxed), num_voices)};
- if(mVoices)
- {
- /* Copy the old voice data to the new storage. */
- auto viter = std::move(mVoices->begin(), mVoices->begin()+v_count, voices->begin());
-
- /* Clear extraneous property set sends. */
- auto clear_sends = [num_sends](ALvoice &voice) -> void
- {
- std::fill(std::begin(voice.mProps.Send)+num_sends, std::end(voice.mProps.Send),
- ALvoiceProps::SendData{});
-
- std::fill(voice.mSend.begin()+num_sends, voice.mSend.end(), ALvoice::SendData{});
- auto clear_chan_sends = [num_sends](ALvoice::ChannelData &chandata) -> void
- {
- std::fill(chandata.mWetParams.begin()+num_sends, chandata.mWetParams.end(),
- SendParams{});
- };
- std::for_each(voice.mChans.begin(), voice.mChans.end(), clear_chan_sends);
- };
- std::for_each(voices->begin(), viter, clear_sends);
- }
-
- mVoices = std::move(voices);
- mVoiceCount.store(static_cast<ALuint>(v_count), std::memory_order_relaxed);
-}
-
-
/************************************************
* Standard ALC functions
************************************************/