aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2021-04-24 08:28:13 -0700
committerChris Robinson <[email protected]>2021-04-24 08:28:13 -0700
commitb54bb388a3dbd92518beef4bda03df5854aad1a9 (patch)
tree8cde0be5ca02b61ae81bf0c3ccdd3a2439b1923a
parent519672c8e54585bc6d827dd3efed943e06b3e6cd (diff)
Create a base the ALCdevice and ALCcontext structs
A base that contains the API-agnostic data, with ALCdevice and ALCcontext being for AL-specific data.
-rw-r--r--al/auxeffectslot.cpp8
-rw-r--r--al/buffer.cpp48
-rw-r--r--al/effect.cpp22
-rw-r--r--al/filter.cpp22
-rw-r--r--al/source.cpp22
-rw-r--r--alc/alc.cpp99
-rw-r--r--alc/alcmain.h178
-rw-r--r--alc/alcontext.h78
-rw-r--r--alc/alu.cpp46
-rw-r--r--alc/effects/autowah.cpp10
-rw-r--r--alc/effects/base.h5
-rw-r--r--alc/effects/chorus.cpp10
-rw-r--r--alc/effects/compressor.cpp8
-rw-r--r--alc/effects/convolution.cpp12
-rw-r--r--alc/effects/dedicated.cpp8
-rw-r--r--alc/effects/distortion.cpp10
-rw-r--r--alc/effects/echo.cpp10
-rw-r--r--alc/effects/equalizer.cpp10
-rw-r--r--alc/effects/fshifter.cpp10
-rw-r--r--alc/effects/modulator.cpp10
-rw-r--r--alc/effects/null.cpp8
-rw-r--r--alc/effects/pshifter.cpp8
-rw-r--r--alc/effects/reverb.cpp10
-rw-r--r--alc/effects/vmorpher.cpp10
-rw-r--r--alc/panning.cpp2
-rw-r--r--alc/voice.cpp12
-rw-r--r--alc/voice.h7
27 files changed, 359 insertions, 324 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp
index 0b64f9da..3ee0a46e 100644
--- a/al/auxeffectslot.cpp
+++ b/al/auxeffectslot.cpp
@@ -325,7 +325,7 @@ START_API_FUNC
if UNLIKELY(n <= 0) return;
std::unique_lock<std::mutex> slotlock{context->mEffectSlotLock};
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
if(static_cast<ALuint>(n) > device->AuxiliaryEffectSlotMax-context->mNumEffectSlots)
{
context->setError(AL_OUT_OF_MEMORY, "Exceeding %u effect slot limit (%u + %d)",
@@ -571,7 +571,7 @@ START_API_FUNC
switch(param)
{
case AL_EFFECTSLOT_EFFECT:
- device = context->mDevice.get();
+ device = context->mALDevice.get();
{
std::lock_guard<std::mutex> ___{device->EffectLock};
@@ -639,7 +639,7 @@ START_API_FUNC
break;
case AL_BUFFER:
- device = context->mDevice.get();
+ device = context->mALDevice.get();
if(slot->mState == SlotState::Playing)
SETERR_RETURN(context, AL_INVALID_OPERATION,,
@@ -946,7 +946,7 @@ ALenum ALeffectslot::initEffect(ALeffect *effect, ALCcontext *context)
}
al::intrusive_ptr<EffectState> state{factory->create()};
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::unique_lock<std::mutex> statelock{device->StateLock};
state->mOutTarget = device->Dry.Buffer;
{
diff --git a/al/buffer.cpp b/al/buffer.cpp
index 6b82ce7f..906b40fc 100644
--- a/al/buffer.cpp
+++ b/al/buffer.cpp
@@ -782,7 +782,7 @@ START_API_FUNC
context->setError(AL_INVALID_VALUE, "Generating %d buffers", n);
if UNLIKELY(n <= 0) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
if(!EnsureBuffers(device, static_cast<ALuint>(n)))
{
@@ -822,7 +822,7 @@ START_API_FUNC
context->setError(AL_INVALID_VALUE, "Deleting %d buffers", n);
if UNLIKELY(n <= 0) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
/* First try to find any buffers that are invalid or in-use. */
@@ -862,7 +862,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if LIKELY(context)
{
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
if(!buffer || LookupBuffer(device, buffer))
return AL_TRUE;
@@ -883,7 +883,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
@@ -917,7 +917,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return nullptr;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
@@ -970,7 +970,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
@@ -993,7 +993,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
@@ -1025,7 +1025,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
@@ -1155,7 +1155,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
@@ -1175,7 +1175,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
@@ -1194,7 +1194,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
@@ -1216,7 +1216,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
@@ -1278,7 +1278,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
@@ -1311,7 +1311,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
@@ -1349,7 +1349,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
@@ -1371,7 +1371,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
@@ -1399,7 +1399,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
@@ -1421,7 +1421,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
if UNLIKELY(!albuf)
@@ -1478,7 +1478,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
@@ -1516,7 +1516,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
if UNLIKELY(!albuf)
@@ -1544,7 +1544,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
@@ -1574,7 +1574,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
if UNLIKELY(!albuf)
@@ -1602,7 +1602,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
@@ -1630,7 +1630,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
diff --git a/al/effect.cpp b/al/effect.cpp
index 93aa5547..645e41df 100644
--- a/al/effect.cpp
+++ b/al/effect.cpp
@@ -233,7 +233,7 @@ START_API_FUNC
context->setError(AL_INVALID_VALUE, "Generating %d effects", n);
if UNLIKELY(n <= 0) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
if(!EnsureEffects(device, static_cast<ALuint>(n)))
{
@@ -273,7 +273,7 @@ START_API_FUNC
context->setError(AL_INVALID_VALUE, "Deleting %d effects", n);
if UNLIKELY(n <= 0) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
/* First try to find any effects that are invalid. */
@@ -304,7 +304,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if LIKELY(context)
{
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
if(!effect || LookupEffect(device, effect))
return AL_TRUE;
@@ -319,7 +319,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
ALeffect *aleffect{LookupEffect(device, effect)};
@@ -369,7 +369,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
ALeffect *aleffect{LookupEffect(device, effect)};
@@ -392,7 +392,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
ALeffect *aleffect{LookupEffect(device, effect)};
@@ -415,7 +415,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
ALeffect *aleffect{LookupEffect(device, effect)};
@@ -438,7 +438,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
const ALeffect *aleffect{LookupEffect(device, effect)};
@@ -470,7 +470,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
const ALeffect *aleffect{LookupEffect(device, effect)};
@@ -493,7 +493,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
const ALeffect *aleffect{LookupEffect(device, effect)};
@@ -516,7 +516,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
const ALeffect *aleffect{LookupEffect(device, effect)};
diff --git a/al/filter.cpp b/al/filter.cpp
index 1e7edbc2..c3391193 100644
--- a/al/filter.cpp
+++ b/al/filter.cpp
@@ -408,7 +408,7 @@ START_API_FUNC
context->setError(AL_INVALID_VALUE, "Generating %d filters", n);
if UNLIKELY(n <= 0) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
if(!EnsureFilters(device, static_cast<ALuint>(n)))
{
@@ -448,7 +448,7 @@ START_API_FUNC
context->setError(AL_INVALID_VALUE, "Deleting %d filters", n);
if UNLIKELY(n <= 0) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
/* First try to find any filters that are invalid. */
@@ -479,7 +479,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if LIKELY(context)
{
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
if(!filter || LookupFilter(device, filter))
return AL_TRUE;
@@ -495,7 +495,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
ALfilter *alfilt{LookupFilter(device, filter)};
@@ -536,7 +536,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
ALfilter *alfilt{LookupFilter(device, filter)};
@@ -559,7 +559,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
ALfilter *alfilt{LookupFilter(device, filter)};
@@ -582,7 +582,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
ALfilter *alfilt{LookupFilter(device, filter)};
@@ -605,7 +605,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
const ALfilter *alfilt{LookupFilter(device, filter)};
@@ -640,7 +640,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
const ALfilter *alfilt{LookupFilter(device, filter)};
@@ -663,7 +663,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
const ALfilter *alfilt{LookupFilter(device, filter)};
@@ -686,7 +686,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if UNLIKELY(!context) return;
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
const ALfilter *alfilt{LookupFilter(device, filter)};
diff --git a/al/source.cpp b/al/source.cpp
index 20de0809..69120bac 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -183,7 +183,7 @@ void UpdateSourceProps(const ALsource *source, Voice *voice, ALCcontext *context
*/
int64_t GetSourceSampleOffset(ALsource *Source, ALCcontext *context, nanoseconds *clocktime)
{
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
const VoiceBufferItem *Current{};
uint64_t readPos{};
ALuint refcount;
@@ -222,7 +222,7 @@ int64_t GetSourceSampleOffset(ALsource *Source, ALCcontext *context, nanoseconds
*/
double GetSourceSecOffset(ALsource *Source, ALCcontext *context, nanoseconds *clocktime)
{
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
const VoiceBufferItem *Current{};
uint64_t readPos{};
ALuint refcount;
@@ -271,7 +271,7 @@ double GetSourceSecOffset(ALsource *Source, ALCcontext *context, nanoseconds *cl
*/
double GetSourceOffset(ALsource *Source, ALenum name, ALCcontext *context)
{
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
const VoiceBufferItem *Current{};
ALuint readPos{};
ALuint readPosFrac{};
@@ -540,7 +540,7 @@ VoiceChange *GetVoiceChanger(ALCcontext *ctx)
void SendVoiceChanges(ALCcontext *ctx, VoiceChange *tail)
{
- ALCdevice *device{ctx->mDevice.get()};
+ ALCdevice *device{ctx->mALDevice.get()};
VoiceChange *oldhead{ctx->mCurrentVoiceChange.load(std::memory_order_acquire)};
while(VoiceChange *next{oldhead->mNext.load(std::memory_order_relaxed)})
@@ -1248,7 +1248,7 @@ bool SetSourcefv(ALsource *Source, ALCcontext *Context, SourceProp prop, const a
auto vpos = GetSampleOffset(Source->mQueue, prop, values[0]);
if(!vpos) SETERR_RETURN(Context, AL_INVALID_VALUE, false, "Invalid offset");
- if(SetVoiceOffset(voice, *vpos, Source, Context, Context->mDevice.get()))
+ if(SetVoiceOffset(voice, *vpos, Source, Context, Context->mALDevice.get()))
return true;
}
Source->OffsetType = prop;
@@ -1350,7 +1350,7 @@ bool SetSourcefv(ALsource *Source, ALCcontext *Context, SourceProp prop, const a
bool SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, const al::span<const int> values)
{
- ALCdevice *device{Context->mDevice.get()};
+ ALCdevice *device{Context->mALDevice.get()};
ALeffectslot *slot{nullptr};
al::deque<ALbufferQueueItem> oldlist;
std::unique_lock<std::mutex> slotlock;
@@ -1794,7 +1794,7 @@ bool GetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp prop, const
bool GetSourcedv(ALsource *Source, ALCcontext *Context, SourceProp prop, const al::span<double> values)
{
- ALCdevice *device{Context->mDevice.get()};
+ ALCdevice *device{Context->mALDevice.get()};
ClockLatency clocktime;
nanoseconds srcclock;
int ivals[MaxValues];
@@ -2174,7 +2174,7 @@ bool GetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, const a
bool GetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp prop, const al::span<int64_t> values)
{
- ALCdevice *device = Context->mDevice.get();
+ ALCdevice *device{Context->mALDevice.get()};
ClockLatency clocktime;
nanoseconds srcclock;
double dvals[MaxValues];
@@ -2332,7 +2332,7 @@ START_API_FUNC
if UNLIKELY(n <= 0) return;
std::unique_lock<std::mutex> srclock{context->mSourceLock};
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
if(static_cast<ALuint>(n) > device->SourcesMax-context->mNumSources)
{
context->setError(AL_OUT_OF_MEMORY, "Exceeding %u source limit (%u + %d)",
@@ -2924,7 +2924,7 @@ START_API_FUNC
++sources;
}
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
/* If the device is disconnected, go right to stopped. */
if UNLIKELY(!device->Connected.load(std::memory_order_acquire))
{
@@ -3302,7 +3302,7 @@ START_API_FUNC
SETERR_RETURN(context, AL_INVALID_OPERATION,, "Queueing onto static source %u", src);
/* Check for a valid Buffer, for its frequency and format */
- ALCdevice *device{context->mDevice.get()};
+ ALCdevice *device{context->mALDevice.get()};
ALbuffer *BufferFmt{nullptr};
for(auto &item : source->mQueue)
{
diff --git a/alc/alc.cpp b/alc/alc.cpp
index cc168b6a..bbb9a45c 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -980,10 +980,10 @@ constexpr int alcEFXMajorVersion{1};
constexpr int alcEFXMinorVersion{0};
-/* To avoid extraneous allocations, a 0-sized FlexArray<ALCcontext*> is defined
- * globally as a sharable object.
+/* To avoid extraneous allocations, a 0-sized FlexArray<ContextBase*> is
+ * defined globally as a sharable object.
*/
-al::FlexArray<ALCcontext*> EmptyContextArray{0u};
+al::FlexArray<ContextBase*> EmptyContextArray{0u};
using DeviceRef = al::intrusive_ptr<ALCdevice>;
@@ -1571,7 +1571,7 @@ void ALCcontext::processUpdates()
}
-void ALCcontext::allocVoiceChanges(size_t addcount)
+void ContextBase::allocVoiceChanges(size_t addcount)
{
constexpr size_t clustersize{128};
/* Convert element count to cluster count. */
@@ -1588,7 +1588,7 @@ void ALCcontext::allocVoiceChanges(size_t addcount)
}
}
-void ALCcontext::allocVoices(size_t addcount)
+void ContextBase::allocVoices(size_t addcount)
{
constexpr size_t clustersize{32};
/* Convert element count to cluster count. */
@@ -2117,8 +2117,10 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
TRACE("Fixed device latency: %" PRId64 "ns\n", int64_t{device->FixedLatency.count()});
FPUCtl mixer_mode{};
- for(ALCcontext *context : *device->mContexts.load())
+ for(ContextBase *ctxbase : *device->mContexts.load())
{
+ auto *context = static_cast<ALCcontext*>(ctxbase);
+
auto GetEffectBuffer = [](ALbuffer *buffer) noexcept -> EffectState::Buffer
{
if(!buffer) return EffectState::Buffer{};
@@ -2270,8 +2272,10 @@ static bool ResetDeviceParams(ALCdevice *device, const int *attrList)
/* Make sure disconnection is finished before continuing on. */
device->waitForMix();
- for(ALCcontext *ctx : *device->mContexts.load(std::memory_order_acquire))
+ for(ContextBase *ctxbase : *device->mContexts.load(std::memory_order_acquire))
{
+ auto *ctx = static_cast<ALCcontext*>(ctxbase);
+
/* Clear any pending voice changes and reallocate voices to get a
* clean restart.
*/
@@ -2297,8 +2301,14 @@ static bool ResetDeviceParams(ALCdevice *device, const int *attrList)
}
-ALCdevice::ALCdevice(DeviceType type) : Type{type}, mContexts{&EmptyContextArray}
+DeviceBase::DeviceBase(DeviceType type) : Type{type}, mContexts{&EmptyContextArray}
+{
+}
+
+DeviceBase::~DeviceBase()
{
+ auto *oldarray = mContexts.exchange(nullptr, std::memory_order_relaxed);
+ if(oldarray != &EmptyContextArray) delete oldarray;
}
ALCdevice::~ALCdevice()
@@ -2324,11 +2334,6 @@ ALCdevice::~ALCdevice()
{ return cur + static_cast<uint>(al::popcount(~sublist.FreeMask)); });
if(count > 0)
WARN("%zu Filter%s not deleted\n", count, (count==1)?"":"s");
-
- mHrtf = nullptr;
-
- auto *oldarray = mContexts.exchange(nullptr, std::memory_order_relaxed);
- if(oldarray != &EmptyContextArray) delete oldarray;
}
void ALCdevice::enumerateHrtfs()
@@ -2359,15 +2364,11 @@ static DeviceRef VerifyDevice(ALCdevice *device)
}
-ALCcontext::ALCcontext(al::intrusive_ptr<ALCdevice> device) : mDevice{std::move(device)}
-{
- mPropsDirty.test_and_clear(std::memory_order_relaxed);
-}
+ContextBase::ContextBase(DeviceBase *device) : mDevice{device}
+{ }
-ALCcontext::~ALCcontext()
+ContextBase::~ContextBase()
{
- TRACE("Freeing context %p\n", voidp{this});
-
size_t count{0};
ContextProps *cprops{mParams.ContextUpdate.exchange(nullptr, std::memory_order_relaxed)};
if(cprops)
@@ -2384,14 +2385,6 @@ ALCcontext::~ALCcontext()
}
TRACE("Freed %zu context property object%s\n", count, (count==1)?"":"s");
- count = std::accumulate(mSourceList.cbegin(), mSourceList.cend(), size_t{0u},
- [](size_t cur, const SourceSubList &sublist) noexcept -> size_t
- { return cur + static_cast<uint>(al::popcount(~sublist.FreeMask)); });
- if(count > 0)
- WARN("%zu Source%s not deleted\n", count, (count==1)?"":"s");
- mSourceList.clear();
- mNumSources = 0;
-
count = 0;
EffectSlotProps *eprops{mFreeEffectslotProps.exchange(nullptr, std::memory_order_acquire)};
while(eprops)
@@ -2407,15 +2400,6 @@ ALCcontext::~ALCcontext()
al::destroy_n(curarray->end(), curarray->size());
delete curarray;
}
- mDefaultSlot = nullptr;
-
- count = std::accumulate(mEffectSlotList.cbegin(), mEffectSlotList.cend(), size_t{0u},
- [](size_t cur, const EffectSlotSubList &sublist) noexcept -> size_t
- { return cur + static_cast<uint>(al::popcount(~sublist.FreeMask)); });
- if(count > 0)
- WARN("%zu AuxiliaryEffectSlot%s not deleted\n", count, (count==1)?"":"s");
- mEffectSlotList.clear();
- mNumEffectSlots = 0;
count = 0;
VoicePropsItem *vprops{mFreeVoiceProps.exchange(nullptr, std::memory_order_acquire)};
@@ -2465,6 +2449,35 @@ ALCcontext::~ALCcontext()
}
}
+
+ALCcontext::ALCcontext(al::intrusive_ptr<ALCdevice> device)
+ : ContextBase{device.get()}, mALDevice{std::move(device)}
+{
+ mPropsDirty.test_and_clear(std::memory_order_relaxed);
+}
+
+ALCcontext::~ALCcontext()
+{
+ TRACE("Freeing context %p\n", voidp{this});
+
+ size_t count{std::accumulate(mSourceList.cbegin(), mSourceList.cend(), size_t{0u},
+ [](size_t cur, const SourceSubList &sublist) noexcept -> size_t
+ { return cur + static_cast<uint>(al::popcount(~sublist.FreeMask)); })};
+ if(count > 0)
+ WARN("%zu Source%s not deleted\n", count, (count==1)?"":"s");
+ mSourceList.clear();
+ mNumSources = 0;
+
+ mDefaultSlot = nullptr;
+ count = std::accumulate(mEffectSlotList.cbegin(), mEffectSlotList.cend(), size_t{0u},
+ [](size_t cur, const EffectSlotSubList &sublist) noexcept -> size_t
+ { return cur + static_cast<uint>(al::popcount(~sublist.FreeMask)); });
+ if(count > 0)
+ WARN("%zu AuxiliaryEffectSlot%s not deleted\n", count, (count==1)?"":"s");
+ mEffectSlotList.clear();
+ mNumEffectSlots = 0;
+}
+
void ALCcontext::init()
{
if(DefaultEffect.type != AL_EFFECT_NULL && mDevice->Type == DeviceType::Playback)
@@ -2531,7 +2544,7 @@ bool ALCcontext::deinit()
auto *oldarray = mDevice->mContexts.load(std::memory_order_acquire);
if(auto toremove = static_cast<size_t>(std::count(oldarray->begin(), oldarray->end(), this)))
{
- using ContextArray = al::FlexArray<ALCcontext*>;
+ using ContextArray = al::FlexArray<ContextBase*>;
auto alloc_ctx_array = [](const size_t count) -> ContextArray*
{
if(count == 0) return &EmptyContextArray;
@@ -2543,7 +2556,7 @@ bool ALCcontext::deinit()
* given context.
*/
std::copy_if(oldarray->begin(), oldarray->end(), newarray->begin(),
- std::bind(std::not_equal_to<ALCcontext*>{}, _1, this));
+ std::bind(std::not_equal_to<>{}, _1, this));
/* Store the new context array in the device. Wait for any current mix
* to finish before deleting the old array.
@@ -3361,7 +3374,7 @@ START_API_FUNC
UpdateListenerProps(context.get());
{
- using ContextArray = al::FlexArray<ALCcontext*>;
+ using ContextArray = al::FlexArray<ContextBase*>;
/* Allocate a new context array, which holds 1 more than the current/
* old array.
@@ -3424,7 +3437,7 @@ START_API_FUNC
ContextRef ctx{*iter};
ContextList.erase(iter);
- ALCdevice *Device{ctx->mDevice.get()};
+ ALCdevice *Device{ctx->mALDevice.get()};
std::lock_guard<std::mutex> _{Device->StateLock};
if(!ctx->deinit() && Device->Flags.test(DeviceRunning))
@@ -3516,7 +3529,7 @@ START_API_FUNC
alcSetError(nullptr, ALC_INVALID_CONTEXT);
return nullptr;
}
- return ctx->mDevice.get();
+ return ctx->mALDevice.get();
}
END_API_FUNC
@@ -3745,7 +3758,7 @@ START_API_FUNC
std::unique_lock<std::mutex> statelock{dev->StateLock};
al::vector<ContextRef> orphanctxs;
- for(ALCcontext *ctx : *dev->mContexts.load())
+ for(ContextBase *ctx : *dev->mContexts.load())
{
auto ctxiter = std::lower_bound(ContextList.begin(), ContextList.end(), ctx);
if(ctxiter != ContextList.end() && *ctxiter == ctx)
diff --git a/alc/alcmain.h b/alc/alcmain.h
index 69f05bfe..025ba3d4 100644
--- a/alc/alcmain.h
+++ b/alc/alcmain.h
@@ -38,6 +38,7 @@ struct ALeffect;
struct ALfilter;
struct BackendBase;
struct Compressor;
+struct ContextBase;
struct EffectState;
struct UhjEncoder;
struct bs2b;
@@ -75,52 +76,6 @@ struct InputRemixMap {
};
-struct BufferSubList {
- uint64_t FreeMask{~0_u64};
- ALbuffer *Buffers{nullptr}; /* 64 */
-
- BufferSubList() noexcept = default;
- BufferSubList(const BufferSubList&) = delete;
- BufferSubList(BufferSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Buffers{rhs.Buffers}
- { rhs.FreeMask = ~0_u64; rhs.Buffers = nullptr; }
- ~BufferSubList();
-
- BufferSubList& operator=(const BufferSubList&) = delete;
- BufferSubList& operator=(BufferSubList&& rhs) noexcept
- { std::swap(FreeMask, rhs.FreeMask); std::swap(Buffers, rhs.Buffers); return *this; }
-};
-
-struct EffectSubList {
- uint64_t FreeMask{~0_u64};
- ALeffect *Effects{nullptr}; /* 64 */
-
- EffectSubList() noexcept = default;
- EffectSubList(const EffectSubList&) = delete;
- EffectSubList(EffectSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Effects{rhs.Effects}
- { rhs.FreeMask = ~0_u64; rhs.Effects = nullptr; }
- ~EffectSubList();
-
- EffectSubList& operator=(const EffectSubList&) = delete;
- EffectSubList& operator=(EffectSubList&& rhs) noexcept
- { std::swap(FreeMask, rhs.FreeMask); std::swap(Effects, rhs.Effects); return *this; }
-};
-
-struct FilterSubList {
- uint64_t FreeMask{~0_u64};
- ALfilter *Filters{nullptr}; /* 64 */
-
- FilterSubList() noexcept = default;
- FilterSubList(const FilterSubList&) = delete;
- FilterSubList(FilterSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Filters{rhs.Filters}
- { rhs.FreeMask = ~0_u64; rhs.Filters = nullptr; }
- ~FilterSubList();
-
- FilterSubList& operator=(const FilterSubList&) = delete;
- FilterSubList& operator=(FilterSubList&& rhs) noexcept
- { std::swap(FreeMask, rhs.FreeMask); std::swap(Filters, rhs.Filters); return *this; }
-};
-
-
/* Maximum delay in samples for speaker distance compensation. */
#define MAX_DELAY_LENGTH 1024
@@ -179,7 +134,7 @@ enum {
DeviceFlagsCount
};
-struct ALCdevice : public al::intrusive_ref<ALCdevice> {
+struct DeviceBase {
std::atomic<bool> Connected{true};
const DeviceType Type{};
@@ -203,10 +158,7 @@ struct ALCdevice : public al::intrusive_ref<ALCdevice> {
// Device flags
std::bitset<DeviceFlagsCount> Flags{};
- // Maximum number of sources that can be created
- uint SourcesMax{};
- // Maximum number of slots that can be created
- uint AuxiliaryEffectSlotMax{};
+ uint NumAuxSends{};
/* Rendering mode. */
RenderMode mRenderMode{RenderMode::Normal};
@@ -257,7 +209,7 @@ struct ALCdevice : public al::intrusive_ref<ALCdevice> {
/* Stereo-to-binaural filter */
std::unique_ptr<bs2b> Bs2b;
- using PostProc = void(ALCdevice::*)(const size_t SamplesToDo);
+ using PostProc = void(DeviceBase::*)(const size_t SamplesToDo);
PostProc PostProcess{nullptr};
std::unique_ptr<Compressor> Limiter;
@@ -277,7 +229,7 @@ struct ALCdevice : public al::intrusive_ref<ALCdevice> {
RefCount MixCount{0u};
// Contexts created on this device
- std::atomic<al::FlexArray<ALCcontext*>*> mContexts{nullptr};
+ std::atomic<al::FlexArray<ContextBase*>*> mContexts{nullptr};
/* This lock protects the device state (format, update size, etc) from
* being from being changed in multiple threads, or being accessed while
@@ -287,37 +239,10 @@ struct ALCdevice : public al::intrusive_ref<ALCdevice> {
std::unique_ptr<BackendBase> Backend;
- ALCuint NumMonoSources{};
- ALCuint NumStereoSources{};
- ALCuint NumAuxSends{};
-
- std::string mHrtfName;
- al::vector<std::string> mHrtfList;
- ALCenum mHrtfStatus{ALC_FALSE};
-
- ALCenum LimiterState{ALC_DONT_CARE_SOFT};
-
- std::atomic<ALCenum> LastError{ALC_NO_ERROR};
-
- // Map of Buffers for this device
- std::mutex BufferLock;
- al::vector<BufferSubList> BufferList;
-
- // Map of Effects for this device
- std::mutex EffectLock;
- al::vector<EffectSubList> EffectList;
-
- // Map of Filters for this device
- std::mutex FilterLock;
- al::vector<FilterSubList> FilterList;
-
-
- ALCdevice(DeviceType type);
- ALCdevice(const ALCdevice&) = delete;
- ALCdevice& operator=(const ALCdevice&) = delete;
- ~ALCdevice();
-
- void enumerateHrtfs();
+ DeviceBase(DeviceType type);
+ DeviceBase(const DeviceBase&) = delete;
+ DeviceBase& operator=(const DeviceBase&) = delete;
+ ~DeviceBase();
uint bytesFromFmt() const noexcept { return BytesFromDevFmt(FmtType); }
uint channelsFromFmt() const noexcept { return ChannelsFromDevFmt(FmtChans, mAmbiOrder); }
@@ -350,6 +275,91 @@ struct ALCdevice : public al::intrusive_ref<ALCdevice> {
#endif
void handleDisconnect(const char *msg, ...);
+ DISABLE_ALLOC()
+};
+
+
+struct BufferSubList {
+ uint64_t FreeMask{~0_u64};
+ ALbuffer *Buffers{nullptr}; /* 64 */
+
+ BufferSubList() noexcept = default;
+ BufferSubList(const BufferSubList&) = delete;
+ BufferSubList(BufferSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Buffers{rhs.Buffers}
+ { rhs.FreeMask = ~0_u64; rhs.Buffers = nullptr; }
+ ~BufferSubList();
+
+ BufferSubList& operator=(const BufferSubList&) = delete;
+ BufferSubList& operator=(BufferSubList&& rhs) noexcept
+ { std::swap(FreeMask, rhs.FreeMask); std::swap(Buffers, rhs.Buffers); return *this; }
+};
+
+struct EffectSubList {
+ uint64_t FreeMask{~0_u64};
+ ALeffect *Effects{nullptr}; /* 64 */
+
+ EffectSubList() noexcept = default;
+ EffectSubList(const EffectSubList&) = delete;
+ EffectSubList(EffectSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Effects{rhs.Effects}
+ { rhs.FreeMask = ~0_u64; rhs.Effects = nullptr; }
+ ~EffectSubList();
+
+ EffectSubList& operator=(const EffectSubList&) = delete;
+ EffectSubList& operator=(EffectSubList&& rhs) noexcept
+ { std::swap(FreeMask, rhs.FreeMask); std::swap(Effects, rhs.Effects); return *this; }
+};
+
+struct FilterSubList {
+ uint64_t FreeMask{~0_u64};
+ ALfilter *Filters{nullptr}; /* 64 */
+
+ FilterSubList() noexcept = default;
+ FilterSubList(const FilterSubList&) = delete;
+ FilterSubList(FilterSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Filters{rhs.Filters}
+ { rhs.FreeMask = ~0_u64; rhs.Filters = nullptr; }
+ ~FilterSubList();
+
+ FilterSubList& operator=(const FilterSubList&) = delete;
+ FilterSubList& operator=(FilterSubList&& rhs) noexcept
+ { std::swap(FreeMask, rhs.FreeMask); std::swap(Filters, rhs.Filters); return *this; }
+};
+
+
+struct ALCdevice : public al::intrusive_ref<ALCdevice>, DeviceBase {
+ ALCuint NumMonoSources{};
+ ALCuint NumStereoSources{};
+
+ // Maximum number of sources that can be created
+ uint SourcesMax{};
+ // Maximum number of slots that can be created
+ uint AuxiliaryEffectSlotMax{};
+
+ std::string mHrtfName;
+ al::vector<std::string> mHrtfList;
+ ALCenum mHrtfStatus{ALC_FALSE};
+
+ ALCenum LimiterState{ALC_DONT_CARE_SOFT};
+
+ std::atomic<ALCenum> LastError{ALC_NO_ERROR};
+
+ // Map of Buffers for this device
+ std::mutex BufferLock;
+ al::vector<BufferSubList> BufferList;
+
+ // Map of Effects for this device
+ std::mutex EffectLock;
+ al::vector<EffectSubList> EffectList;
+
+ // Map of Filters for this device
+ std::mutex FilterLock;
+ al::vector<FilterSubList> FilterList;
+
+
+ ALCdevice(DeviceType type) : DeviceBase{type} { }
+ ~ALCdevice();
+
+ void enumerateHrtfs();
+
DEF_NEWDEL(ALCdevice)
};
diff --git a/alc/alcontext.h b/alc/alcontext.h
index 860b129b..3c368a64 100644
--- a/alc/alcontext.h
+++ b/alc/alcontext.h
@@ -26,6 +26,7 @@
struct ALeffectslot;
struct ALsource;
+struct DeviceBase;
struct EffectSlot;
struct EffectSlotProps;
struct RingBuffer;
@@ -98,40 +99,8 @@ struct ContextParams {
DistanceModel mDistanceModel{};
};
-
-struct SourceSubList {
- uint64_t FreeMask{~0_u64};
- ALsource *Sources{nullptr}; /* 64 */
-
- SourceSubList() noexcept = default;
- SourceSubList(const SourceSubList&) = delete;
- SourceSubList(SourceSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Sources{rhs.Sources}
- { rhs.FreeMask = ~0_u64; rhs.Sources = nullptr; }
- ~SourceSubList();
-
- SourceSubList& operator=(const SourceSubList&) = delete;
- SourceSubList& operator=(SourceSubList&& rhs) noexcept
- { std::swap(FreeMask, rhs.FreeMask); std::swap(Sources, rhs.Sources); return *this; }
-};
-
-struct EffectSlotSubList {
- uint64_t FreeMask{~0_u64};
- ALeffectslot *EffectSlots{nullptr}; /* 64 */
-
- EffectSlotSubList() noexcept = default;
- EffectSlotSubList(const EffectSlotSubList&) = delete;
- EffectSlotSubList(EffectSlotSubList&& rhs) noexcept
- : FreeMask{rhs.FreeMask}, EffectSlots{rhs.EffectSlots}
- { rhs.FreeMask = ~0_u64; rhs.EffectSlots = nullptr; }
- ~EffectSlotSubList();
-
- EffectSlotSubList& operator=(const EffectSlotSubList&) = delete;
- EffectSlotSubList& operator=(EffectSlotSubList&& rhs) noexcept
- { std::swap(FreeMask, rhs.FreeMask); std::swap(EffectSlots, rhs.EffectSlots); return *this; }
-};
-
-struct ALCcontext : public al::intrusive_ref<ALCcontext> {
- const al::intrusive_ptr<ALCdevice> mDevice;
+struct ContextBase {
+ DeviceBase *const mDevice;
/* Counter for the pre-mixing updates, in 31.1 fixed point (lowest bit
* indicates if updates are currently happening).
@@ -198,6 +167,47 @@ struct ALCcontext : public al::intrusive_ref<ALCcontext> {
using VoiceCluster = std::unique_ptr<Voice[]>;
al::vector<VoiceCluster> mVoiceClusters;
+
+ ContextBase(DeviceBase *device);
+ ContextBase(const ContextBase&) = delete;
+ ContextBase& operator=(const ContextBase&) = delete;
+ ~ContextBase();
+};
+
+struct SourceSubList {
+ uint64_t FreeMask{~0_u64};
+ ALsource *Sources{nullptr}; /* 64 */
+
+ SourceSubList() noexcept = default;
+ SourceSubList(const SourceSubList&) = delete;
+ SourceSubList(SourceSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Sources{rhs.Sources}
+ { rhs.FreeMask = ~0_u64; rhs.Sources = nullptr; }
+ ~SourceSubList();
+
+ SourceSubList& operator=(const SourceSubList&) = delete;
+ SourceSubList& operator=(SourceSubList&& rhs) noexcept
+ { std::swap(FreeMask, rhs.FreeMask); std::swap(Sources, rhs.Sources); return *this; }
+};
+
+struct EffectSlotSubList {
+ uint64_t FreeMask{~0_u64};
+ ALeffectslot *EffectSlots{nullptr}; /* 64 */
+
+ EffectSlotSubList() noexcept = default;
+ EffectSlotSubList(const EffectSlotSubList&) = delete;
+ EffectSlotSubList(EffectSlotSubList&& rhs) noexcept
+ : FreeMask{rhs.FreeMask}, EffectSlots{rhs.EffectSlots}
+ { rhs.FreeMask = ~0_u64; rhs.EffectSlots = nullptr; }
+ ~EffectSlotSubList();
+
+ EffectSlotSubList& operator=(const EffectSlotSubList&) = delete;
+ EffectSlotSubList& operator=(EffectSlotSubList&& rhs) noexcept
+ { std::swap(FreeMask, rhs.FreeMask); std::swap(EffectSlots, rhs.EffectSlots); return *this; }
+};
+
+struct ALCcontext : public al::intrusive_ref<ALCcontext>, ContextBase {
+ const al::intrusive_ptr<ALCdevice> mALDevice;
+
/* Wet buffers used by effect slots. */
al::vector<WetBufferPtr> mWetBuffers;
diff --git a/alc/alu.cpp b/alc/alu.cpp
index b2b0834a..d5103852 100644
--- a/alc/alu.cpp
+++ b/alc/alu.cpp
@@ -279,7 +279,7 @@ ResamplerFunc PrepareResampler(Resampler resampler, uint increment, InterpState
}
-void ALCdevice::ProcessHrtf(const size_t SamplesToDo)
+void DeviceBase::ProcessHrtf(const size_t SamplesToDo)
{
/* HRTF is stereo output only. */
const uint lidx{RealOut.ChannelIndex[FrontLeft]};
@@ -289,12 +289,12 @@ void ALCdevice::ProcessHrtf(const size_t SamplesToDo)
mHrtfState->mTemp.data(), mHrtfState->mChannels.data(), mHrtfState->mIrSize, SamplesToDo);
}
-void ALCdevice::ProcessAmbiDec(const size_t SamplesToDo)
+void DeviceBase::ProcessAmbiDec(const size_t SamplesToDo)
{
AmbiDecoder->process(RealOut.Buffer, Dry.Buffer.data(), SamplesToDo);
}
-void ALCdevice::ProcessAmbiDecStablized(const size_t SamplesToDo)
+void DeviceBase::ProcessAmbiDecStablized(const size_t SamplesToDo)
{
/* Decode with front image stablization. */
const uint lidx{RealOut.ChannelIndex[FrontLeft]};
@@ -305,7 +305,7 @@ void ALCdevice::ProcessAmbiDecStablized(const size_t SamplesToDo)
SamplesToDo);
}
-void ALCdevice::ProcessUhj(const size_t SamplesToDo)
+void DeviceBase::ProcessUhj(const size_t SamplesToDo)
{
/* UHJ is stereo output only. */
const uint lidx{RealOut.ChannelIndex[FrontLeft]};
@@ -316,7 +316,7 @@ void ALCdevice::ProcessUhj(const size_t SamplesToDo)
SamplesToDo);
}
-void ALCdevice::ProcessBs2b(const size_t SamplesToDo)
+void DeviceBase::ProcessBs2b(const size_t SamplesToDo)
{
/* First, decode the ambisonic mix to the "real" output. */
AmbiDecoder->process(RealOut.Buffer, Dry.Buffer.data(), SamplesToDo);
@@ -364,7 +364,7 @@ inline auto& GetAmbi2DLayout(AmbiLayout layouttype) noexcept
}
-bool CalcContextParams(ALCcontext *ctx)
+bool CalcContextParams(ContextBase *ctx)
{
ContextProps *props{ctx->mParams.ContextUpdate.exchange(nullptr, std::memory_order_acq_rel)};
if(!props) return false;
@@ -379,7 +379,7 @@ bool CalcContextParams(ALCcontext *ctx)
return true;
}
-bool CalcListenerParams(ALCcontext *ctx)
+bool CalcListenerParams(ContextBase *ctx)
{
ListenerProps *props{ctx->mParams.ListenerUpdate.exchange(nullptr,
std::memory_order_acq_rel)};
@@ -417,7 +417,7 @@ bool CalcListenerParams(ALCcontext *ctx)
return true;
}
-bool CalcEffectSlotParams(EffectSlot *slot, EffectSlot **sorted_slots, ALCcontext *context)
+bool CalcEffectSlotParams(EffectSlot *slot, EffectSlot **sorted_slots, ContextBase *context)
{
EffectSlotProps *props{slot->Update.exchange(nullptr, std::memory_order_acq_rel)};
if(!props) return false;
@@ -487,7 +487,7 @@ bool CalcEffectSlotParams(EffectSlot *slot, EffectSlot **sorted_slots, ALCcontex
output = EffectTarget{&target->Wet, nullptr};
else
{
- ALCdevice *device{context->mDevice.get()};
+ DeviceBase *device{context->mDevice};
output = EffectTarget{&device->Dry, &device->RealOut};
}
state->update(context, slot, &slot->mEffectProps, output);
@@ -677,7 +677,7 @@ struct GainTriplet { float Base, HF, LF; };
void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, const float zpos,
const float Distance, const float Spread, const GainTriplet &DryGain,
const al::span<const GainTriplet,MAX_SENDS> WetGain, EffectSlot *(&SendSlots)[MAX_SENDS],
- const VoiceProps *props, const ContextParams &Context, const ALCdevice *Device)
+ const VoiceProps *props, const ContextParams &Context, const DeviceBase *Device)
{
static const ChanMap MonoMap[1]{
{ FrontCenter, 0.0f, 0.0f }
@@ -1202,9 +1202,9 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con
}
}
-void CalcNonAttnSourceParams(Voice *voice, const VoiceProps *props, const ALCcontext *context)
+void CalcNonAttnSourceParams(Voice *voice, const VoiceProps *props, const ContextBase *context)
{
- const ALCdevice *Device{context->mDevice.get()};
+ const DeviceBase *Device{context->mDevice};
EffectSlot *SendSlots[MAX_SENDS];
voice->mDirect.Buffer = Device->Dry.Buffer;
@@ -1248,9 +1248,9 @@ void CalcNonAttnSourceParams(Voice *voice, const VoiceProps *props, const ALCcon
context->mParams, Device);
}
-void CalcAttnSourceParams(Voice *voice, const VoiceProps *props, const ALCcontext *context)
+void CalcAttnSourceParams(Voice *voice, const VoiceProps *props, const ContextBase *context)
{
- const ALCdevice *Device{context->mDevice.get()};
+ const DeviceBase *Device{context->mDevice};
const uint NumSends{Device->NumAuxSends};
/* Set mixing buffers and get send parameters. */
@@ -1548,7 +1548,7 @@ void CalcAttnSourceParams(Voice *voice, const VoiceProps *props, const ALCcontex
context->mParams, Device);
}
-void CalcSourceParams(Voice *voice, ALCcontext *context, bool force)
+void CalcSourceParams(Voice *voice, ContextBase *context, bool force)
{
VoicePropsItem *props{voice->mUpdate.exchange(nullptr, std::memory_order_acq_rel)};
if(!props && !force) return;
@@ -1572,7 +1572,7 @@ void CalcSourceParams(Voice *voice, ALCcontext *context, bool force)
}
-void SendSourceStateEvent(ALCcontext *context, uint id, VChangeState state)
+void SendSourceStateEvent(ContextBase *context, uint id, VChangeState state)
{
RingBuffer *ring{context->mAsyncEvents.get()};
auto evt_vec = ring->getWriteVector();
@@ -1585,7 +1585,7 @@ void SendSourceStateEvent(ALCcontext *context, uint id, VChangeState state)
ring->writeAdvance(1);
}
-void ProcessVoiceChanges(ALCcontext *ctx)
+void ProcessVoiceChanges(ContextBase *ctx)
{
VoiceChange *cur{ctx->mCurrentVoiceChange.load(std::memory_order_acquire)};
VoiceChange *next{cur->mNext.load(std::memory_order_acquire)};
@@ -1680,7 +1680,7 @@ void ProcessVoiceChanges(ALCcontext *ctx)
ctx->mCurrentVoiceChange.store(cur, std::memory_order_release);
}
-void ProcessParamUpdates(ALCcontext *ctx, const EffectSlotArray &slots,
+void ProcessParamUpdates(ContextBase *ctx, const EffectSlotArray &slots,
const al::span<Voice*> voices)
{
ProcessVoiceChanges(ctx);
@@ -1704,11 +1704,11 @@ void ProcessParamUpdates(ALCcontext *ctx, const EffectSlotArray &slots,
IncrementRef(ctx->mUpdateCount);
}
-void ProcessContexts(ALCdevice *device, const uint SamplesToDo)
+void ProcessContexts(DeviceBase *device, const uint SamplesToDo)
{
ASSUME(SamplesToDo > 0);
- for(ALCcontext *ctx : *device->mContexts.load(std::memory_order_acquire))
+ for(ContextBase *ctx : *device->mContexts.load(std::memory_order_acquire))
{
const EffectSlotArray &auxslots = *ctx->mActiveAuxSlots.load(std::memory_order_acquire);
const al::span<Voice*> voices{ctx->getVoicesSpanAcquired()};
@@ -1910,7 +1910,7 @@ void Write(const al::span<const FloatBufferLine> InBuffer, void *OutBuffer, cons
} // namespace
-void ALCdevice::renderSamples(void *outBuffer, const uint numSamples, const size_t frameStep)
+void DeviceBase::renderSamples(void *outBuffer, const uint numSamples, const size_t frameStep)
{
FPUCtl mixer_mode{};
for(uint written{0u};written < numSamples;)
@@ -1981,7 +1981,7 @@ void ALCdevice::renderSamples(void *outBuffer, const uint numSamples, const size
}
}
-void ALCdevice::handleDisconnect(const char *msg, ...)
+void DeviceBase::handleDisconnect(const char *msg, ...)
{
if(!Connected.exchange(false, std::memory_order_acq_rel))
return;
@@ -1997,7 +1997,7 @@ void ALCdevice::handleDisconnect(const char *msg, ...)
evt.u.disconnect.msg[sizeof(evt.u.disconnect.msg)-1] = 0;
IncrementRef(MixCount);
- for(ALCcontext *ctx : *mContexts.load())
+ for(ContextBase *ctx : *mContexts.load())
{
const uint enabledevt{ctx->mEnabledEvts.load(std::memory_order_acquire)};
if((enabledevt&EventType_Disconnected))
diff --git a/alc/effects/autowah.cpp b/alc/effects/autowah.cpp
index 2577eb30..a21d2a01 100644
--- a/alc/effects/autowah.cpp
+++ b/alc/effects/autowah.cpp
@@ -69,8 +69,8 @@ struct AutowahState final : public EffectState {
alignas(16) float mBufferOut[BufferLineSize];
- void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override;
- void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
+ void deviceUpdate(const DeviceBase *device, const Buffer &buffer) override;
+ void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
const al::span<FloatBufferLine> samplesOut) override;
@@ -78,7 +78,7 @@ struct AutowahState final : public EffectState {
DEF_NEWDEL(AutowahState)
};
-void AutowahState::deviceUpdate(const ALCdevice*, const Buffer&)
+void AutowahState::deviceUpdate(const DeviceBase*, const Buffer&)
{
/* (Re-)initializing parameters and clear the buffers. */
@@ -104,10 +104,10 @@ void AutowahState::deviceUpdate(const ALCdevice*, const Buffer&)
}
}
-void AutowahState::update(const ALCcontext *context, const EffectSlot *slot,
+void AutowahState::update(const ContextBase *context, const EffectSlot *slot,
const EffectProps *props, const EffectTarget target)
{
- const ALCdevice *device{context->mDevice.get()};
+ const DeviceBase *device{context->mDevice};
const auto frequency = static_cast<float>(device->Frequency);
const float ReleaseTime{clampf(props->Autowah.ReleaseTime, 0.001f, 1.0f)};
diff --git a/alc/effects/base.h b/alc/effects/base.h
index b482bae2..64621888 100644
--- a/alc/effects/base.h
+++ b/alc/effects/base.h
@@ -10,6 +10,7 @@
#include "atomic.h"
#include "intrusive_ptr.h"
+struct ContextBase;
struct EffectSlot;
struct BufferStorage;
@@ -175,8 +176,8 @@ struct EffectState : public al::intrusive_ref<EffectState> {
virtual ~EffectState() = default;
- virtual void deviceUpdate(const ALCdevice *device, const Buffer &buffer) = 0;
- virtual void update(const ALCcontext *context, const EffectSlot *slot,
+ virtual void deviceUpdate(const DeviceBase *device, const Buffer &buffer) = 0;
+ virtual void update(const ContextBase *context, const EffectSlot *slot,
const EffectProps *props, const EffectTarget target) = 0;
virtual void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
const al::span<FloatBufferLine> samplesOut) = 0;
diff --git a/alc/effects/chorus.cpp b/alc/effects/chorus.cpp
index 365eaf33..805c57d5 100644
--- a/alc/effects/chorus.cpp
+++ b/alc/effects/chorus.cpp
@@ -68,8 +68,8 @@ struct ChorusState final : public EffectState {
void getTriangleDelays(uint (*delays)[MAX_UPDATE_SAMPLES], const size_t todo);
void getSinusoidDelays(uint (*delays)[MAX_UPDATE_SAMPLES], const size_t todo);
- void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override;
- void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
+ void deviceUpdate(const DeviceBase *device, const Buffer &buffer) override;
+ void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
const al::span<FloatBufferLine> samplesOut) override;
@@ -77,7 +77,7 @@ struct ChorusState final : public EffectState {
DEF_NEWDEL(ChorusState)
};
-void ChorusState::deviceUpdate(const ALCdevice *Device, const Buffer&)
+void ChorusState::deviceUpdate(const DeviceBase *Device, const Buffer&)
{
constexpr float max_delay{maxf(AL_CHORUS_MAX_DELAY, AL_FLANGER_MAX_DELAY)};
@@ -94,7 +94,7 @@ void ChorusState::deviceUpdate(const ALCdevice *Device, const Buffer&)
}
}
-void ChorusState::update(const ALCcontext *Context, const EffectSlot *Slot,
+void ChorusState::update(const ContextBase *Context, const EffectSlot *Slot,
const EffectProps *props, const EffectTarget target)
{
constexpr int mindelay{(MaxResamplerPadding>>1) << MixerFracBits};
@@ -102,7 +102,7 @@ void ChorusState::update(const ALCcontext *Context, const EffectSlot *Slot,
/* The LFO depth is scaled to be relative to the sample delay. Clamp the
* delay and depth to allow enough padding for resampling.
*/
- const ALCdevice *device{Context->mDevice.get()};
+ const DeviceBase *device{Context->mDevice};
const auto frequency = static_cast<float>(device->Frequency);
mWaveform = props->Chorus.Waveform;
diff --git a/alc/effects/compressor.cpp b/alc/effects/compressor.cpp
index 393bb93f..88fcf442 100644
--- a/alc/effects/compressor.cpp
+++ b/alc/effects/compressor.cpp
@@ -49,8 +49,8 @@ struct CompressorState final : public EffectState {
float mEnvFollower{1.0f};
- void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override;
- void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
+ void deviceUpdate(const DeviceBase *device, const Buffer &buffer) override;
+ void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
const al::span<FloatBufferLine> samplesOut) override;
@@ -58,7 +58,7 @@ struct CompressorState final : public EffectState {
DEF_NEWDEL(CompressorState)
};
-void CompressorState::deviceUpdate(const ALCdevice *device, const Buffer&)
+void CompressorState::deviceUpdate(const DeviceBase *device, const Buffer&)
{
/* Number of samples to do a full attack and release (non-integer sample
* counts are okay).
@@ -73,7 +73,7 @@ void CompressorState::deviceUpdate(const ALCdevice *device, const Buffer&)
mReleaseMult = std::pow(AMP_ENVELOPE_MIN/AMP_ENVELOPE_MAX, 1.0f/releaseCount);
}
-void CompressorState::update(const ALCcontext*, const EffectSlot *slot,
+void CompressorState::update(const ContextBase*, const EffectSlot *slot,
const EffectProps *props, const EffectTarget target)
{
mEnabled = props->Compressor.OnOff;
diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp
index 5bb52656..0a1bd214 100644
--- a/alc/effects/convolution.cpp
+++ b/alc/effects/convolution.cpp
@@ -190,8 +190,8 @@ struct ConvolutionState final : public EffectState {
void (ConvolutionState::*mMix)(const al::span<FloatBufferLine>,const size_t)
{&ConvolutionState::NormalMix};
- void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override;
- void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
+ void deviceUpdate(const DeviceBase *device, const Buffer &buffer) override;
+ void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
const al::span<FloatBufferLine> samplesOut) override;
@@ -219,7 +219,7 @@ void ConvolutionState::UpsampleMix(const al::span<FloatBufferLine> samplesOut,
}
-void ConvolutionState::deviceUpdate(const ALCdevice *device, const Buffer &buffer)
+void ConvolutionState::deviceUpdate(const DeviceBase *device, const Buffer &buffer)
{
constexpr uint MaxConvolveAmbiOrder{1u};
@@ -316,7 +316,7 @@ void ConvolutionState::deviceUpdate(const ALCdevice *device, const Buffer &buffe
}
-void ConvolutionState::update(const ALCcontext *context, const EffectSlot *slot,
+void ConvolutionState::update(const ContextBase *context, const EffectSlot *slot,
const EffectProps* /*props*/, const EffectTarget target)
{
/* NOTE: Stereo and Rear are slightly different from normal mixing (as
@@ -394,7 +394,7 @@ void ConvolutionState::update(const ALCcontext *context, const EffectSlot *slot,
}
else if(mChannels == FmtBFormat3D || mChannels == FmtBFormat2D)
{
- ALCdevice *device{context->mDevice.get()};
+ DeviceBase *device{context->mDevice};
if(device->mAmbiOrder > mAmbiOrder)
{
mMix = &ConvolutionState::UpsampleMix;
@@ -421,7 +421,7 @@ void ConvolutionState::update(const ALCcontext *context, const EffectSlot *slot,
}
else
{
- ALCdevice *device{context->mDevice.get()};
+ DeviceBase *device{context->mDevice};
al::span<const ChanMap> chanmap{};
switch(mChannels)
{
diff --git a/alc/effects/dedicated.cpp b/alc/effects/dedicated.cpp
index 9fee7fd7..f29458d2 100644
--- a/alc/effects/dedicated.cpp
+++ b/alc/effects/dedicated.cpp
@@ -37,8 +37,8 @@ struct DedicatedState final : public EffectState {
float mTargetGains[MAX_OUTPUT_CHANNELS];
- void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override;
- void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
+ void deviceUpdate(const DeviceBase *device, const Buffer &buffer) override;
+ void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
const al::span<FloatBufferLine> samplesOut) override;
@@ -46,12 +46,12 @@ struct DedicatedState final : public EffectState {
DEF_NEWDEL(DedicatedState)
};
-void DedicatedState::deviceUpdate(const ALCdevice*, const Buffer&)
+void DedicatedState::deviceUpdate(const DeviceBase*, const Buffer&)
{
std::fill(std::begin(mCurrentGains), std::end(mCurrentGains), 0.0f);
}
-void DedicatedState::update(const ALCcontext*, const EffectSlot *slot,
+void DedicatedState::update(const ContextBase*, const EffectSlot *slot,
const EffectProps *props, const EffectTarget target)
{
std::fill(std::begin(mTargetGains), std::end(mTargetGains), 0.0f);
diff --git a/alc/effects/distortion.cpp b/alc/effects/distortion.cpp
index 09dae4c5..a9ac8293 100644
--- a/alc/effects/distortion.cpp
+++ b/alc/effects/distortion.cpp
@@ -45,8 +45,8 @@ struct DistortionState final : public EffectState {
float mBuffer[2][BufferLineSize]{};
- void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override;
- void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
+ void deviceUpdate(const DeviceBase *device, const Buffer &buffer) override;
+ void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
const al::span<FloatBufferLine> samplesOut) override;
@@ -54,16 +54,16 @@ struct DistortionState final : public EffectState {
DEF_NEWDEL(DistortionState)
};
-void DistortionState::deviceUpdate(const ALCdevice*, const Buffer&)
+void DistortionState::deviceUpdate(const DeviceBase*, const Buffer&)
{
mLowpass.clear();
mBandpass.clear();
}
-void DistortionState::update(const ALCcontext *context, const EffectSlot *slot,
+void DistortionState::update(const ContextBase *context, const EffectSlot *slot,
const EffectProps *props, const EffectTarget target)
{
- const ALCdevice *device{context->mDevice.get()};
+ const DeviceBase *device{context->mDevice};
/* Store waveshaper edge settings. */
const float edge{minf(std::sin(al::MathDefs<float>::Pi()*0.5f * props->Distortion.Edge),
diff --git a/alc/effects/echo.cpp b/alc/effects/echo.cpp
index f782055f..38183460 100644
--- a/alc/effects/echo.cpp
+++ b/alc/effects/echo.cpp
@@ -57,8 +57,8 @@ struct EchoState final : public EffectState {
alignas(16) float mTempBuffer[2][BufferLineSize];
- void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override;
- void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
+ void deviceUpdate(const DeviceBase *device, const Buffer &buffer) override;
+ void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
const al::span<FloatBufferLine> samplesOut) override;
@@ -66,7 +66,7 @@ struct EchoState final : public EffectState {
DEF_NEWDEL(EchoState)
};
-void EchoState::deviceUpdate(const ALCdevice *Device, const Buffer&)
+void EchoState::deviceUpdate(const DeviceBase *Device, const Buffer&)
{
const auto frequency = static_cast<float>(Device->Frequency);
@@ -85,10 +85,10 @@ void EchoState::deviceUpdate(const ALCdevice *Device, const Buffer&)
}
}
-void EchoState::update(const ALCcontext *context, const EffectSlot *slot,
+void EchoState::update(const ContextBase *context, const EffectSlot *slot,
const EffectProps *props, const EffectTarget target)
{
- const ALCdevice *device{context->mDevice.get()};
+ const DeviceBase *device{context->mDevice};
const auto frequency = static_cast<float>(device->Frequency);
mTap[0].delay = maxu(float2uint(props->Echo.Delay*frequency + 0.5f), 1);
diff --git a/alc/effects/equalizer.cpp b/alc/effects/equalizer.cpp
index bd19c051..fd8bf8c7 100644
--- a/alc/effects/equalizer.cpp
+++ b/alc/effects/equalizer.cpp
@@ -90,8 +90,8 @@ struct EqualizerState final : public EffectState {
FloatBufferLine mSampleBuffer{};
- void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override;
- void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
+ void deviceUpdate(const DeviceBase *device, const Buffer &buffer) override;
+ void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
const al::span<FloatBufferLine> samplesOut) override;
@@ -99,7 +99,7 @@ struct EqualizerState final : public EffectState {
DEF_NEWDEL(EqualizerState)
};
-void EqualizerState::deviceUpdate(const ALCdevice*, const Buffer&)
+void EqualizerState::deviceUpdate(const DeviceBase*, const Buffer&)
{
for(auto &e : mChans)
{
@@ -108,10 +108,10 @@ void EqualizerState::deviceUpdate(const ALCdevice*, const Buffer&)
}
}
-void EqualizerState::update(const ALCcontext *context, const EffectSlot *slot,
+void EqualizerState::update(const ContextBase *context, const EffectSlot *slot,
const EffectProps *props, const EffectTarget target)
{
- const ALCdevice *device{context->mDevice.get()};
+ const DeviceBase *device{context->mDevice};
auto frequency = static_cast<float>(device->Frequency);
float gain, f0norm;
diff --git a/alc/effects/fshifter.cpp b/alc/effects/fshifter.cpp
index 4037f46b..e378a267 100644
--- a/alc/effects/fshifter.cpp
+++ b/alc/effects/fshifter.cpp
@@ -84,8 +84,8 @@ struct FshifterState final : public EffectState {
} mGains[2];
- void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override;
- void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
+ void deviceUpdate(const DeviceBase *device, const Buffer &buffer) override;
+ void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
const al::span<FloatBufferLine> samplesOut) override;
@@ -93,7 +93,7 @@ struct FshifterState final : public EffectState {
DEF_NEWDEL(FshifterState)
};
-void FshifterState::deviceUpdate(const ALCdevice*, const Buffer&)
+void FshifterState::deviceUpdate(const DeviceBase*, const Buffer&)
{
/* (Re-)initializing parameters and clear the buffers. */
mCount = 0;
@@ -114,10 +114,10 @@ void FshifterState::deviceUpdate(const ALCdevice*, const Buffer&)
}
}
-void FshifterState::update(const ALCcontext *context, const EffectSlot *slot,
+void FshifterState::update(const ContextBase *context, const EffectSlot *slot,
const EffectProps *props, const EffectTarget target)
{
- const ALCdevice *device{context->mDevice.get()};
+ const DeviceBase *device{context->mDevice};
const float step{props->Fshifter.Frequency / static_cast<float>(device->Frequency)};
mPhaseStep[0] = mPhaseStep[1] = fastf2u(minf(step, 1.0f) * MixerFracOne);
diff --git a/alc/effects/modulator.cpp b/alc/effects/modulator.cpp
index 267c73e7..380d9809 100644
--- a/alc/effects/modulator.cpp
+++ b/alc/effects/modulator.cpp
@@ -81,8 +81,8 @@ struct ModulatorState final : public EffectState {
} mChans[MaxAmbiChannels];
- void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override;
- void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
+ void deviceUpdate(const DeviceBase *device, const Buffer &buffer) override;
+ void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
const al::span<FloatBufferLine> samplesOut) override;
@@ -90,7 +90,7 @@ struct ModulatorState final : public EffectState {
DEF_NEWDEL(ModulatorState)
};
-void ModulatorState::deviceUpdate(const ALCdevice*, const Buffer&)
+void ModulatorState::deviceUpdate(const DeviceBase*, const Buffer&)
{
for(auto &e : mChans)
{
@@ -99,10 +99,10 @@ void ModulatorState::deviceUpdate(const ALCdevice*, const Buffer&)
}
}
-void ModulatorState::update(const ALCcontext *context, const EffectSlot *slot,
+void ModulatorState::update(const ContextBase *context, const EffectSlot *slot,
const EffectProps *props, const EffectTarget target)
{
- const ALCdevice *device{context->mDevice.get()};
+ const DeviceBase *device{context->mDevice};
const float step{props->Modulator.Frequency / static_cast<float>(device->Frequency)};
mStep = fastf2u(clampf(step*WAVEFORM_FRACONE, 0.0f, float{WAVEFORM_FRACONE-1}));
diff --git a/alc/effects/null.cpp b/alc/effects/null.cpp
index 9d589285..f838a367 100644
--- a/alc/effects/null.cpp
+++ b/alc/effects/null.cpp
@@ -15,8 +15,8 @@ struct NullState final : public EffectState {
NullState();
~NullState() override;
- void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override;
- void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
+ void deviceUpdate(const DeviceBase *device, const Buffer &buffer) override;
+ void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
const al::span<FloatBufferLine> samplesOut) override;
@@ -39,14 +39,14 @@ NullState::~NullState() = default;
* format) have been changed. Will always be followed by a call to the update
* method, if successful.
*/
-void NullState::deviceUpdate(const ALCdevice* /*device*/, const Buffer& /*buffer*/)
+void NullState::deviceUpdate(const DeviceBase* /*device*/, const Buffer& /*buffer*/)
{
}
/* This updates the effect state with new properties. This is called any time
* the effect is (re)loaded into a slot.
*/
-void NullState::update(const ALCcontext* /*context*/, const EffectSlot* /*slot*/,
+void NullState::update(const ContextBase* /*context*/, const EffectSlot* /*slot*/,
const EffectProps* /*props*/, const EffectTarget /*target*/)
{
}
diff --git a/alc/effects/pshifter.cpp b/alc/effects/pshifter.cpp
index 5087860f..1cf4861f 100644
--- a/alc/effects/pshifter.cpp
+++ b/alc/effects/pshifter.cpp
@@ -93,8 +93,8 @@ struct PshifterState final : public EffectState {
float mTargetGains[MAX_OUTPUT_CHANNELS];
- void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override;
- void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
+ void deviceUpdate(const DeviceBase *device, const Buffer &buffer) override;
+ void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
const al::span<FloatBufferLine> samplesOut) override;
@@ -102,7 +102,7 @@ struct PshifterState final : public EffectState {
DEF_NEWDEL(PshifterState)
};
-void PshifterState::deviceUpdate(const ALCdevice*, const Buffer&)
+void PshifterState::deviceUpdate(const DeviceBase*, const Buffer&)
{
/* (Re-)initializing parameters and clear the buffers. */
mCount = 0;
@@ -122,7 +122,7 @@ void PshifterState::deviceUpdate(const ALCdevice*, const Buffer&)
std::fill(std::begin(mTargetGains), std::end(mTargetGains), 0.0f);
}
-void PshifterState::update(const ALCcontext*, const EffectSlot *slot,
+void PshifterState::update(const ContextBase*, const EffectSlot *slot,
const EffectProps *props, const EffectTarget target)
{
const int tune{props->Pshifter.CoarseTune*100 + props->Pshifter.FineTune};
diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp
index a519fc34..1260748c 100644
--- a/alc/effects/reverb.cpp
+++ b/alc/effects/reverb.cpp
@@ -527,8 +527,8 @@ struct ReverbState final : public EffectState {
void lateFaded(const size_t offset, const size_t todo, const float fade,
const float fadeStep);
- void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override;
- void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
+ void deviceUpdate(const DeviceBase *device, const Buffer &buffer) override;
+ void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
const al::span<FloatBufferLine> samplesOut) override;
@@ -607,7 +607,7 @@ void ReverbState::allocLines(const float frequency)
mLate.Delay.realizeLineOffset(mSampleBuffer.data());
}
-void ReverbState::deviceUpdate(const ALCdevice *device, const Buffer&)
+void ReverbState::deviceUpdate(const DeviceBase *device, const Buffer&)
{
const auto frequency = static_cast<float>(device->Frequency);
@@ -985,10 +985,10 @@ void ReverbState::update3DPanning(const float *ReflectionsPan, const float *Late
}
}
-void ReverbState::update(const ALCcontext *Context, const EffectSlot *Slot,
+void ReverbState::update(const ContextBase *Context, const EffectSlot *Slot,
const EffectProps *props, const EffectTarget target)
{
- const ALCdevice *Device{Context->mDevice.get()};
+ const DeviceBase *Device{Context->mDevice};
const auto frequency = static_cast<float>(Device->Frequency);
/* Calculate the master filters */
diff --git a/alc/effects/vmorpher.cpp b/alc/effects/vmorpher.cpp
index ab21439c..332df159 100644
--- a/alc/effects/vmorpher.cpp
+++ b/alc/effects/vmorpher.cpp
@@ -138,8 +138,8 @@ struct VmorpherState final : public EffectState {
alignas(16) float mSampleBufferB[MAX_UPDATE_SAMPLES]{};
alignas(16) float mLfo[MAX_UPDATE_SAMPLES]{};
- void deviceUpdate(const ALCdevice *device, const Buffer &buffer) override;
- void update(const ALCcontext *context, const EffectSlot *slot, const EffectProps *props,
+ void deviceUpdate(const DeviceBase *device, const Buffer &buffer) override;
+ void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
const al::span<FloatBufferLine> samplesOut) override;
@@ -202,7 +202,7 @@ std::array<FormantFilter,4> VmorpherState::getFiltersByPhoneme(VMorpherPhenome p
}
-void VmorpherState::deviceUpdate(const ALCdevice*, const Buffer&)
+void VmorpherState::deviceUpdate(const DeviceBase*, const Buffer&)
{
for(auto &e : mChans)
{
@@ -214,10 +214,10 @@ void VmorpherState::deviceUpdate(const ALCdevice*, const Buffer&)
}
}
-void VmorpherState::update(const ALCcontext *context, const EffectSlot *slot,
+void VmorpherState::update(const ContextBase *context, const EffectSlot *slot,
const EffectProps *props, const EffectTarget target)
{
- const ALCdevice *device{context->mDevice.get()};
+ const DeviceBase *device{context->mDevice};
const float frequency{static_cast<float>(device->Frequency)};
const float step{props->Vmorpher.Rate / frequency};
mStep = fastf2u(clampf(step*WAVEFORM_FRACONE, 0.0f, float{WAVEFORM_FRACONE-1}));
diff --git a/alc/panning.cpp b/alc/panning.cpp
index d385ecf0..39f4f4c3 100644
--- a/alc/panning.cpp
+++ b/alc/panning.cpp
@@ -1041,7 +1041,7 @@ no_hrtf:
void aluInitEffectPanning(EffectSlot *slot, ALCcontext *context)
{
- ALCdevice *device{context->mDevice.get()};
+ DeviceBase *device{context->mDevice};
const size_t count{AmbiChannelsFromOrder(device->mAmbiOrder)};
auto wetbuffer_iter = context->mWetBuffers.end();
diff --git a/alc/voice.cpp b/alc/voice.cpp
index afc22a9b..ba00f082 100644
--- a/alc/voice.cpp
+++ b/alc/voice.cpp
@@ -181,7 +181,7 @@ void aluInitMixer()
namespace {
-void SendSourceStoppedEvent(ALCcontext *context, uint id)
+void SendSourceStoppedEvent(ContextBase *context, uint id)
{
RingBuffer *ring{context->mAsyncEvents.get()};
auto evt_vec = ring->getWriteVector();
@@ -370,7 +370,7 @@ void LoadBufferQueue(VoiceBufferItem *buffer, VoiceBufferItem *bufferLoopItem,
void DoHrtfMix(const float *samples, const uint DstBufferSize, DirectParams &parms,
- const float TargetGain, const uint Counter, uint OutPos, ALCdevice *Device)
+ const float TargetGain, const uint Counter, uint OutPos, DeviceBase *Device)
{
const uint IrSize{Device->mIrSize};
auto &HrtfSamples = Device->HrtfSourceData;
@@ -446,7 +446,7 @@ void DoHrtfMix(const float *samples, const uint DstBufferSize, DirectParams &par
}
void DoNfcMix(const al::span<const float> samples, FloatBufferLine *OutBuffer, DirectParams &parms,
- const float *TargetGains, const uint Counter, const uint OutPos, ALCdevice *Device)
+ const float *TargetGains, const uint Counter, const uint OutPos, DeviceBase *Device)
{
using FilterProc = void (NfcFilter::*)(const al::span<const float>, float*);
static constexpr FilterProc NfcProcess[MaxAmbiOrder+1]{
@@ -474,7 +474,7 @@ void DoNfcMix(const al::span<const float> samples, FloatBufferLine *OutBuffer, D
} // namespace
-void Voice::mix(const State vstate, ALCcontext *Context, const uint SamplesToDo)
+void Voice::mix(const State vstate, ContextBase *Context, const uint SamplesToDo)
{
static constexpr std::array<float,MAX_OUTPUT_CHANNELS> SilentTarget{};
@@ -496,7 +496,7 @@ void Voice::mix(const State vstate, ALCcontext *Context, const uint SamplesToDo)
return;
}
- ALCdevice *Device{Context->mDevice.get()};
+ DeviceBase *Device{Context->mDevice};
const uint NumSends{Device->NumAuxSends};
ResamplerFunc Resample{(increment == MixerFracOne && DataPosFrac == 0) ?
@@ -819,7 +819,7 @@ void Voice::mix(const State vstate, ALCcontext *Context, const uint SamplesToDo)
}
}
-void Voice::prepare(ALCdevice *device)
+void Voice::prepare(DeviceBase *device)
{
if((mFmtChannels == FmtUHJ2 || mFmtChannels == FmtUHJ3 || mFmtChannels==FmtUHJ4) && !mDecoder)
mDecoder = std::make_unique<UhjDecoder>();
diff --git a/alc/voice.h b/alc/voice.h
index 8f3476f1..809cac8a 100644
--- a/alc/voice.h
+++ b/alc/voice.h
@@ -18,7 +18,8 @@
#include "core/uhjfilter.h"
#include "vector.h"
-struct ALCcontext;
+struct ContextBase;
+struct DeviceBase;
struct EffectSlot;
enum class DistanceModel : unsigned char;
@@ -247,9 +248,9 @@ struct Voice {
Voice(const Voice&) = delete;
Voice& operator=(const Voice&) = delete;
- void mix(const State vstate, ALCcontext *Context, const uint SamplesToDo);
+ void mix(const State vstate, ContextBase *Context, const uint SamplesToDo);
- void prepare(ALCdevice *device);
+ void prepare(DeviceBase *device);
DEF_NEWDEL(Voice)
};