aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2021-12-17 17:34:03 -0800
committerChris Robinson <[email protected]>2021-12-17 17:34:03 -0800
commitcbbc4dc8faf14f234d156ccc312b952ed9bc4e8e (patch)
tree739a2c3156bffbd25eab89809723df0a5de0d89d
parentd16b61dffb24cbe90e03e921684cb538cb23e181 (diff)
Move some more context functions to the proper source
-rw-r--r--alc/context.cpp76
-rw-r--r--core/context.cpp79
-rw-r--r--core/context.h2
3 files changed, 80 insertions, 77 deletions
diff --git a/alc/context.cpp b/alc/context.cpp
index b870a2a3..1dff00bc 100644
--- a/alc/context.cpp
+++ b/alc/context.cpp
@@ -96,82 +96,6 @@ thread_local ALCcontext::ThreadCtx ALCcontext::sThreadContext;
ALeffect ALCcontext::sDefaultEffect;
-ContextBase::ContextBase(DeviceBase *device) : mDevice{device}
-{ }
-
-ContextBase::~ContextBase()
-{
- size_t count{0};
- ContextProps *cprops{mParams.ContextUpdate.exchange(nullptr, std::memory_order_relaxed)};
- if(cprops)
- {
- ++count;
- delete cprops;
- }
- cprops = mFreeContextProps.exchange(nullptr, std::memory_order_acquire);
- while(cprops)
- {
- std::unique_ptr<ContextProps> old{cprops};
- cprops = old->next.load(std::memory_order_relaxed);
- ++count;
- }
- TRACE("Freed %zu context property object%s\n", count, (count==1)?"":"s");
-
- count = 0;
- EffectSlotProps *eprops{mFreeEffectslotProps.exchange(nullptr, std::memory_order_acquire)};
- while(eprops)
- {
- std::unique_ptr<EffectSlotProps> old{eprops};
- eprops = old->next.load(std::memory_order_relaxed);
- ++count;
- }
- TRACE("Freed %zu AuxiliaryEffectSlot property object%s\n", count, (count==1)?"":"s");
-
- if(EffectSlotArray *curarray{mActiveAuxSlots.exchange(nullptr, std::memory_order_relaxed)})
- {
- al::destroy_n(curarray->end(), curarray->size());
- delete curarray;
- }
-
- delete mVoices.exchange(nullptr, std::memory_order_relaxed);
-
- count = 0;
- ListenerProps *lprops{mParams.ListenerUpdate.exchange(nullptr, std::memory_order_relaxed)};
- if(lprops)
- {
- ++count;
- delete lprops;
- }
- lprops = mFreeListenerProps.exchange(nullptr, std::memory_order_acquire);
- while(lprops)
- {
- std::unique_ptr<ListenerProps> old{lprops};
- lprops = old->next.load(std::memory_order_relaxed);
- ++count;
- }
- TRACE("Freed %zu listener property object%s\n", count, (count==1)?"":"s");
-
- if(mAsyncEvents)
- {
- count = 0;
- auto evt_vec = mAsyncEvents->getReadVector();
- if(evt_vec.first.len > 0)
- {
- al::destroy_n(reinterpret_cast<AsyncEvent*>(evt_vec.first.buf), evt_vec.first.len);
- count += evt_vec.first.len;
- }
- if(evt_vec.second.len > 0)
- {
- al::destroy_n(reinterpret_cast<AsyncEvent*>(evt_vec.second.buf), evt_vec.second.len);
- count += evt_vec.second.len;
- }
- if(count > 0)
- TRACE("Destructed %zu orphaned event%s\n", count, (count==1)?"":"s");
- mAsyncEvents->readAdvance(count);
- }
-}
-
-
ALCcontext::ALCcontext(al::intrusive_ptr<ALCdevice> device)
: ContextBase{device.get()}, mALDevice{std::move(device)}
{
diff --git a/core/context.cpp b/core/context.cpp
index c8d9ea93..6457a6ec 100644
--- a/core/context.cpp
+++ b/core/context.cpp
@@ -3,13 +3,92 @@
#include <memory>
+#include "async_event.h"
#include "context.h"
#include "device.h"
+#include "effectslot.h"
#include "logging.h"
+#include "ringbuffer.h"
#include "voice.h"
#include "voice_change.h"
+ContextBase::ContextBase(DeviceBase *device) : mDevice{device}
+{ }
+
+ContextBase::~ContextBase()
+{
+ size_t count{0};
+ ContextProps *cprops{mParams.ContextUpdate.exchange(nullptr, std::memory_order_relaxed)};
+ if(cprops)
+ {
+ ++count;
+ delete cprops;
+ }
+ cprops = mFreeContextProps.exchange(nullptr, std::memory_order_acquire);
+ while(cprops)
+ {
+ std::unique_ptr<ContextProps> old{cprops};
+ cprops = old->next.load(std::memory_order_relaxed);
+ ++count;
+ }
+ TRACE("Freed %zu context property object%s\n", count, (count==1)?"":"s");
+
+ count = 0;
+ EffectSlotProps *eprops{mFreeEffectslotProps.exchange(nullptr, std::memory_order_acquire)};
+ while(eprops)
+ {
+ std::unique_ptr<EffectSlotProps> old{eprops};
+ eprops = old->next.load(std::memory_order_relaxed);
+ ++count;
+ }
+ TRACE("Freed %zu AuxiliaryEffectSlot property object%s\n", count, (count==1)?"":"s");
+
+ if(EffectSlotArray *curarray{mActiveAuxSlots.exchange(nullptr, std::memory_order_relaxed)})
+ {
+ al::destroy_n(curarray->end(), curarray->size());
+ delete curarray;
+ }
+
+ delete mVoices.exchange(nullptr, std::memory_order_relaxed);
+
+ count = 0;
+ ListenerProps *lprops{mParams.ListenerUpdate.exchange(nullptr, std::memory_order_relaxed)};
+ if(lprops)
+ {
+ ++count;
+ delete lprops;
+ }
+ lprops = mFreeListenerProps.exchange(nullptr, std::memory_order_acquire);
+ while(lprops)
+ {
+ std::unique_ptr<ListenerProps> old{lprops};
+ lprops = old->next.load(std::memory_order_relaxed);
+ ++count;
+ }
+ TRACE("Freed %zu listener property object%s\n", count, (count==1)?"":"s");
+
+ if(mAsyncEvents)
+ {
+ count = 0;
+ auto evt_vec = mAsyncEvents->getReadVector();
+ if(evt_vec.first.len > 0)
+ {
+ al::destroy_n(reinterpret_cast<AsyncEvent*>(evt_vec.first.buf), evt_vec.first.len);
+ count += evt_vec.first.len;
+ }
+ if(evt_vec.second.len > 0)
+ {
+ al::destroy_n(reinterpret_cast<AsyncEvent*>(evt_vec.second.buf), evt_vec.second.len);
+ count += evt_vec.second.len;
+ }
+ if(count > 0)
+ TRACE("Destructed %zu orphaned event%s\n", count, (count==1)?"":"s");
+ mAsyncEvents->readAdvance(count);
+ }
+}
+
+
void ContextBase::allocVoiceChanges()
{
constexpr size_t clustersize{128};
diff --git a/core/context.h b/core/context.h
index 6bdf5db9..f3e05689 100644
--- a/core/context.h
+++ b/core/context.h
@@ -10,7 +10,7 @@
#include "almalloc.h"
#include "alspan.h"
#include "atomic.h"
-#include "core/bufferline.h"
+#include "bufferline.h"
#include "threads.h"
#include "vecmat.h"
#include "vector.h"