Properly prefix ALCcontext members
parent
488d1de944
commit
ea76e003e7
|
@ -54,9 +54,9 @@ inline ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id) noexcept
|
|||
ALuint lidx = (id-1) >> 6;
|
||||
ALsizei slidx = (id-1) & 0x3f;
|
||||
|
||||
if(UNLIKELY(lidx >= context->EffectSlotList.size()))
|
||||
if(UNLIKELY(lidx >= context->mEffectSlotList.size()))
|
||||
return nullptr;
|
||||
EffectSlotSubList &sublist{context->EffectSlotList[lidx]};
|
||||
EffectSlotSubList &sublist{context->mEffectSlotList[lidx]};
|
||||
if(UNLIKELY(sublist.FreeMask & (1_u64 << slidx)))
|
||||
return nullptr;
|
||||
return sublist.EffectSlots + slidx;
|
||||
|
@ -79,7 +79,7 @@ inline ALeffect *LookupEffect(ALCdevice *device, ALuint id) noexcept
|
|||
void AddActiveEffectSlots(const ALuint *slotids, ALsizei count, ALCcontext *context)
|
||||
{
|
||||
if(count < 1) return;
|
||||
ALeffectslotArray *curarray{context->ActiveAuxSlots.load(std::memory_order_acquire)};
|
||||
ALeffectslotArray *curarray{context->mActiveAuxSlots.load(std::memory_order_acquire)};
|
||||
size_t newcount{curarray->size() + count};
|
||||
|
||||
/* Insert the new effect slots into the head of the array, followed by the
|
||||
|
@ -114,8 +114,8 @@ void AddActiveEffectSlots(const ALuint *slotids, ALsizei count, ALCcontext *cont
|
|||
curarray = nullptr;
|
||||
}
|
||||
|
||||
curarray = context->ActiveAuxSlots.exchange(newarray, std::memory_order_acq_rel);
|
||||
ALCdevice *device{context->Device};
|
||||
curarray = context->mActiveAuxSlots.exchange(newarray, std::memory_order_acq_rel);
|
||||
ALCdevice *device{context->mDevice};
|
||||
while((device->MixCount.load(std::memory_order_acquire)&1))
|
||||
std::this_thread::yield();
|
||||
delete curarray;
|
||||
|
@ -124,7 +124,7 @@ void AddActiveEffectSlots(const ALuint *slotids, ALsizei count, ALCcontext *cont
|
|||
void RemoveActiveEffectSlots(const ALuint *slotids, ALsizei count, ALCcontext *context)
|
||||
{
|
||||
if(count < 1) return;
|
||||
ALeffectslotArray *curarray{context->ActiveAuxSlots.load(std::memory_order_acquire)};
|
||||
ALeffectslotArray *curarray{context->mActiveAuxSlots.load(std::memory_order_acquire)};
|
||||
|
||||
/* Don't shrink the allocated array size since we don't know how many (if
|
||||
* any) of the effect slots to remove are in the array.
|
||||
|
@ -150,8 +150,8 @@ void RemoveActiveEffectSlots(const ALuint *slotids, ALsizei count, ALCcontext *c
|
|||
curarray = nullptr;
|
||||
}
|
||||
|
||||
curarray = context->ActiveAuxSlots.exchange(newarray, std::memory_order_acq_rel);
|
||||
ALCdevice *device{context->Device};
|
||||
curarray = context->mActiveAuxSlots.exchange(newarray, std::memory_order_acq_rel);
|
||||
ALCdevice *device{context->mDevice};
|
||||
while((device->MixCount.load(std::memory_order_acquire)&1))
|
||||
std::this_thread::yield();
|
||||
delete curarray;
|
||||
|
@ -160,22 +160,22 @@ void RemoveActiveEffectSlots(const ALuint *slotids, ALsizei count, ALCcontext *c
|
|||
|
||||
ALeffectslot *AllocEffectSlot(ALCcontext *context)
|
||||
{
|
||||
ALCdevice *device{context->Device};
|
||||
std::lock_guard<std::mutex> _{context->EffectSlotLock};
|
||||
if(context->NumEffectSlots >= device->AuxiliaryEffectSlotMax)
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
|
||||
if(context->mNumEffectSlots >= device->AuxiliaryEffectSlotMax)
|
||||
{
|
||||
alSetError(context, AL_OUT_OF_MEMORY, "Exceeding %u effect slot limit",
|
||||
device->AuxiliaryEffectSlotMax);
|
||||
return nullptr;
|
||||
}
|
||||
auto sublist = std::find_if(context->EffectSlotList.begin(), context->EffectSlotList.end(),
|
||||
auto sublist = std::find_if(context->mEffectSlotList.begin(), context->mEffectSlotList.end(),
|
||||
[](const EffectSlotSubList &entry) noexcept -> bool
|
||||
{ return entry.FreeMask != 0; }
|
||||
);
|
||||
auto lidx = static_cast<ALsizei>(std::distance(context->EffectSlotList.begin(), sublist));
|
||||
auto lidx = static_cast<ALsizei>(std::distance(context->mEffectSlotList.begin(), sublist));
|
||||
ALeffectslot *slot;
|
||||
ALsizei slidx;
|
||||
if(LIKELY(sublist != context->EffectSlotList.end()))
|
||||
if(LIKELY(sublist != context->mEffectSlotList.end()))
|
||||
{
|
||||
slidx = CTZ64(sublist->FreeMask);
|
||||
slot = sublist->EffectSlots + slidx;
|
||||
|
@ -185,19 +185,19 @@ ALeffectslot *AllocEffectSlot(ALCcontext *context)
|
|||
/* Don't allocate so many list entries that the 32-bit ID could
|
||||
* overflow...
|
||||
*/
|
||||
if(UNLIKELY(context->EffectSlotList.size() >= 1<<25))
|
||||
if(UNLIKELY(context->mEffectSlotList.size() >= 1<<25))
|
||||
{
|
||||
alSetError(context, AL_OUT_OF_MEMORY, "Too many effect slots allocated");
|
||||
return nullptr;
|
||||
}
|
||||
context->EffectSlotList.emplace_back();
|
||||
sublist = context->EffectSlotList.end() - 1;
|
||||
context->mEffectSlotList.emplace_back();
|
||||
sublist = context->mEffectSlotList.end() - 1;
|
||||
|
||||
sublist->FreeMask = ~0_u64;
|
||||
sublist->EffectSlots = static_cast<ALeffectslot*>(al_calloc(16, sizeof(ALeffectslot)*64));
|
||||
if(UNLIKELY(!sublist->EffectSlots))
|
||||
{
|
||||
context->EffectSlotList.pop_back();
|
||||
context->mEffectSlotList.pop_back();
|
||||
alSetError(context, AL_OUT_OF_MEMORY, "Failed to allocate effect slot batch");
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ ALeffectslot *AllocEffectSlot(ALCcontext *context)
|
|||
/* Add 1 to avoid source ID 0. */
|
||||
slot->id = ((lidx<<6) | slidx) + 1;
|
||||
|
||||
context->NumEffectSlots += 1;
|
||||
context->mNumEffectSlots += 1;
|
||||
sublist->FreeMask &= ~(1_u64 << slidx);
|
||||
|
||||
return slot;
|
||||
|
@ -233,13 +233,13 @@ void FreeEffectSlot(ALCcontext *context, ALeffectslot *slot)
|
|||
|
||||
al::destroy_at(slot);
|
||||
|
||||
context->EffectSlotList[lidx].FreeMask |= 1_u64 << slidx;
|
||||
context->NumEffectSlots--;
|
||||
context->mEffectSlotList[lidx].FreeMask |= 1_u64 << slidx;
|
||||
context->mNumEffectSlots--;
|
||||
}
|
||||
|
||||
|
||||
#define DO_UPDATEPROPS() do { \
|
||||
if(!context->DeferUpdates.load(std::memory_order_acquire)) \
|
||||
if(!context->mDeferUpdates.load(std::memory_order_acquire)) \
|
||||
UpdateEffectSlotProps(slot, context.get()); \
|
||||
else \
|
||||
slot->PropsClean.clear(std::memory_order_release); \
|
||||
|
@ -295,7 +295,7 @@ START_API_FUNC
|
|||
std::copy(tempids.cbegin(), tempids.cend(), effectslots);
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> slotlock{context->EffectSlotLock};
|
||||
std::unique_lock<std::mutex> slotlock{context->mEffectSlotLock};
|
||||
AddActiveEffectSlots(effectslots, n, context.get());
|
||||
}
|
||||
END_API_FUNC
|
||||
|
@ -310,7 +310,7 @@ START_API_FUNC
|
|||
SETERR_RETURN(context.get(), AL_INVALID_VALUE,, "Deleting %d effect slots", n);
|
||||
if(n == 0) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->EffectSlotLock};
|
||||
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
|
||||
auto effectslots_end = effectslots + n;
|
||||
auto bad_slot = std::find_if(effectslots, effectslots_end,
|
||||
[&context](ALuint id) -> bool
|
||||
|
@ -350,7 +350,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(LIKELY(context))
|
||||
{
|
||||
std::lock_guard<std::mutex> _{context->EffectSlotLock};
|
||||
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
|
||||
if(LookupEffectSlot(context.get(), effectslot) != nullptr)
|
||||
return AL_TRUE;
|
||||
}
|
||||
|
@ -365,8 +365,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> __{context->EffectSlotLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
std::lock_guard<std::mutex> __{context->mEffectSlotLock};
|
||||
ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot);
|
||||
if(UNLIKELY(!slot))
|
||||
SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot);
|
||||
|
@ -377,7 +377,7 @@ START_API_FUNC
|
|||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_EFFECT:
|
||||
device = context->Device;
|
||||
device = context->mDevice;
|
||||
|
||||
{ std::lock_guard<std::mutex> ___{device->EffectLock};
|
||||
ALeffect *effect{value ? LookupEffect(device, value) : nullptr};
|
||||
|
@ -453,7 +453,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->EffectSlotLock};
|
||||
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
|
||||
ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot);
|
||||
if(UNLIKELY(!slot))
|
||||
SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot);
|
||||
|
@ -473,8 +473,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> __{context->EffectSlotLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
std::lock_guard<std::mutex> __{context->mEffectSlotLock};
|
||||
ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot);
|
||||
if(UNLIKELY(!slot))
|
||||
SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot);
|
||||
|
@ -508,7 +508,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->EffectSlotLock};
|
||||
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
|
||||
ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot);
|
||||
if(UNLIKELY(!slot))
|
||||
SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot);
|
||||
|
@ -529,7 +529,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->EffectSlotLock};
|
||||
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
|
||||
ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot);
|
||||
if(UNLIKELY(!slot))
|
||||
SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot);
|
||||
|
@ -566,7 +566,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->EffectSlotLock};
|
||||
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
|
||||
ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot);
|
||||
if(UNLIKELY(!slot))
|
||||
SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot);
|
||||
|
@ -586,7 +586,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->EffectSlotLock};
|
||||
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
|
||||
ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot);
|
||||
if(UNLIKELY(!slot))
|
||||
SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot);
|
||||
|
@ -617,7 +617,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->EffectSlotLock};
|
||||
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
|
||||
ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot);
|
||||
if(UNLIKELY(!slot))
|
||||
SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot);
|
||||
|
@ -647,7 +647,7 @@ ALenum InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect
|
|||
if(!State) return AL_OUT_OF_MEMORY;
|
||||
|
||||
FPUCtl mixer_mode{};
|
||||
ALCdevice *Device{Context->Device};
|
||||
ALCdevice *Device{Context->mDevice};
|
||||
std::unique_lock<std::mutex> statelock{Device->StateLock};
|
||||
State->mOutTarget = Device->Dry.Buffer;
|
||||
if(State->deviceUpdate(Device) == AL_FALSE)
|
||||
|
@ -677,7 +677,7 @@ ALenum InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect
|
|||
EffectSlot->Effect.Props = effect->Props;
|
||||
|
||||
/* Remove state references from old effect slot property updates. */
|
||||
ALeffectslotProps *props{Context->FreeEffectslotProps.load()};
|
||||
ALeffectslotProps *props{Context->mFreeEffectslotProps.load()};
|
||||
while(props)
|
||||
{
|
||||
if(props->State)
|
||||
|
@ -739,7 +739,7 @@ ALeffectslot::~ALeffectslot()
|
|||
void UpdateEffectSlotProps(ALeffectslot *slot, ALCcontext *context)
|
||||
{
|
||||
/* Get an unused property container, or allocate a new one as needed. */
|
||||
ALeffectslotProps *props{context->FreeEffectslotProps.load(std::memory_order_relaxed)};
|
||||
ALeffectslotProps *props{context->mFreeEffectslotProps.load(std::memory_order_relaxed)};
|
||||
if(!props)
|
||||
props = static_cast<ALeffectslotProps*>(al_calloc(16, sizeof(*props)));
|
||||
else
|
||||
|
@ -747,7 +747,7 @@ void UpdateEffectSlotProps(ALeffectslot *slot, ALCcontext *context)
|
|||
ALeffectslotProps *next;
|
||||
do {
|
||||
next = props->next.load(std::memory_order_relaxed);
|
||||
} while(context->FreeEffectslotProps.compare_exchange_weak(props, next,
|
||||
} while(context->mFreeEffectslotProps.compare_exchange_weak(props, next,
|
||||
std::memory_order_seq_cst, std::memory_order_acquire) == 0);
|
||||
}
|
||||
|
||||
|
@ -775,7 +775,7 @@ void UpdateEffectSlotProps(ALeffectslot *slot, ALCcontext *context)
|
|||
if(props->State)
|
||||
props->State->DecRef();
|
||||
props->State = nullptr;
|
||||
AtomicReplaceHead(context->FreeEffectslotProps, props);
|
||||
AtomicReplaceHead(context->mFreeEffectslotProps, props);
|
||||
}
|
||||
|
||||
if(oldstate)
|
||||
|
@ -784,8 +784,8 @@ void UpdateEffectSlotProps(ALeffectslot *slot, ALCcontext *context)
|
|||
|
||||
void UpdateAllEffectSlotProps(ALCcontext *context)
|
||||
{
|
||||
std::lock_guard<std::mutex> _{context->EffectSlotLock};
|
||||
ALeffectslotArray *auxslots{context->ActiveAuxSlots.load(std::memory_order_acquire)};
|
||||
std::lock_guard<std::mutex> _{context->mEffectSlotLock};
|
||||
ALeffectslotArray *auxslots{context->mActiveAuxSlots.load(std::memory_order_acquire)};
|
||||
for(ALeffectslot *slot : *auxslots)
|
||||
{
|
||||
if(!slot->PropsClean.test_and_set(std::memory_order_acq_rel))
|
||||
|
|
|
@ -247,7 +247,7 @@ constexpr ALbitfieldSOFT INVALID_MAP_FLAGS{~unsigned(AL_MAP_READ_BIT_SOFT | AL_M
|
|||
|
||||
ALbuffer *AllocBuffer(ALCcontext *context)
|
||||
{
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
auto sublist = std::find_if(device->BufferList.begin(), device->BufferList.end(),
|
||||
[](const BufferSubList &entry) noexcept -> bool
|
||||
|
@ -657,7 +657,7 @@ START_API_FUNC
|
|||
if(UNLIKELY(n == 0))
|
||||
return;
|
||||
|
||||
ALCdevice *device = context->Device;
|
||||
ALCdevice *device = context->mDevice;
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
|
||||
/* First try to find any buffers that are invalid or in-use. */
|
||||
|
@ -700,7 +700,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(LIKELY(context))
|
||||
{
|
||||
ALCdevice *device = context->Device;
|
||||
ALCdevice *device = context->mDevice;
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
if(!buffer || LookupBuffer(device, buffer))
|
||||
return AL_TRUE;
|
||||
|
@ -721,7 +721,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device = context->Device;
|
||||
ALCdevice *device = context->mDevice;
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
|
||||
ALbuffer *albuf = LookupBuffer(device, buffer);
|
||||
|
@ -755,7 +755,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return nullptr;
|
||||
|
||||
ALCdevice *device = context->Device;
|
||||
ALCdevice *device = context->mDevice;
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
|
||||
ALbuffer *albuf = LookupBuffer(device, buffer);
|
||||
|
@ -807,7 +807,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device = context->Device;
|
||||
ALCdevice *device = context->mDevice;
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
|
||||
ALbuffer *albuf = LookupBuffer(device, buffer);
|
||||
|
@ -830,7 +830,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device = context->Device;
|
||||
ALCdevice *device = context->mDevice;
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
|
||||
ALbuffer *albuf = LookupBuffer(device, buffer);
|
||||
|
@ -862,7 +862,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device = context->Device;
|
||||
ALCdevice *device = context->mDevice;
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
|
||||
ALbuffer *albuf = LookupBuffer(device, buffer);
|
||||
|
@ -992,7 +992,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device = context->Device;
|
||||
ALCdevice *device = context->mDevice;
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
|
||||
if(UNLIKELY(LookupBuffer(device, buffer) == nullptr))
|
||||
|
@ -1012,7 +1012,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device = context->Device;
|
||||
ALCdevice *device = context->mDevice;
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
|
||||
if(UNLIKELY(LookupBuffer(device, buffer) == nullptr))
|
||||
|
@ -1031,7 +1031,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device = context->Device;
|
||||
ALCdevice *device = context->mDevice;
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
|
||||
if(UNLIKELY(LookupBuffer(device, buffer) == nullptr))
|
||||
|
@ -1053,7 +1053,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device = context->Device;
|
||||
ALCdevice *device = context->mDevice;
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
|
||||
ALbuffer *albuf = LookupBuffer(device, buffer);
|
||||
|
@ -1088,7 +1088,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device = context->Device;
|
||||
ALCdevice *device = context->mDevice;
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
|
||||
if(UNLIKELY(LookupBuffer(device, buffer) == nullptr))
|
||||
|
@ -1118,7 +1118,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device = context->Device;
|
||||
ALCdevice *device = context->mDevice;
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
|
||||
ALbuffer *albuf = LookupBuffer(device, buffer);
|
||||
|
@ -1156,7 +1156,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device = context->Device;
|
||||
ALCdevice *device = context->mDevice;
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
|
||||
ALbuffer *albuf = LookupBuffer(device, buffer);
|
||||
|
@ -1178,7 +1178,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device = context->Device;
|
||||
ALCdevice *device = context->mDevice;
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
|
||||
if(UNLIKELY(LookupBuffer(device, buffer) == nullptr))
|
||||
|
@ -1206,7 +1206,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device = context->Device;
|
||||
ALCdevice *device = context->mDevice;
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
|
||||
if(UNLIKELY(LookupBuffer(device, buffer) == nullptr))
|
||||
|
@ -1228,7 +1228,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device = context->Device;
|
||||
ALCdevice *device = context->mDevice;
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
ALbuffer *albuf = LookupBuffer(device, buffer);
|
||||
if(UNLIKELY(!albuf))
|
||||
|
@ -1273,7 +1273,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device = context->Device;
|
||||
ALCdevice *device = context->mDevice;
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
if(UNLIKELY(LookupBuffer(device, buffer) == nullptr))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
|
||||
|
@ -1308,7 +1308,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device = context->Device;
|
||||
ALCdevice *device = context->mDevice;
|
||||
std::lock_guard<std::mutex> _{device->BufferLock};
|
||||
ALbuffer *albuf = LookupBuffer(device, buffer);
|
||||
if(UNLIKELY(!albuf))
|
||||
|
|
|
@ -139,7 +139,7 @@ void InitEffectParams(ALeffect *effect, ALenum type)
|
|||
|
||||
ALeffect *AllocEffect(ALCcontext *context)
|
||||
{
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->EffectLock};
|
||||
auto sublist = std::find_if(device->EffectList.begin(), device->EffectList.end(),
|
||||
[](const EffectSubList &entry) noexcept -> bool
|
||||
|
@ -270,7 +270,7 @@ START_API_FUNC
|
|||
if(UNLIKELY(n == 0))
|
||||
return;
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->EffectLock};
|
||||
|
||||
/* First try to find any effects that are invalid. */
|
||||
|
@ -308,7 +308,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(LIKELY(context))
|
||||
{
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->EffectLock};
|
||||
if(!effect || LookupEffect(device, effect))
|
||||
return AL_TRUE;
|
||||
|
@ -323,7 +323,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->EffectLock};
|
||||
|
||||
ALeffect *aleffect{LookupEffect(device, effect)};
|
||||
|
@ -373,7 +373,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->EffectLock};
|
||||
|
||||
ALeffect *aleffect{LookupEffect(device, effect)};
|
||||
|
@ -393,7 +393,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->EffectLock};
|
||||
|
||||
ALeffect *aleffect{LookupEffect(device, effect)};
|
||||
|
@ -413,7 +413,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->EffectLock};
|
||||
|
||||
ALeffect *aleffect{LookupEffect(device, effect)};
|
||||
|
@ -433,7 +433,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->EffectLock};
|
||||
|
||||
const ALeffect *aleffect{LookupEffect(device, effect)};
|
||||
|
@ -465,7 +465,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->EffectLock};
|
||||
|
||||
const ALeffect *aleffect{LookupEffect(device, effect)};
|
||||
|
@ -485,7 +485,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->EffectLock};
|
||||
|
||||
const ALeffect *aleffect{LookupEffect(device, effect)};
|
||||
|
@ -505,7 +505,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->EffectLock};
|
||||
|
||||
const ALeffect *aleffect{LookupEffect(device, effect)};
|
||||
|
|
16
al/error.cpp
16
al/error.cpp
|
@ -82,14 +82,14 @@ void alSetError(ALCcontext *context, ALenum errorCode, const char *msg, ...)
|
|||
}
|
||||
|
||||
ALenum curerr{AL_NO_ERROR};
|
||||
context->LastError.compare_exchange_strong(curerr, errorCode);
|
||||
if((context->EnabledEvts.load(std::memory_order_relaxed)&EventType_Error))
|
||||
context->mLastError.compare_exchange_strong(curerr, errorCode);
|
||||
if((context->mEnabledEvts.load(std::memory_order_relaxed)&EventType_Error))
|
||||
{
|
||||
std::lock_guard<std::mutex> _{context->EventCbLock};
|
||||
ALbitfieldSOFT enabledevts{context->EnabledEvts.load(std::memory_order_relaxed)};
|
||||
if((enabledevts&EventType_Error) && context->EventCb)
|
||||
(*context->EventCb)(AL_EVENT_TYPE_ERROR_SOFT, 0, errorCode, msglen, msg,
|
||||
context->EventParam);
|
||||
std::lock_guard<std::mutex> _{context->mEventCbLock};
|
||||
ALbitfieldSOFT enabledevts{context->mEnabledEvts.load(std::memory_order_relaxed)};
|
||||
if((enabledevts&EventType_Error) && context->mEventCb)
|
||||
(*context->mEventCb)(AL_EVENT_TYPE_ERROR_SOFT, 0, errorCode, msglen, msg,
|
||||
context->mEventParam);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,6 +113,6 @@ START_API_FUNC
|
|||
return deferror;
|
||||
}
|
||||
|
||||
return context->LastError.exchange(AL_NO_ERROR);
|
||||
return context->mLastError.exchange(AL_NO_ERROR);
|
||||
}
|
||||
END_API_FUNC
|
||||
|
|
50
al/event.cpp
50
al/event.cpp
|
@ -31,18 +31,18 @@
|
|||
|
||||
static int EventThread(ALCcontext *context)
|
||||
{
|
||||
RingBuffer *ring{context->AsyncEvents.get()};
|
||||
RingBuffer *ring{context->mAsyncEvents.get()};
|
||||
bool quitnow{false};
|
||||
while(LIKELY(!quitnow))
|
||||
{
|
||||
auto evt_data = ring->getReadVector().first;
|
||||
if(evt_data.len == 0)
|
||||
{
|
||||
context->EventSem.wait();
|
||||
context->mEventSem.wait();
|
||||
continue;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> _{context->EventCbLock};
|
||||
std::lock_guard<std::mutex> _{context->mEventCbLock};
|
||||
do {
|
||||
auto &evt = *reinterpret_cast<AsyncEvent*>(evt_data.buf);
|
||||
evt_data.buf += sizeof(AsyncEvent);
|
||||
|
@ -69,8 +69,8 @@ static int EventThread(ALCcontext *context)
|
|||
continue;
|
||||
}
|
||||
|
||||
ALbitfieldSOFT enabledevts{context->EnabledEvts.load(std::memory_order_acquire)};
|
||||
if(!context->EventCb) continue;
|
||||
ALbitfieldSOFT enabledevts{context->mEnabledEvts.load(std::memory_order_acquire)};
|
||||
if(!context->mEventCb) continue;
|
||||
|
||||
if(evt.EnumType == EventType_SourceStateChange)
|
||||
{
|
||||
|
@ -82,9 +82,9 @@ static int EventThread(ALCcontext *context)
|
|||
(evt.u.srcstate.state==AL_PLAYING) ? "AL_PLAYING" :
|
||||
(evt.u.srcstate.state==AL_PAUSED) ? "AL_PAUSED" :
|
||||
(evt.u.srcstate.state==AL_STOPPED) ? "AL_STOPPED" : "<unknown>";
|
||||
context->EventCb(AL_EVENT_TYPE_SOURCE_STATE_CHANGED_SOFT, evt.u.srcstate.id,
|
||||
context->mEventCb(AL_EVENT_TYPE_SOURCE_STATE_CHANGED_SOFT, evt.u.srcstate.id,
|
||||
evt.u.srcstate.state, static_cast<ALsizei>(msg.length()), msg.c_str(),
|
||||
context->EventParam);
|
||||
context->mEventParam);
|
||||
}
|
||||
else if(evt.EnumType == EventType_BufferCompleted)
|
||||
{
|
||||
|
@ -93,14 +93,14 @@ static int EventThread(ALCcontext *context)
|
|||
std::string msg{std::to_string(evt.u.bufcomp.count)};
|
||||
if(evt.u.bufcomp.count == 1) msg += " buffer completed";
|
||||
else msg += " buffers completed";
|
||||
context->EventCb(AL_EVENT_TYPE_BUFFER_COMPLETED_SOFT, evt.u.bufcomp.id,
|
||||
context->mEventCb(AL_EVENT_TYPE_BUFFER_COMPLETED_SOFT, evt.u.bufcomp.id,
|
||||
evt.u.bufcomp.count, static_cast<ALsizei>(msg.length()), msg.c_str(),
|
||||
context->EventParam);
|
||||
context->mEventParam);
|
||||
}
|
||||
else if((enabledevts&evt.EnumType) == evt.EnumType)
|
||||
context->EventCb(evt.u.user.type, evt.u.user.id, evt.u.user.param,
|
||||
context->mEventCb(evt.u.user.type, evt.u.user.id, evt.u.user.param,
|
||||
static_cast<ALsizei>(strlen(evt.u.user.msg)), evt.u.user.msg,
|
||||
context->EventParam);
|
||||
context->mEventParam);
|
||||
} while(evt_data.len != 0);
|
||||
}
|
||||
return 0;
|
||||
|
@ -109,7 +109,7 @@ static int EventThread(ALCcontext *context)
|
|||
void StartEventThrd(ALCcontext *ctx)
|
||||
{
|
||||
try {
|
||||
ctx->EventThread = std::thread{EventThread, ctx};
|
||||
ctx->mEventThread = std::thread{EventThread, ctx};
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
ERR("Failed to start event thread: %s\n", e.what());
|
||||
|
@ -122,7 +122,7 @@ void StartEventThrd(ALCcontext *ctx)
|
|||
void StopEventThrd(ALCcontext *ctx)
|
||||
{
|
||||
static constexpr AsyncEvent kill_evt{EventType_KillThread};
|
||||
RingBuffer *ring{ctx->AsyncEvents.get()};
|
||||
RingBuffer *ring{ctx->mAsyncEvents.get()};
|
||||
auto evt_data = ring->getWriteVector().first;
|
||||
if(evt_data.len == 0)
|
||||
{
|
||||
|
@ -134,9 +134,9 @@ void StopEventThrd(ALCcontext *ctx)
|
|||
new (evt_data.buf) AsyncEvent{kill_evt};
|
||||
ring->writeAdvance(1);
|
||||
|
||||
ctx->EventSem.post();
|
||||
if(ctx->EventThread.joinable())
|
||||
ctx->EventThread.join();
|
||||
ctx->mEventSem.post();
|
||||
if(ctx->mEventThread.joinable())
|
||||
ctx->mEventThread.join();
|
||||
}
|
||||
|
||||
AL_API void AL_APIENTRY alEventControlSOFT(ALsizei count, const ALenum *types, ALboolean enable)
|
||||
|
@ -176,8 +176,8 @@ START_API_FUNC
|
|||
|
||||
if(enable)
|
||||
{
|
||||
ALbitfieldSOFT enabledevts{context->EnabledEvts.load(std::memory_order_relaxed)};
|
||||
while(context->EnabledEvts.compare_exchange_weak(enabledevts, enabledevts|flags,
|
||||
ALbitfieldSOFT enabledevts{context->mEnabledEvts.load(std::memory_order_relaxed)};
|
||||
while(context->mEnabledEvts.compare_exchange_weak(enabledevts, enabledevts|flags,
|
||||
std::memory_order_acq_rel, std::memory_order_acquire) == 0)
|
||||
{
|
||||
/* enabledevts is (re-)filled with the current value on failure, so
|
||||
|
@ -187,15 +187,15 @@ START_API_FUNC
|
|||
}
|
||||
else
|
||||
{
|
||||
ALbitfieldSOFT enabledevts{context->EnabledEvts.load(std::memory_order_relaxed)};
|
||||
while(context->EnabledEvts.compare_exchange_weak(enabledevts, enabledevts&~flags,
|
||||
ALbitfieldSOFT enabledevts{context->mEnabledEvts.load(std::memory_order_relaxed)};
|
||||
while(context->mEnabledEvts.compare_exchange_weak(enabledevts, enabledevts&~flags,
|
||||
std::memory_order_acq_rel, std::memory_order_acquire) == 0)
|
||||
{
|
||||
}
|
||||
/* Wait to ensure the event handler sees the changed flags before
|
||||
* returning.
|
||||
*/
|
||||
std::lock_guard<std::mutex>{context->EventCbLock};
|
||||
std::lock_guard<std::mutex>{context->mEventCbLock};
|
||||
}
|
||||
}
|
||||
END_API_FUNC
|
||||
|
@ -206,9 +206,9 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> __{context->EventCbLock};
|
||||
context->EventCb = callback;
|
||||
context->EventParam = userParam;
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
std::lock_guard<std::mutex> __{context->mEventCbLock};
|
||||
context->mEventCb = callback;
|
||||
context->mEventParam = userParam;
|
||||
}
|
||||
END_API_FUNC
|
||||
|
|
|
@ -43,7 +43,7 @@ START_API_FUNC
|
|||
SETERR_RETURN(context.get(), AL_INVALID_VALUE, AL_FALSE, "NULL pointer");
|
||||
|
||||
size_t len{strlen(extName)};
|
||||
const char *ptr{context->ExtensionList};
|
||||
const char *ptr{context->mExtensionList};
|
||||
while(ptr && *ptr)
|
||||
{
|
||||
if(strncasecmp(ptr, extName, len) == 0 &&
|
||||
|
|
|
@ -279,7 +279,7 @@ void InitFilterParams(ALfilter *filter, ALenum type)
|
|||
|
||||
ALfilter *AllocFilter(ALCcontext *context)
|
||||
{
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->FilterLock};
|
||||
auto sublist = std::find_if(device->FilterList.begin(), device->FilterList.end(),
|
||||
[](const FilterSubList &entry) noexcept -> bool
|
||||
|
@ -411,7 +411,7 @@ START_API_FUNC
|
|||
if(UNLIKELY(n == 0))
|
||||
return;
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->FilterLock};
|
||||
|
||||
/* First try to find any filters that are invalid. */
|
||||
|
@ -449,7 +449,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(LIKELY(context))
|
||||
{
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->FilterLock};
|
||||
if(!filter || LookupFilter(device, filter))
|
||||
return AL_TRUE;
|
||||
|
@ -465,7 +465,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->FilterLock};
|
||||
|
||||
ALfilter *alfilt{LookupFilter(device, filter)};
|
||||
|
@ -503,7 +503,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->FilterLock};
|
||||
|
||||
ALfilter *alfilt{LookupFilter(device, filter)};
|
||||
|
@ -523,7 +523,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->FilterLock};
|
||||
|
||||
ALfilter *alfilt{LookupFilter(device, filter)};
|
||||
|
@ -543,7 +543,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->FilterLock};
|
||||
|
||||
ALfilter *alfilt{LookupFilter(device, filter)};
|
||||
|
@ -563,7 +563,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->FilterLock};
|
||||
|
||||
ALfilter *alfilt{LookupFilter(device, filter)};
|
||||
|
@ -595,7 +595,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->FilterLock};
|
||||
|
||||
ALfilter *alfilt{LookupFilter(device, filter)};
|
||||
|
@ -615,7 +615,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->FilterLock};
|
||||
|
||||
ALfilter *alfilt{LookupFilter(device, filter)};
|
||||
|
@ -635,7 +635,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{device->FilterLock};
|
||||
|
||||
ALfilter *alfilt{LookupFilter(device, filter)};
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
|
||||
#define DO_UPDATEPROPS() do { \
|
||||
if(!context->DeferUpdates.load(std::memory_order_acquire)) \
|
||||
if(!context->mDeferUpdates.load(std::memory_order_acquire)) \
|
||||
UpdateListenerProps(context.get()); \
|
||||
else \
|
||||
listener.PropsClean.clear(std::memory_order_release); \
|
||||
|
@ -49,8 +49,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALlistener &listener = context->Listener;
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
ALlistener &listener = context->mListener;
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
switch(param)
|
||||
{
|
||||
case AL_GAIN:
|
||||
|
@ -64,11 +64,11 @@ START_API_FUNC
|
|||
if(!(value >= AL_MIN_METERS_PER_UNIT && value <= AL_MAX_METERS_PER_UNIT))
|
||||
SETERR_RETURN(context.get(), AL_INVALID_VALUE,,
|
||||
"Listener meters per unit out of range");
|
||||
context->MetersPerUnit = value;
|
||||
if(!context->DeferUpdates.load(std::memory_order_acquire))
|
||||
context->mMetersPerUnit = value;
|
||||
if(!context->mDeferUpdates.load(std::memory_order_acquire))
|
||||
UpdateContextProps(context.get());
|
||||
else
|
||||
context->PropsClean.clear(std::memory_order_release);
|
||||
context->mPropsClean.clear(std::memory_order_release);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -83,8 +83,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALlistener &listener = context->Listener;
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
ALlistener &listener = context->mListener;
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
switch(param)
|
||||
{
|
||||
case AL_POSITION:
|
||||
|
@ -133,8 +133,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALlistener &listener = context->Listener;
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
ALlistener &listener = context->mListener;
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
if(!values) SETERR_RETURN(context.get(), AL_INVALID_VALUE,, "NULL pointer");
|
||||
switch(param)
|
||||
{
|
||||
|
@ -165,7 +165,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
switch(param)
|
||||
{
|
||||
default:
|
||||
|
@ -188,7 +188,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
switch(param)
|
||||
{
|
||||
default:
|
||||
|
@ -225,7 +225,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
if(!values)
|
||||
alSetError(context.get(), AL_INVALID_VALUE, "NULL pointer");
|
||||
else switch(param)
|
||||
|
@ -243,8 +243,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALlistener &listener = context->Listener;
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
ALlistener &listener = context->mListener;
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
if(!value)
|
||||
alSetError(context.get(), AL_INVALID_VALUE, "NULL pointer");
|
||||
else switch(param)
|
||||
|
@ -254,7 +254,7 @@ START_API_FUNC
|
|||
break;
|
||||
|
||||
case AL_METERS_PER_UNIT:
|
||||
*value = context->MetersPerUnit;
|
||||
*value = context->mMetersPerUnit;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -269,8 +269,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALlistener &listener = context->Listener;
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
ALlistener &listener = context->mListener;
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
if(!value1 || !value2 || !value3)
|
||||
alSetError(context.get(), AL_INVALID_VALUE, "NULL pointer");
|
||||
else switch(param)
|
||||
|
@ -312,8 +312,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALlistener &listener = context->Listener;
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
ALlistener &listener = context->mListener;
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
if(!values)
|
||||
alSetError(context.get(), AL_INVALID_VALUE, "NULL pointer");
|
||||
else switch(param)
|
||||
|
@ -341,7 +341,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
if(!value)
|
||||
alSetError(context.get(), AL_INVALID_VALUE, "NULL pointer");
|
||||
else switch(param)
|
||||
|
@ -358,8 +358,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALlistener &listener = context->Listener;
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
ALlistener &listener = context->mListener;
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
if(!value1 || !value2 || !value3)
|
||||
alSetError(context.get(), AL_INVALID_VALUE, "NULL pointer");
|
||||
else switch(param)
|
||||
|
@ -396,8 +396,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
ALlistener &listener = context->Listener;
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
ALlistener &listener = context->mListener;
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
if(!values)
|
||||
alSetError(context.get(), AL_INVALID_VALUE, "NULL pointer");
|
||||
else switch(param)
|
||||
|
@ -422,7 +422,7 @@ END_API_FUNC
|
|||
void UpdateListenerProps(ALCcontext *context)
|
||||
{
|
||||
/* Get an unused proprty container, or allocate a new one as needed. */
|
||||
ALlistenerProps *props{context->FreeListenerProps.load(std::memory_order_acquire)};
|
||||
ALlistenerProps *props{context->mFreeListenerProps.load(std::memory_order_acquire)};
|
||||
if(!props)
|
||||
props = static_cast<ALlistenerProps*>(al_calloc(16, sizeof(*props)));
|
||||
else
|
||||
|
@ -430,12 +430,12 @@ void UpdateListenerProps(ALCcontext *context)
|
|||
ALlistenerProps *next;
|
||||
do {
|
||||
next = props->next.load(std::memory_order_relaxed);
|
||||
} while(context->FreeListenerProps.compare_exchange_weak(props, next,
|
||||
} while(context->mFreeListenerProps.compare_exchange_weak(props, next,
|
||||
std::memory_order_seq_cst, std::memory_order_acquire) == 0);
|
||||
}
|
||||
|
||||
/* Copy in current property values. */
|
||||
ALlistener &listener = context->Listener;
|
||||
ALlistener &listener = context->mListener;
|
||||
props->Position = listener.Position;
|
||||
props->Velocity = listener.Velocity;
|
||||
props->OrientAt = listener.OrientAt;
|
||||
|
@ -449,6 +449,6 @@ void UpdateListenerProps(ALCcontext *context)
|
|||
/* If there was an unused update container, put it back in the
|
||||
* freelist.
|
||||
*/
|
||||
AtomicReplaceHead(context->FreeListenerProps, props);
|
||||
AtomicReplaceHead(context->mFreeListenerProps, props);
|
||||
}
|
||||
}
|
||||
|
|
208
al/source.cpp
208
al/source.cpp
|
@ -77,10 +77,10 @@ using namespace std::placeholders;
|
|||
inline ALvoice *GetSourceVoice(ALsource *source, ALCcontext *context)
|
||||
{
|
||||
ALint idx{source->VoiceIdx};
|
||||
if(idx >= 0 && static_cast<ALuint>(idx) < context->VoiceCount.load(std::memory_order_relaxed))
|
||||
if(idx >= 0 && static_cast<ALuint>(idx) < context->mVoiceCount.load(std::memory_order_relaxed))
|
||||
{
|
||||
ALuint sid{source->id};
|
||||
ALvoice &voice = (*context->Voices)[idx];
|
||||
ALvoice &voice = (*context->mVoices)[idx];
|
||||
if(voice.mSourceID.load(std::memory_order_acquire) == sid)
|
||||
return &voice;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ inline ALvoice *GetSourceVoice(ALsource *source, ALCcontext *context)
|
|||
void UpdateSourceProps(const ALsource *source, ALvoice *voice, ALCcontext *context)
|
||||
{
|
||||
/* Get an unused property container, or allocate a new one as needed. */
|
||||
ALvoiceProps *props{context->FreeVoiceProps.load(std::memory_order_acquire)};
|
||||
ALvoiceProps *props{context->mFreeVoiceProps.load(std::memory_order_acquire)};
|
||||
if(!props)
|
||||
props = new ALvoiceProps{};
|
||||
else
|
||||
|
@ -99,7 +99,7 @@ void UpdateSourceProps(const ALsource *source, ALvoice *voice, ALCcontext *conte
|
|||
ALvoiceProps *next;
|
||||
do {
|
||||
next = props->next.load(std::memory_order_relaxed);
|
||||
} while(context->FreeVoiceProps.compare_exchange_weak(props, next,
|
||||
} while(context->mFreeVoiceProps.compare_exchange_weak(props, next,
|
||||
std::memory_order_acq_rel, std::memory_order_acquire) == 0);
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ void UpdateSourceProps(const ALsource *source, ALvoice *voice, ALCcontext *conte
|
|||
/* If there was an unused update container, put it back in the
|
||||
* freelist.
|
||||
*/
|
||||
AtomicReplaceHead(context->FreeVoiceProps, props);
|
||||
AtomicReplaceHead(context->mFreeVoiceProps, props);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ void UpdateSourceProps(const ALsource *source, ALvoice *voice, ALCcontext *conte
|
|||
*/
|
||||
int64_t GetSourceSampleOffset(ALsource *Source, ALCcontext *context, std::chrono::nanoseconds *clocktime)
|
||||
{
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
const ALbufferlistitem *Current;
|
||||
uint64_t readPos;
|
||||
ALuint refcount;
|
||||
|
@ -222,7 +222,7 @@ int64_t GetSourceSampleOffset(ALsource *Source, ALCcontext *context, std::chrono
|
|||
*/
|
||||
ALdouble GetSourceSecOffset(ALsource *Source, ALCcontext *context, std::chrono::nanoseconds *clocktime)
|
||||
{
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
const ALbufferlistitem *Current;
|
||||
uint64_t readPos;
|
||||
ALuint refcount;
|
||||
|
@ -282,7 +282,7 @@ ALdouble GetSourceSecOffset(ALsource *Source, ALCcontext *context, std::chrono::
|
|||
*/
|
||||
ALdouble GetSourceOffset(ALsource *Source, ALenum name, ALCcontext *context)
|
||||
{
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
const ALbufferlistitem *Current;
|
||||
ALuint readPos;
|
||||
ALsizei readPosFrac;
|
||||
|
@ -484,21 +484,21 @@ ALboolean ApplyOffset(ALsource *Source, ALvoice *voice)
|
|||
|
||||
ALsource *AllocSource(ALCcontext *context)
|
||||
{
|
||||
ALCdevice *device{context->Device};
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
if(context->NumSources >= device->SourcesMax)
|
||||
ALCdevice *device{context->mDevice};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
if(context->mNumSources >= device->SourcesMax)
|
||||
{
|
||||
alSetError(context, AL_OUT_OF_MEMORY, "Exceeding %u source limit", device->SourcesMax);
|
||||
return nullptr;
|
||||
}
|
||||
auto sublist = std::find_if(context->SourceList.begin(), context->SourceList.end(),
|
||||
auto sublist = std::find_if(context->mSourceList.begin(), context->mSourceList.end(),
|
||||
[](const SourceSubList &entry) noexcept -> bool
|
||||
{ return entry.FreeMask != 0; }
|
||||
);
|
||||
auto lidx = static_cast<ALsizei>(std::distance(context->SourceList.begin(), sublist));
|
||||
auto lidx = static_cast<ALsizei>(std::distance(context->mSourceList.begin(), sublist));
|
||||
ALsource *source;
|
||||
ALsizei slidx;
|
||||
if(LIKELY(sublist != context->SourceList.end()))
|
||||
if(LIKELY(sublist != context->mSourceList.end()))
|
||||
{
|
||||
slidx = CTZ64(sublist->FreeMask);
|
||||
source = sublist->Sources + slidx;
|
||||
|
@ -508,19 +508,19 @@ ALsource *AllocSource(ALCcontext *context)
|
|||
/* Don't allocate so many list entries that the 32-bit ID could
|
||||
* overflow...
|
||||
*/
|
||||
if(UNLIKELY(context->SourceList.size() >= 1<<25))
|
||||
if(UNLIKELY(context->mSourceList.size() >= 1<<25))
|
||||
{
|
||||
alSetError(context, AL_OUT_OF_MEMORY, "Too many sources allocated");
|
||||
return nullptr;
|
||||
}
|
||||
context->SourceList.emplace_back();
|
||||
sublist = context->SourceList.end() - 1;
|
||||
context->mSourceList.emplace_back();
|
||||
sublist = context->mSourceList.end() - 1;
|
||||
|
||||
sublist->FreeMask = ~0_u64;
|
||||
sublist->Sources = static_cast<ALsource*>(al_calloc(16, sizeof(ALsource)*64));
|
||||
if(UNLIKELY(!sublist->Sources))
|
||||
{
|
||||
context->SourceList.pop_back();
|
||||
context->mSourceList.pop_back();
|
||||
alSetError(context, AL_OUT_OF_MEMORY, "Failed to allocate source batch");
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -534,7 +534,7 @@ ALsource *AllocSource(ALCcontext *context)
|
|||
/* Add 1 to avoid source ID 0. */
|
||||
source->id = ((lidx<<6) | slidx) + 1;
|
||||
|
||||
context->NumSources += 1;
|
||||
context->mNumSources += 1;
|
||||
sublist->FreeMask &= ~(1_u64 << slidx);
|
||||
|
||||
return source;
|
||||
|
@ -546,7 +546,7 @@ void FreeSource(ALCcontext *context, ALsource *source)
|
|||
ALsizei lidx = id >> 6;
|
||||
ALsizei slidx = id & 0x3f;
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
BackendUniqueLock backlock{*device->Backend};
|
||||
if(ALvoice *voice{GetSourceVoice(source, context)})
|
||||
{
|
||||
|
@ -565,8 +565,8 @@ void FreeSource(ALCcontext *context, ALsource *source)
|
|||
|
||||
al::destroy_at(source);
|
||||
|
||||
context->SourceList[lidx].FreeMask |= 1_u64 << slidx;
|
||||
context->NumSources--;
|
||||
context->mSourceList[lidx].FreeMask |= 1_u64 << slidx;
|
||||
context->mNumSources--;
|
||||
}
|
||||
|
||||
|
||||
|
@ -575,9 +575,9 @@ inline ALsource *LookupSource(ALCcontext *context, ALuint id) noexcept
|
|||
ALuint lidx = (id-1) >> 6;
|
||||
ALsizei slidx = (id-1) & 0x3f;
|
||||
|
||||
if(UNLIKELY(lidx >= context->SourceList.size()))
|
||||
if(UNLIKELY(lidx >= context->mSourceList.size()))
|
||||
return nullptr;
|
||||
SourceSubList &sublist{context->SourceList[lidx]};
|
||||
SourceSubList &sublist{context->mSourceList[lidx]};
|
||||
if(UNLIKELY(sublist.FreeMask & (1_u64 << slidx)))
|
||||
return nullptr;
|
||||
return sublist.Sources + slidx;
|
||||
|
@ -614,9 +614,9 @@ inline ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id) noexcept
|
|||
ALuint lidx = (id-1) >> 6;
|
||||
ALsizei slidx = (id-1) & 0x3f;
|
||||
|
||||
if(UNLIKELY(lidx >= context->EffectSlotList.size()))
|
||||
if(UNLIKELY(lidx >= context->mEffectSlotList.size()))
|
||||
return nullptr;
|
||||
EffectSlotSubList &sublist{context->EffectSlotList[lidx]};
|
||||
EffectSlotSubList &sublist{context->mEffectSlotList[lidx]};
|
||||
if(UNLIKELY(sublist.FreeMask & (1_u64 << slidx)))
|
||||
return nullptr;
|
||||
return sublist.EffectSlots + slidx;
|
||||
|
@ -715,7 +715,7 @@ inline ALenum GetSourceState(ALsource *source, ALvoice *voice)
|
|||
*/
|
||||
inline bool SourceShouldUpdate(ALsource *source, ALCcontext *context)
|
||||
{
|
||||
return !context->DeferUpdates.load(std::memory_order_acquire) &&
|
||||
return !context->mDeferUpdates.load(std::memory_order_acquire) &&
|
||||
IsPlayingOrPaused(source);
|
||||
}
|
||||
|
||||
|
@ -723,14 +723,14 @@ inline bool SourceShouldUpdate(ALsource *source, ALCcontext *context)
|
|||
/** Can only be called while the mixer is locked! */
|
||||
void SendStateChangeEvent(ALCcontext *context, ALuint id, ALenum state)
|
||||
{
|
||||
ALbitfieldSOFT enabledevt{context->EnabledEvts.load(std::memory_order_acquire)};
|
||||
ALbitfieldSOFT enabledevt{context->mEnabledEvts.load(std::memory_order_acquire)};
|
||||
if(!(enabledevt&EventType_SourceStateChange)) return;
|
||||
|
||||
/* The mixer may have queued a state change that's not yet been processed,
|
||||
* and we don't want state change messages to occur out of order, so send
|
||||
* it through the async queue to ensure proper ordering.
|
||||
*/
|
||||
RingBuffer *ring{context->AsyncEvents.get()};
|
||||
RingBuffer *ring{context->mAsyncEvents.get()};
|
||||
auto evt_vec = ring->getWriteVector();
|
||||
if(evt_vec.first.len < 1) return;
|
||||
|
||||
|
@ -738,7 +738,7 @@ void SendStateChangeEvent(ALCcontext *context, ALuint id, ALenum state)
|
|||
evt->u.srcstate.id = id;
|
||||
evt->u.srcstate.state = state;
|
||||
ring->writeAdvance(1);
|
||||
context->EventSem.post();
|
||||
context->mEventSem.post();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1127,7 +1127,7 @@ ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SourceProp prop, co
|
|||
|
||||
if(IsPlayingOrPaused(Source))
|
||||
{
|
||||
ALCdevice *device{Context->Device};
|
||||
ALCdevice *device{Context->mDevice};
|
||||
BackendLockGuard _{*device->Backend};
|
||||
/* Double-check that the source is still playing while we have
|
||||
* the lock.
|
||||
|
@ -1230,7 +1230,7 @@ ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SourceProp prop, co
|
|||
|
||||
ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, const ALint *values)
|
||||
{
|
||||
ALCdevice *device{Context->Device};
|
||||
ALCdevice *device{Context->mDevice};
|
||||
ALbuffer *buffer{nullptr};
|
||||
ALfilter *filter{nullptr};
|
||||
ALeffectslot *slot{nullptr};
|
||||
|
@ -1348,7 +1348,7 @@ ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, co
|
|||
|
||||
if(IsPlayingOrPaused(Source))
|
||||
{
|
||||
ALCdevice *device{Context->Device};
|
||||
ALCdevice *device{Context->mDevice};
|
||||
BackendLockGuard _{*device->Backend};
|
||||
if(ALvoice *voice{GetSourceVoice(Source, Context)})
|
||||
{
|
||||
|
@ -1423,7 +1423,7 @@ ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, co
|
|||
*values == AL_EXPONENT_DISTANCE_CLAMPED);
|
||||
|
||||
Source->mDistanceModel = static_cast<DistanceModel>(*values);
|
||||
if(Context->SourceDistanceModel)
|
||||
if(Context->mSourceDistanceModel)
|
||||
UpdateSourceProps(Source, Context);
|
||||
return AL_TRUE;
|
||||
|
||||
|
@ -1443,7 +1443,7 @@ ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, co
|
|||
|
||||
|
||||
case AL_AUXILIARY_SEND_FILTER:
|
||||
slotlock = std::unique_lock<std::mutex>{Context->EffectSlotLock};
|
||||
slotlock = std::unique_lock<std::mutex>{Context->mEffectSlotLock};
|
||||
if(!(values[0] == 0 || (slot=LookupEffectSlot(Context, values[0])) != nullptr))
|
||||
SETERR_RETURN(Context, AL_INVALID_VALUE, AL_FALSE, "Invalid effect ID %u",
|
||||
values[0]);
|
||||
|
@ -1664,7 +1664,7 @@ ALboolean GetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp prop,
|
|||
|
||||
ALboolean GetSourcedv(ALsource *Source, ALCcontext *Context, SourceProp prop, ALdouble *values)
|
||||
{
|
||||
ALCdevice *device{Context->Device};
|
||||
ALCdevice *device{Context->mDevice};
|
||||
ClockLatency clocktime;
|
||||
std::chrono::nanoseconds srcclock;
|
||||
ALint ivals[3];
|
||||
|
@ -1997,7 +1997,7 @@ ALboolean GetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, AL
|
|||
|
||||
ALboolean GetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp prop, ALint64SOFT *values)
|
||||
{
|
||||
ALCdevice *device = Context->Device;
|
||||
ALCdevice *device = Context->mDevice;
|
||||
ClockLatency clocktime;
|
||||
std::chrono::nanoseconds srcclock;
|
||||
ALdouble dvals[6];
|
||||
|
@ -2172,7 +2172,7 @@ START_API_FUNC
|
|||
if(n < 0)
|
||||
SETERR_RETURN(context.get(), AL_INVALID_VALUE,, "Deleting %d sources", n);
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
|
||||
/* Check that all Sources are valid */
|
||||
const ALuint *sources_end = sources + n;
|
||||
|
@ -2207,7 +2207,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(LIKELY(context))
|
||||
{
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
if(LookupSource(context.get(), source) != nullptr)
|
||||
return AL_TRUE;
|
||||
}
|
||||
|
@ -2222,8 +2222,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> __{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
std::lock_guard<std::mutex> __{context->mSourceLock};
|
||||
ALsource *Source = LookupSource(context.get(), source);
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2240,8 +2240,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> __{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
std::lock_guard<std::mutex> __{context->mSourceLock};
|
||||
ALsource *Source = LookupSource(context.get(), source);
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2261,8 +2261,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> __{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
std::lock_guard<std::mutex> __{context->mSourceLock};
|
||||
ALsource *Source = LookupSource(context.get(), source);
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2282,8 +2282,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> __{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
std::lock_guard<std::mutex> __{context->mSourceLock};
|
||||
ALsource *Source = LookupSource(context.get(), source);
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2303,8 +2303,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> __{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
std::lock_guard<std::mutex> __{context->mSourceLock};
|
||||
ALsource *Source = LookupSource(context.get(), source);
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2325,8 +2325,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> __{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
std::lock_guard<std::mutex> __{context->mSourceLock};
|
||||
ALsource *Source = LookupSource(context.get(), source);
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2357,8 +2357,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> __{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
std::lock_guard<std::mutex> __{context->mSourceLock};
|
||||
ALsource *Source = LookupSource(context.get(), source);
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2375,8 +2375,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> __{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
std::lock_guard<std::mutex> __{context->mSourceLock};
|
||||
ALsource *Source = LookupSource(context.get(), source);
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2396,8 +2396,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> __{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
std::lock_guard<std::mutex> __{context->mSourceLock};
|
||||
ALsource *Source = LookupSource(context.get(), source);
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2417,8 +2417,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> __{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
std::lock_guard<std::mutex> __{context->mSourceLock};
|
||||
ALsource *Source{LookupSource(context.get(), source)};
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2435,8 +2435,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> __{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
std::lock_guard<std::mutex> __{context->mSourceLock};
|
||||
ALsource *Source{LookupSource(context.get(), source)};
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2456,8 +2456,8 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> __{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
std::lock_guard<std::mutex> __{context->mSourceLock};
|
||||
ALsource *Source{LookupSource(context.get(), source)};
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2477,7 +2477,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
ALsource *Source{LookupSource(context.get(), source)};
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2500,7 +2500,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
ALsource *Source{LookupSource(context.get(), source)};
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2527,7 +2527,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
ALsource *Source{LookupSource(context.get(), source)};
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2558,7 +2558,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
ALsource *Source{LookupSource(context.get(), source)};
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2577,7 +2577,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
ALsource *Source{LookupSource(context.get(), source)};
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2604,7 +2604,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
ALsource *Source{LookupSource(context.get(), source)};
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2624,7 +2624,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
ALsource *Source{LookupSource(context.get(), source)};
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2643,7 +2643,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
ALsource *Source{LookupSource(context.get(), source)};
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2670,7 +2670,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
ALsource *Source{LookupSource(context.get(), source)};
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2690,7 +2690,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
ALsource *Source{LookupSource(context.get(), source)};
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2709,7 +2709,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
ALsource *Source{LookupSource(context.get(), source)};
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2736,7 +2736,7 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
ALsource *Source{LookupSource(context.get(), source)};
|
||||
if(UNLIKELY(!Source))
|
||||
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
|
||||
|
@ -2774,7 +2774,7 @@ START_API_FUNC
|
|||
srchandles = extra_sources.data();
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
for(ALsizei i{0};i < n;i++)
|
||||
{
|
||||
srchandles[i] = LookupSource(context.get(), sources[i]);
|
||||
|
@ -2782,7 +2782,7 @@ START_API_FUNC
|
|||
SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid source ID %u", sources[i]);
|
||||
}
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
BackendLockGuard __{*device->Backend};
|
||||
/* If the device is disconnected, go right to stopped. */
|
||||
if(UNLIKELY(!device->Connected.load(std::memory_order_acquire)))
|
||||
|
@ -2800,9 +2800,9 @@ START_API_FUNC
|
|||
}
|
||||
|
||||
/* Count the number of reusable voices. */
|
||||
auto voices_end = context->Voices->begin() +
|
||||
context->VoiceCount.load(std::memory_order_relaxed);
|
||||
auto free_voices = std::accumulate(context->Voices->begin(), voices_end, ALsizei{0},
|
||||
auto voices_end = context->mVoices->begin() +
|
||||
context->mVoiceCount.load(std::memory_order_relaxed);
|
||||
auto free_voices = std::accumulate(context->mVoices->begin(), voices_end, ALsizei{0},
|
||||
[](const ALsizei count, const ALvoice &voice) noexcept -> ALsizei
|
||||
{
|
||||
if(voice.mPlayState.load(std::memory_order_acquire) == ALvoice::Stopped &&
|
||||
|
@ -2815,23 +2815,23 @@ START_API_FUNC
|
|||
{
|
||||
/* Increment the number of voices to handle the request. */
|
||||
const ALuint need_voices{static_cast<ALuint>(n) - free_voices};
|
||||
const size_t rem_voices{context->Voices->size() -
|
||||
context->VoiceCount.load(std::memory_order_relaxed)};
|
||||
const size_t rem_voices{context->mVoices->size() -
|
||||
context->mVoiceCount.load(std::memory_order_relaxed)};
|
||||
|
||||
if(UNLIKELY(need_voices > rem_voices))
|
||||
{
|
||||
/* Allocate more voices to get enough. */
|
||||
const size_t alloc_count{need_voices - rem_voices};
|
||||
if(UNLIKELY(context->Voices->size() > std::numeric_limits<ALsizei>::max()-alloc_count))
|
||||
if(UNLIKELY(context->mVoices->size() > std::numeric_limits<ALsizei>::max()-alloc_count))
|
||||
SETERR_RETURN(context.get(), AL_OUT_OF_MEMORY,,
|
||||
"Overflow increasing voice count to %zu + %zu", context->Voices->size(),
|
||||
"Overflow increasing voice count to %zu + %zu", context->mVoices->size(),
|
||||
alloc_count);
|
||||
|
||||
const size_t newcount{context->Voices->size() + alloc_count};
|
||||
const size_t newcount{context->mVoices->size() + alloc_count};
|
||||
AllocateVoices(context.get(), newcount);
|
||||
}
|
||||
|
||||
context->VoiceCount.fetch_add(need_voices, std::memory_order_relaxed);
|
||||
context->mVoiceCount.fetch_add(need_voices, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
auto start_source = [&context,device](ALsource *source) -> void
|
||||
|
@ -2886,9 +2886,9 @@ START_API_FUNC
|
|||
}
|
||||
|
||||
/* Look for an unused voice to play this source with. */
|
||||
auto voices_end = context->Voices->begin() +
|
||||
context->VoiceCount.load(std::memory_order_relaxed);
|
||||
voice = std::find_if(context->Voices->begin(), voices_end,
|
||||
auto voices_end = context->mVoices->begin() +
|
||||
context->mVoiceCount.load(std::memory_order_relaxed);
|
||||
voice = std::find_if(context->mVoices->begin(), voices_end,
|
||||
[](const ALvoice &voice) noexcept -> bool
|
||||
{
|
||||
return voice.mPlayState.load(std::memory_order_acquire) == ALvoice::Stopped &&
|
||||
|
@ -2896,7 +2896,7 @@ START_API_FUNC
|
|||
}
|
||||
);
|
||||
assert(voice != voices_end);
|
||||
auto vidx = static_cast<ALint>(std::distance(context->Voices->begin(), voice));
|
||||
auto vidx = static_cast<ALint>(std::distance(context->mVoices->begin(), voice));
|
||||
voice->mPlayState.store(ALvoice::Stopped, std::memory_order_release);
|
||||
|
||||
source->PropsClean.test_and_set(std::memory_order_acquire);
|
||||
|
@ -3036,7 +3036,7 @@ START_API_FUNC
|
|||
srchandles = extra_sources.data();
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
for(ALsizei i{0};i < n;i++)
|
||||
{
|
||||
srchandles[i] = LookupSource(context.get(), sources[i]);
|
||||
|
@ -3044,7 +3044,7 @@ START_API_FUNC
|
|||
SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid source ID %u", sources[i]);
|
||||
}
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
BackendLockGuard __{*device->Backend};
|
||||
auto pause_source = [&context](ALsource *source) -> void
|
||||
{
|
||||
|
@ -3091,7 +3091,7 @@ START_API_FUNC
|
|||
srchandles = extra_sources.data();
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
for(ALsizei i{0};i < n;i++)
|
||||
{
|
||||
srchandles[i] = LookupSource(context.get(), sources[i]);
|
||||
|
@ -3099,7 +3099,7 @@ START_API_FUNC
|
|||
SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid source ID %u", sources[i]);
|
||||
}
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
BackendLockGuard __{*device->Backend};
|
||||
auto stop_source = [&context](ALsource *source) -> void
|
||||
{
|
||||
|
@ -3153,7 +3153,7 @@ START_API_FUNC
|
|||
srchandles = extra_sources.data();
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
for(ALsizei i{0};i < n;i++)
|
||||
{
|
||||
srchandles[i] = LookupSource(context.get(), sources[i]);
|
||||
|
@ -3161,7 +3161,7 @@ START_API_FUNC
|
|||
SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid source ID %u", sources[i]);
|
||||
}
|
||||
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
BackendLockGuard __{*device->Backend};
|
||||
auto rewind_source = [&context](ALsource *source) -> void
|
||||
{
|
||||
|
@ -3200,7 +3200,7 @@ START_API_FUNC
|
|||
SETERR_RETURN(context.get(), AL_INVALID_VALUE,, "Queueing %d buffers", nb);
|
||||
if(nb == 0) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
ALsource *source{LookupSource(context.get(),src)};
|
||||
if(UNLIKELY(!source))
|
||||
SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid source ID %u", src);
|
||||
|
@ -3210,7 +3210,7 @@ START_API_FUNC
|
|||
SETERR_RETURN(context.get(), AL_INVALID_OPERATION,, "Queueing onto static source %u", src);
|
||||
|
||||
/* Check for a valid Buffer, for its frequency and format */
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
ALbuffer *BufferFmt{nullptr};
|
||||
ALbufferlistitem *BufferList{source->queue};
|
||||
while(BufferList)
|
||||
|
@ -3319,7 +3319,7 @@ START_API_FUNC
|
|||
SETERR_RETURN(context.get(), AL_INVALID_VALUE,, "Queueing %d buffer layers", nb);
|
||||
if(nb == 0) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
ALsource *source{LookupSource(context.get(),src)};
|
||||
if(UNLIKELY(!source))
|
||||
SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid source ID %u", src);
|
||||
|
@ -3329,7 +3329,7 @@ START_API_FUNC
|
|||
SETERR_RETURN(context.get(), AL_INVALID_OPERATION,, "Queueing onto static source %u", src);
|
||||
|
||||
/* Check for a valid Buffer, for its frequency and format */
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
ALbuffer *BufferFmt{nullptr};
|
||||
ALbufferlistitem *BufferList{source->queue};
|
||||
while(BufferList)
|
||||
|
@ -3429,7 +3429,7 @@ START_API_FUNC
|
|||
SETERR_RETURN(context.get(), AL_INVALID_VALUE,, "Unqueueing %d buffers", nb);
|
||||
if(nb == 0) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->SourceLock};
|
||||
std::lock_guard<std::mutex> _{context->mSourceLock};
|
||||
ALsource *source{LookupSource(context.get(),src)};
|
||||
if(UNLIKELY(!source))
|
||||
SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid source ID %u", src);
|
||||
|
@ -3611,9 +3611,9 @@ ALsource::~ALsource()
|
|||
|
||||
void UpdateAllSourceProps(ALCcontext *context)
|
||||
{
|
||||
auto voices_end = context->Voices->begin() +
|
||||
context->VoiceCount.load(std::memory_order_relaxed);
|
||||
std::for_each(context->Voices->begin(), voices_end,
|
||||
auto voices_end = context->mVoices->begin() +
|
||||
context->mVoiceCount.load(std::memory_order_relaxed);
|
||||
std::for_each(context->mVoices->begin(), voices_end,
|
||||
[context](ALvoice &voice) -> void
|
||||
{
|
||||
ALuint sid{voice.mSourceID.load(std::memory_order_acquire)};
|
||||
|
|
130
al/state.cpp
130
al/state.cpp
|
@ -80,10 +80,10 @@ START_API_FUNC
|
|||
END_API_FUNC
|
||||
|
||||
#define DO_UPDATEPROPS() do { \
|
||||
if(!context->DeferUpdates.load(std::memory_order_acquire)) \
|
||||
if(!context->mDeferUpdates.load(std::memory_order_acquire)) \
|
||||
UpdateContextProps(context.get()); \
|
||||
else \
|
||||
context->PropsClean.clear(std::memory_order_release); \
|
||||
context->mPropsClean.clear(std::memory_order_release); \
|
||||
} while(0)
|
||||
|
||||
|
||||
|
@ -93,11 +93,11 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
switch(capability)
|
||||
{
|
||||
case AL_SOURCE_DISTANCE_MODEL:
|
||||
context->SourceDistanceModel = AL_TRUE;
|
||||
context->mSourceDistanceModel = AL_TRUE;
|
||||
DO_UPDATEPROPS();
|
||||
break;
|
||||
|
||||
|
@ -113,11 +113,11 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
switch(capability)
|
||||
{
|
||||
case AL_SOURCE_DISTANCE_MODEL:
|
||||
context->SourceDistanceModel = AL_FALSE;
|
||||
context->mSourceDistanceModel = AL_FALSE;
|
||||
DO_UPDATEPROPS();
|
||||
break;
|
||||
|
||||
|
@ -133,12 +133,12 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return AL_FALSE;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
ALboolean value{AL_FALSE};
|
||||
switch(capability)
|
||||
{
|
||||
case AL_SOURCE_DISTANCE_MODEL:
|
||||
value = context->SourceDistanceModel;
|
||||
value = context->mSourceDistanceModel;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -155,17 +155,17 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return AL_FALSE;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
ALboolean value{AL_FALSE};
|
||||
switch(pname)
|
||||
{
|
||||
case AL_DOPPLER_FACTOR:
|
||||
if(context->DopplerFactor != 0.0f)
|
||||
if(context->mDopplerFactor != 0.0f)
|
||||
value = AL_TRUE;
|
||||
break;
|
||||
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
if(context->DopplerVelocity != 0.0f)
|
||||
if(context->mDopplerVelocity != 0.0f)
|
||||
value = AL_TRUE;
|
||||
break;
|
||||
|
||||
|
@ -175,17 +175,17 @@ START_API_FUNC
|
|||
break;
|
||||
|
||||
case AL_SPEED_OF_SOUND:
|
||||
if(context->SpeedOfSound != 0.0f)
|
||||
if(context->mSpeedOfSound != 0.0f)
|
||||
value = AL_TRUE;
|
||||
break;
|
||||
|
||||
case AL_DEFERRED_UPDATES_SOFT:
|
||||
if(context->DeferUpdates.load(std::memory_order_acquire))
|
||||
if(context->mDeferUpdates.load(std::memory_order_acquire))
|
||||
value = AL_TRUE;
|
||||
break;
|
||||
|
||||
case AL_GAIN_LIMIT_SOFT:
|
||||
if(GAIN_MIX_MAX/context->GainBoost != 0.0f)
|
||||
if(GAIN_MIX_MAX/context->mGainBoost != 0.0f)
|
||||
value = AL_TRUE;
|
||||
break;
|
||||
|
||||
|
@ -212,16 +212,16 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return 0.0;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
ALdouble value{0.0};
|
||||
switch(pname)
|
||||
{
|
||||
case AL_DOPPLER_FACTOR:
|
||||
value = static_cast<ALdouble>(context->DopplerFactor);
|
||||
value = static_cast<ALdouble>(context->mDopplerFactor);
|
||||
break;
|
||||
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
value = static_cast<ALdouble>(context->DopplerVelocity);
|
||||
value = static_cast<ALdouble>(context->mDopplerVelocity);
|
||||
break;
|
||||
|
||||
case AL_DISTANCE_MODEL:
|
||||
|
@ -229,16 +229,16 @@ START_API_FUNC
|
|||
break;
|
||||
|
||||
case AL_SPEED_OF_SOUND:
|
||||
value = static_cast<ALdouble>(context->SpeedOfSound);
|
||||
value = static_cast<ALdouble>(context->mSpeedOfSound);
|
||||
break;
|
||||
|
||||
case AL_DEFERRED_UPDATES_SOFT:
|
||||
if(context->DeferUpdates.load(std::memory_order_acquire))
|
||||
if(context->mDeferUpdates.load(std::memory_order_acquire))
|
||||
value = static_cast<ALdouble>(AL_TRUE);
|
||||
break;
|
||||
|
||||
case AL_GAIN_LIMIT_SOFT:
|
||||
value = static_cast<ALdouble>GAIN_MIX_MAX/context->GainBoost;
|
||||
value = static_cast<ALdouble>GAIN_MIX_MAX/context->mGainBoost;
|
||||
break;
|
||||
|
||||
case AL_NUM_RESAMPLERS_SOFT:
|
||||
|
@ -263,16 +263,16 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return 0.0f;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
ALfloat value{0.0f};
|
||||
switch(pname)
|
||||
{
|
||||
case AL_DOPPLER_FACTOR:
|
||||
value = context->DopplerFactor;
|
||||
value = context->mDopplerFactor;
|
||||
break;
|
||||
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
value = context->DopplerVelocity;
|
||||
value = context->mDopplerVelocity;
|
||||
break;
|
||||
|
||||
case AL_DISTANCE_MODEL:
|
||||
|
@ -280,16 +280,16 @@ START_API_FUNC
|
|||
break;
|
||||
|
||||
case AL_SPEED_OF_SOUND:
|
||||
value = context->SpeedOfSound;
|
||||
value = context->mSpeedOfSound;
|
||||
break;
|
||||
|
||||
case AL_DEFERRED_UPDATES_SOFT:
|
||||
if(context->DeferUpdates.load(std::memory_order_acquire))
|
||||
if(context->mDeferUpdates.load(std::memory_order_acquire))
|
||||
value = static_cast<ALfloat>(AL_TRUE);
|
||||
break;
|
||||
|
||||
case AL_GAIN_LIMIT_SOFT:
|
||||
value = GAIN_MIX_MAX/context->GainBoost;
|
||||
value = GAIN_MIX_MAX/context->mGainBoost;
|
||||
break;
|
||||
|
||||
case AL_NUM_RESAMPLERS_SOFT:
|
||||
|
@ -314,16 +314,16 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return 0;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
ALint value{0};
|
||||
switch(pname)
|
||||
{
|
||||
case AL_DOPPLER_FACTOR:
|
||||
value = static_cast<ALint>(context->DopplerFactor);
|
||||
value = static_cast<ALint>(context->mDopplerFactor);
|
||||
break;
|
||||
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
value = static_cast<ALint>(context->DopplerVelocity);
|
||||
value = static_cast<ALint>(context->mDopplerVelocity);
|
||||
break;
|
||||
|
||||
case AL_DISTANCE_MODEL:
|
||||
|
@ -331,16 +331,16 @@ START_API_FUNC
|
|||
break;
|
||||
|
||||
case AL_SPEED_OF_SOUND:
|
||||
value = static_cast<ALint>(context->SpeedOfSound);
|
||||
value = static_cast<ALint>(context->mSpeedOfSound);
|
||||
break;
|
||||
|
||||
case AL_DEFERRED_UPDATES_SOFT:
|
||||
if(context->DeferUpdates.load(std::memory_order_acquire))
|
||||
if(context->mDeferUpdates.load(std::memory_order_acquire))
|
||||
value = static_cast<ALint>(AL_TRUE);
|
||||
break;
|
||||
|
||||
case AL_GAIN_LIMIT_SOFT:
|
||||
value = static_cast<ALint>(GAIN_MIX_MAX/context->GainBoost);
|
||||
value = static_cast<ALint>(GAIN_MIX_MAX/context->mGainBoost);
|
||||
break;
|
||||
|
||||
case AL_NUM_RESAMPLERS_SOFT:
|
||||
|
@ -365,16 +365,16 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return 0;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
ALint64SOFT value{0};
|
||||
switch(pname)
|
||||
{
|
||||
case AL_DOPPLER_FACTOR:
|
||||
value = (ALint64SOFT)context->DopplerFactor;
|
||||
value = (ALint64SOFT)context->mDopplerFactor;
|
||||
break;
|
||||
|
||||
case AL_DOPPLER_VELOCITY:
|
||||
value = (ALint64SOFT)context->DopplerVelocity;
|
||||
value = (ALint64SOFT)context->mDopplerVelocity;
|
||||
break;
|
||||
|
||||
case AL_DISTANCE_MODEL:
|
||||
|
@ -382,16 +382,16 @@ START_API_FUNC
|
|||
break;
|
||||
|
||||
case AL_SPEED_OF_SOUND:
|
||||
value = (ALint64SOFT)context->SpeedOfSound;
|
||||
value = (ALint64SOFT)context->mSpeedOfSound;
|
||||
break;
|
||||
|
||||
case AL_DEFERRED_UPDATES_SOFT:
|
||||
if(context->DeferUpdates.load(std::memory_order_acquire))
|
||||
if(context->mDeferUpdates.load(std::memory_order_acquire))
|
||||
value = (ALint64SOFT)AL_TRUE;
|
||||
break;
|
||||
|
||||
case AL_GAIN_LIMIT_SOFT:
|
||||
value = (ALint64SOFT)(GAIN_MIX_MAX/context->GainBoost);
|
||||
value = (ALint64SOFT)(GAIN_MIX_MAX/context->mGainBoost);
|
||||
break;
|
||||
|
||||
case AL_NUM_RESAMPLERS_SOFT:
|
||||
|
@ -416,16 +416,16 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return nullptr;
|
||||
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
void *value{nullptr};
|
||||
switch(pname)
|
||||
{
|
||||
case AL_EVENT_CALLBACK_FUNCTION_SOFT:
|
||||
value = reinterpret_cast<void*>(context->EventCb);
|
||||
value = reinterpret_cast<void*>(context->mEventCb);
|
||||
break;
|
||||
|
||||
case AL_EVENT_CALLBACK_USER_PARAM_SOFT:
|
||||
value = context->EventParam;
|
||||
value = context->mEventParam;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -650,7 +650,7 @@ START_API_FUNC
|
|||
break;
|
||||
|
||||
case AL_EXTENSIONS:
|
||||
value = context->ExtensionList;
|
||||
value = context->mExtensionList;
|
||||
break;
|
||||
|
||||
case AL_NO_ERROR:
|
||||
|
@ -694,8 +694,8 @@ START_API_FUNC
|
|||
alSetError(context.get(), AL_INVALID_VALUE, "Doppler factor %f out of range", value);
|
||||
else
|
||||
{
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
context->DopplerFactor = value;
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
context->mDopplerFactor = value;
|
||||
DO_UPDATEPROPS();
|
||||
}
|
||||
}
|
||||
|
@ -707,24 +707,24 @@ START_API_FUNC
|
|||
ContextRef context{GetContextRef()};
|
||||
if(UNLIKELY(!context)) return;
|
||||
|
||||
if((context->EnabledEvts.load(std::memory_order_relaxed)&EventType_Deprecated))
|
||||
if((context->mEnabledEvts.load(std::memory_order_relaxed)&EventType_Deprecated))
|
||||
{
|
||||
static constexpr ALCchar msg[] =
|
||||
"alDopplerVelocity is deprecated in AL1.1, use alSpeedOfSound";
|
||||
const ALsizei msglen = static_cast<ALsizei>(strlen(msg));
|
||||
std::lock_guard<std::mutex> _{context->EventCbLock};
|
||||
ALbitfieldSOFT enabledevts{context->EnabledEvts.load(std::memory_order_relaxed)};
|
||||
if((enabledevts&EventType_Deprecated) && context->EventCb)
|
||||
(*context->EventCb)(AL_EVENT_TYPE_DEPRECATED_SOFT, 0, 0, msglen, msg,
|
||||
context->EventParam);
|
||||
std::lock_guard<std::mutex> _{context->mEventCbLock};
|
||||
ALbitfieldSOFT enabledevts{context->mEnabledEvts.load(std::memory_order_relaxed)};
|
||||
if((enabledevts&EventType_Deprecated) && context->mEventCb)
|
||||
(*context->mEventCb)(AL_EVENT_TYPE_DEPRECATED_SOFT, 0, 0, msglen, msg,
|
||||
context->mEventParam);
|
||||
}
|
||||
|
||||
if(!(value >= 0.0f && std::isfinite(value)))
|
||||
alSetError(context.get(), AL_INVALID_VALUE, "Doppler velocity %f out of range", value);
|
||||
else
|
||||
{
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
context->DopplerVelocity = value;
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
context->mDopplerVelocity = value;
|
||||
DO_UPDATEPROPS();
|
||||
}
|
||||
}
|
||||
|
@ -740,8 +740,8 @@ START_API_FUNC
|
|||
alSetError(context.get(), AL_INVALID_VALUE, "Speed of sound %f out of range", value);
|
||||
else
|
||||
{
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
context->SpeedOfSound = value;
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
context->mSpeedOfSound = value;
|
||||
DO_UPDATEPROPS();
|
||||
}
|
||||
}
|
||||
|
@ -760,9 +760,9 @@ START_API_FUNC
|
|||
alSetError(context.get(), AL_INVALID_VALUE, "Distance model 0x%04x out of range", value);
|
||||
else
|
||||
{
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
context->mDistanceModel = static_cast<DistanceModel>(value);
|
||||
if(!context->SourceDistanceModel)
|
||||
if(!context->mSourceDistanceModel)
|
||||
DO_UPDATEPROPS();
|
||||
}
|
||||
}
|
||||
|
@ -825,7 +825,7 @@ END_API_FUNC
|
|||
void UpdateContextProps(ALCcontext *context)
|
||||
{
|
||||
/* Get an unused proprty container, or allocate a new one as needed. */
|
||||
ALcontextProps *props{context->FreeContextProps.load(std::memory_order_acquire)};
|
||||
ALcontextProps *props{context->mFreeContextProps.load(std::memory_order_acquire)};
|
||||
if(!props)
|
||||
props = static_cast<ALcontextProps*>(al_calloc(16, sizeof(*props)));
|
||||
else
|
||||
|
@ -833,27 +833,27 @@ void UpdateContextProps(ALCcontext *context)
|
|||
ALcontextProps *next;
|
||||
do {
|
||||
next = props->next.load(std::memory_order_relaxed);
|
||||
} while(context->FreeContextProps.compare_exchange_weak(props, next,
|
||||
} while(context->mFreeContextProps.compare_exchange_weak(props, next,
|
||||
std::memory_order_seq_cst, std::memory_order_acquire) == 0);
|
||||
}
|
||||
|
||||
/* Copy in current property values. */
|
||||
props->MetersPerUnit = context->MetersPerUnit;
|
||||
props->MetersPerUnit = context->mMetersPerUnit;
|
||||
|
||||
props->DopplerFactor = context->DopplerFactor;
|
||||
props->DopplerVelocity = context->DopplerVelocity;
|
||||
props->SpeedOfSound = context->SpeedOfSound;
|
||||
props->DopplerFactor = context->mDopplerFactor;
|
||||
props->DopplerVelocity = context->mDopplerVelocity;
|
||||
props->SpeedOfSound = context->mSpeedOfSound;
|
||||
|
||||
props->SourceDistanceModel = context->SourceDistanceModel;
|
||||
props->SourceDistanceModel = context->mSourceDistanceModel;
|
||||
props->mDistanceModel = context->mDistanceModel;
|
||||
|
||||
/* Set the new container for updating internal parameters. */
|
||||
props = context->Update.exchange(props, std::memory_order_acq_rel);
|
||||
props = context->mUpdate.exchange(props, std::memory_order_acq_rel);
|
||||
if(props)
|
||||
{
|
||||
/* If there was an unused update container, put it back in the
|
||||
* freelist.
|
||||
*/
|
||||
AtomicReplaceHead(context->FreeContextProps, props);
|
||||
AtomicReplaceHead(context->mFreeContextProps, props);
|
||||
}
|
||||
}
|
||||
|
|
158
alc/alc.cpp
158
alc/alc.cpp
|
@ -833,7 +833,7 @@ std::atomic<ALCenum> LastNullDeviceError{ALC_NO_ERROR};
|
|||
/* Thread-local current context */
|
||||
void ReleaseThreadCtx(ALCcontext *context)
|
||||
{
|
||||
auto ref = DecrementRef(&context->ref);
|
||||
auto ref = DecrementRef(&context->mRef);
|
||||
TRACEREF("ALCcontext %p decreasing refcount to %u\n", context, ref);
|
||||
ERR("Context %p current for thread being destroyed, possible leak!\n", context);
|
||||
}
|
||||
|
@ -1599,7 +1599,7 @@ void SetDefaultChannelOrder(ALCdevice *device)
|
|||
*/
|
||||
void ALCcontext_DeferUpdates(ALCcontext *context)
|
||||
{
|
||||
context->DeferUpdates.store(true);
|
||||
context->mDeferUpdates.store(true);
|
||||
}
|
||||
|
||||
/* ALCcontext_ProcessUpdates
|
||||
|
@ -1608,19 +1608,19 @@ void ALCcontext_DeferUpdates(ALCcontext *context)
|
|||
*/
|
||||
void ALCcontext_ProcessUpdates(ALCcontext *context)
|
||||
{
|
||||
std::lock_guard<std::mutex> _{context->PropLock};
|
||||
if(context->DeferUpdates.exchange(false))
|
||||
std::lock_guard<std::mutex> _{context->mPropLock};
|
||||
if(context->mDeferUpdates.exchange(false))
|
||||
{
|
||||
/* Tell the mixer to stop applying updates, then wait for any active
|
||||
* updating to finish, before providing updates.
|
||||
*/
|
||||
context->HoldUpdates.store(true, std::memory_order_release);
|
||||
while((context->UpdateCount.load(std::memory_order_acquire)&1) != 0)
|
||||
context->mHoldUpdates.store(true, std::memory_order_release);
|
||||
while((context->mUpdateCount.load(std::memory_order_acquire)&1) != 0)
|
||||
std::this_thread::yield();
|
||||
|
||||
if(!context->PropsClean.test_and_set(std::memory_order_acq_rel))
|
||||
if(!context->mPropsClean.test_and_set(std::memory_order_acq_rel))
|
||||
UpdateContextProps(context);
|
||||
if(!context->Listener.PropsClean.test_and_set(std::memory_order_acq_rel))
|
||||
if(!context->mListener.PropsClean.test_and_set(std::memory_order_acq_rel))
|
||||
UpdateListenerProps(context);
|
||||
UpdateAllEffectSlotProps(context);
|
||||
UpdateAllSourceProps(context);
|
||||
|
@ -1628,7 +1628,7 @@ void ALCcontext_ProcessUpdates(ALCcontext *context)
|
|||
/* Now with all updates declared, let the mixer continue applying them
|
||||
* so they all happen at once.
|
||||
*/
|
||||
context->HoldUpdates.store(false, std::memory_order_release);
|
||||
context->mHoldUpdates.store(false, std::memory_order_release);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2167,9 +2167,9 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
|
|||
FPUCtl mixer_mode{};
|
||||
for(ALCcontext *context : *device->mContexts.load())
|
||||
{
|
||||
if(context->DefaultSlot)
|
||||
if(context->mDefaultSlot)
|
||||
{
|
||||
ALeffectslot *slot = context->DefaultSlot.get();
|
||||
ALeffectslot *slot = context->mDefaultSlot.get();
|
||||
aluInitEffectPanning(slot, device);
|
||||
|
||||
EffectState *state{slot->Effect.State};
|
||||
|
@ -2180,9 +2180,9 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
|
|||
UpdateEffectSlotProps(slot, context);
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> proplock{context->PropLock};
|
||||
std::unique_lock<std::mutex> slotlock{context->EffectSlotLock};
|
||||
for(auto &sublist : context->EffectSlotList)
|
||||
std::unique_lock<std::mutex> proplock{context->mPropLock};
|
||||
std::unique_lock<std::mutex> slotlock{context->mEffectSlotLock};
|
||||
for(auto &sublist : context->mEffectSlotList)
|
||||
{
|
||||
uint64_t usemask = ~sublist.FreeMask;
|
||||
while(usemask)
|
||||
|
@ -2204,8 +2204,8 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
|
|||
}
|
||||
slotlock.unlock();
|
||||
|
||||
std::unique_lock<std::mutex> srclock{context->SourceLock};
|
||||
for(auto &sublist : context->SourceList)
|
||||
std::unique_lock<std::mutex> srclock{context->mSourceLock};
|
||||
for(auto &sublist : context->mSourceList)
|
||||
{
|
||||
uint64_t usemask = ~sublist.FreeMask;
|
||||
while(usemask)
|
||||
|
@ -2245,7 +2245,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
|
|||
* auxiliary sends is changing. Active sources will have updates
|
||||
* respecified in UpdateAllSourceProps.
|
||||
*/
|
||||
ALvoiceProps *vprops{context->FreeVoiceProps.exchange(nullptr, std::memory_order_acq_rel)};
|
||||
ALvoiceProps *vprops{context->mFreeVoiceProps.exchange(nullptr, std::memory_order_acq_rel)};
|
||||
while(vprops)
|
||||
{
|
||||
ALvoiceProps *next = vprops->next.load(std::memory_order_relaxed);
|
||||
|
@ -2253,8 +2253,8 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
|
|||
vprops = next;
|
||||
}
|
||||
|
||||
auto voices = context->Voices.get();
|
||||
auto voices_end = voices->begin() + context->VoiceCount.load(std::memory_order_relaxed);
|
||||
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};
|
||||
|
@ -2300,9 +2300,9 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
|
|||
);
|
||||
srclock.unlock();
|
||||
|
||||
context->PropsClean.test_and_set(std::memory_order_release);
|
||||
context->mPropsClean.test_and_set(std::memory_order_release);
|
||||
UpdateContextProps(context);
|
||||
context->Listener.PropsClean.test_and_set(std::memory_order_release);
|
||||
context->mListener.PropsClean.test_and_set(std::memory_order_release);
|
||||
UpdateListenerProps(context);
|
||||
UpdateAllSourceProps(context);
|
||||
}
|
||||
|
@ -2383,9 +2383,9 @@ static DeviceRef VerifyDevice(ALCdevice *device)
|
|||
}
|
||||
|
||||
|
||||
ALCcontext::ALCcontext(ALCdevice *device) : Device{device}
|
||||
ALCcontext::ALCcontext(ALCdevice *device) : mDevice{device}
|
||||
{
|
||||
PropsClean.test_and_set(std::memory_order_relaxed);
|
||||
mPropsClean.test_and_set(std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
/* InitContext
|
||||
|
@ -2394,43 +2394,43 @@ ALCcontext::ALCcontext(ALCdevice *device) : Device{device}
|
|||
*/
|
||||
static ALvoid InitContext(ALCcontext *Context)
|
||||
{
|
||||
ALlistener &listener = Context->Listener;
|
||||
ALlistener &listener = Context->mListener;
|
||||
ALeffectslotArray *auxslots;
|
||||
|
||||
//Validate Context
|
||||
if(!Context->DefaultSlot)
|
||||
if(!Context->mDefaultSlot)
|
||||
auxslots = ALeffectslot::CreatePtrArray(0);
|
||||
else
|
||||
{
|
||||
auxslots = ALeffectslot::CreatePtrArray(1);
|
||||
(*auxslots)[0] = Context->DefaultSlot.get();
|
||||
(*auxslots)[0] = Context->mDefaultSlot.get();
|
||||
}
|
||||
Context->ActiveAuxSlots.store(auxslots, std::memory_order_relaxed);
|
||||
Context->mActiveAuxSlots.store(auxslots, std::memory_order_relaxed);
|
||||
|
||||
//Set globals
|
||||
Context->mDistanceModel = DistanceModel::Default;
|
||||
Context->SourceDistanceModel = AL_FALSE;
|
||||
Context->DopplerFactor = 1.0f;
|
||||
Context->DopplerVelocity = 1.0f;
|
||||
Context->SpeedOfSound = SPEEDOFSOUNDMETRESPERSEC;
|
||||
Context->MetersPerUnit = AL_DEFAULT_METERS_PER_UNIT;
|
||||
Context->mSourceDistanceModel = AL_FALSE;
|
||||
Context->mDopplerFactor = 1.0f;
|
||||
Context->mDopplerVelocity = 1.0f;
|
||||
Context->mSpeedOfSound = SPEEDOFSOUNDMETRESPERSEC;
|
||||
Context->mMetersPerUnit = AL_DEFAULT_METERS_PER_UNIT;
|
||||
|
||||
Context->ExtensionList = alExtList;
|
||||
Context->mExtensionList = alExtList;
|
||||
|
||||
|
||||
listener.Params.Matrix = alu::Matrix::Identity();
|
||||
listener.Params.Velocity = alu::Vector{};
|
||||
listener.Params.Gain = listener.Gain;
|
||||
listener.Params.MetersPerUnit = Context->MetersPerUnit;
|
||||
listener.Params.DopplerFactor = Context->DopplerFactor;
|
||||
listener.Params.SpeedOfSound = Context->SpeedOfSound * Context->DopplerVelocity;
|
||||
listener.Params.MetersPerUnit = Context->mMetersPerUnit;
|
||||
listener.Params.DopplerFactor = Context->mDopplerFactor;
|
||||
listener.Params.SpeedOfSound = Context->mSpeedOfSound * Context->mDopplerVelocity;
|
||||
listener.Params.ReverbSpeedOfSound = listener.Params.SpeedOfSound *
|
||||
listener.Params.MetersPerUnit;
|
||||
listener.Params.SourceDistanceModel = Context->SourceDistanceModel;
|
||||
listener.Params.SourceDistanceModel = Context->mSourceDistanceModel;
|
||||
listener.Params.mDistanceModel = Context->mDistanceModel;
|
||||
|
||||
|
||||
Context->AsyncEvents = CreateRingBuffer(511, sizeof(AsyncEvent), false);
|
||||
Context->mAsyncEvents = CreateRingBuffer(511, sizeof(AsyncEvent), false);
|
||||
StartEventThrd(Context);
|
||||
}
|
||||
|
||||
|
@ -2444,14 +2444,14 @@ ALCcontext::~ALCcontext()
|
|||
{
|
||||
TRACE("Freeing context %p\n", this);
|
||||
|
||||
ALcontextProps *cprops{Update.exchange(nullptr, std::memory_order_relaxed)};
|
||||
ALcontextProps *cprops{mUpdate.exchange(nullptr, std::memory_order_relaxed)};
|
||||
if(cprops)
|
||||
{
|
||||
TRACE("Freed unapplied context update %p\n", cprops);
|
||||
al_free(cprops);
|
||||
}
|
||||
size_t count{0};
|
||||
cprops = FreeContextProps.exchange(nullptr, std::memory_order_acquire);
|
||||
cprops = mFreeContextProps.exchange(nullptr, std::memory_order_acquire);
|
||||
while(cprops)
|
||||
{
|
||||
ALcontextProps *next{cprops->next.load(std::memory_order_relaxed)};
|
||||
|
@ -2461,17 +2461,17 @@ ALCcontext::~ALCcontext()
|
|||
}
|
||||
TRACE("Freed %zu context property object%s\n", count, (count==1)?"":"s");
|
||||
|
||||
count = std::accumulate(SourceList.cbegin(), SourceList.cend(), size_t{0u},
|
||||
count = std::accumulate(mSourceList.cbegin(), mSourceList.cend(), size_t{0u},
|
||||
[](size_t cur, const SourceSubList &sublist) noexcept -> size_t
|
||||
{ return cur + POPCNT64(~sublist.FreeMask); }
|
||||
);
|
||||
if(count > 0)
|
||||
WARN("%zu Source%s not deleted\n", count, (count==1)?"":"s");
|
||||
SourceList.clear();
|
||||
NumSources = 0;
|
||||
mSourceList.clear();
|
||||
mNumSources = 0;
|
||||
|
||||
count = 0;
|
||||
ALeffectslotProps *eprops{FreeEffectslotProps.exchange(nullptr, std::memory_order_acquire)};
|
||||
ALeffectslotProps *eprops{mFreeEffectslotProps.exchange(nullptr, std::memory_order_acquire)};
|
||||
while(eprops)
|
||||
{
|
||||
ALeffectslotProps *next{eprops->next.load(std::memory_order_relaxed)};
|
||||
|
@ -2482,20 +2482,20 @@ ALCcontext::~ALCcontext()
|
|||
}
|
||||
TRACE("Freed %zu AuxiliaryEffectSlot property object%s\n", count, (count==1)?"":"s");
|
||||
|
||||
delete ActiveAuxSlots.exchange(nullptr, std::memory_order_relaxed);
|
||||
DefaultSlot = nullptr;
|
||||
delete mActiveAuxSlots.exchange(nullptr, std::memory_order_relaxed);
|
||||
mDefaultSlot = nullptr;
|
||||
|
||||
count = std::accumulate(EffectSlotList.cbegin(), EffectSlotList.cend(), size_t{0u},
|
||||
count = std::accumulate(mEffectSlotList.cbegin(), mEffectSlotList.cend(), size_t{0u},
|
||||
[](size_t cur, const EffectSlotSubList &sublist) noexcept -> size_t
|
||||
{ return cur + POPCNT64(~sublist.FreeMask); }
|
||||
);
|
||||
if(count > 0)
|
||||
WARN("%zu AuxiliaryEffectSlot%s not deleted\n", count, (count==1)?"":"s");
|
||||
EffectSlotList.clear();
|
||||
NumEffectSlots = 0;
|
||||
mEffectSlotList.clear();
|
||||
mNumEffectSlots = 0;
|
||||
|
||||
count = 0;
|
||||
ALvoiceProps *vprops{FreeVoiceProps.exchange(nullptr, std::memory_order_acquire)};
|
||||
ALvoiceProps *vprops{mFreeVoiceProps.exchange(nullptr, std::memory_order_acquire)};
|
||||
while(vprops)
|
||||
{
|
||||
ALvoiceProps *next{vprops->next.load(std::memory_order_relaxed)};
|
||||
|
@ -2505,17 +2505,17 @@ ALCcontext::~ALCcontext()
|
|||
}
|
||||
TRACE("Freed %zu voice property object%s\n", count, (count==1)?"":"s");
|
||||
|
||||
Voices = nullptr;
|
||||
VoiceCount.store(0, std::memory_order_relaxed);
|
||||
mVoices = nullptr;
|
||||
mVoiceCount.store(0, std::memory_order_relaxed);
|
||||
|
||||
ALlistenerProps *lprops{Listener.Update.exchange(nullptr, std::memory_order_relaxed)};
|
||||
ALlistenerProps *lprops{mListener.Update.exchange(nullptr, std::memory_order_relaxed)};
|
||||
if(lprops)
|
||||
{
|
||||
TRACE("Freed unapplied listener update %p\n", lprops);
|
||||
al_free(lprops);
|
||||
}
|
||||
count = 0;
|
||||
lprops = FreeListenerProps.exchange(nullptr, std::memory_order_acquire);
|
||||
lprops = mFreeListenerProps.exchange(nullptr, std::memory_order_acquire);
|
||||
while(lprops)
|
||||
{
|
||||
ALlistenerProps *next{lprops->next.load(std::memory_order_relaxed)};
|
||||
|
@ -2525,10 +2525,10 @@ ALCcontext::~ALCcontext()
|
|||
}
|
||||
TRACE("Freed %zu listener property object%s\n", count, (count==1)?"":"s");
|
||||
|
||||
if(AsyncEvents)
|
||||
if(mAsyncEvents)
|
||||
{
|
||||
count = 0;
|
||||
auto evt_vec = AsyncEvents->getReadVector();
|
||||
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);
|
||||
|
@ -2541,10 +2541,10 @@ ALCcontext::~ALCcontext()
|
|||
}
|
||||
if(count > 0)
|
||||
TRACE("Destructed %zu orphaned event%s\n", count, (count==1)?"":"s");
|
||||
AsyncEvents->readAdvance(count);
|
||||
mAsyncEvents->readAdvance(count);
|
||||
}
|
||||
|
||||
ALCdevice_DecRef(Device);
|
||||
ALCdevice_DecRef(mDevice);
|
||||
}
|
||||
|
||||
/* ReleaseContext
|
||||
|
@ -2612,13 +2612,13 @@ static bool ReleaseContext(ALCcontext *context, ALCdevice *device)
|
|||
|
||||
static void ALCcontext_IncRef(ALCcontext *context)
|
||||
{
|
||||
auto ref = IncrementRef(&context->ref);
|
||||
auto ref = IncrementRef(&context->mRef);
|
||||
TRACEREF("ALCcontext %p increasing refcount to %u\n", context, ref);
|
||||
}
|
||||
|
||||
void ALCcontext_DecRef(ALCcontext *context)
|
||||
{
|
||||
auto ref = DecrementRef(&context->ref);
|
||||
auto ref = DecrementRef(&context->mRef);
|
||||
TRACEREF("ALCcontext %p decreasing refcount to %u\n", context, ref);
|
||||
if(UNLIKELY(ref == 0)) delete context;
|
||||
}
|
||||
|
@ -2661,10 +2661,10 @@ ContextRef GetContextRef(void)
|
|||
|
||||
void AllocateVoices(ALCcontext *context, size_t num_voices)
|
||||
{
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
const ALsizei num_sends{device->NumAuxSends};
|
||||
|
||||
if(context->Voices && num_voices == context->Voices->size())
|
||||
if(context->mVoices && num_voices == context->mVoices->size())
|
||||
return;
|
||||
|
||||
std::unique_ptr<al::FlexArray<ALvoice>> voices;
|
||||
|
@ -2673,11 +2673,11 @@ void AllocateVoices(ALCcontext *context, size_t num_voices)
|
|||
voices.reset(new (ptr) al::FlexArray<ALvoice>{num_voices});
|
||||
}
|
||||
|
||||
const size_t v_count{minz(context->VoiceCount.load(std::memory_order_relaxed), num_voices)};
|
||||
if(context->Voices)
|
||||
const size_t v_count{minz(context->mVoiceCount.load(std::memory_order_relaxed), num_voices)};
|
||||
if(context->mVoices)
|
||||
{
|
||||
/* Copy the old voice data to the new storage. */
|
||||
auto viter = std::move(context->Voices->begin(), context->Voices->begin()+v_count,
|
||||
auto viter = std::move(context->mVoices->begin(), context->mVoices->begin()+v_count,
|
||||
voices->begin());
|
||||
|
||||
/* Clear extraneous property set sends. */
|
||||
|
@ -2697,8 +2697,8 @@ void AllocateVoices(ALCcontext *context, size_t num_voices)
|
|||
std::for_each(voices->begin(), viter, clear_sends);
|
||||
}
|
||||
|
||||
context->Voices = std::move(voices);
|
||||
context->VoiceCount.store(static_cast<ALuint>(v_count), std::memory_order_relaxed);
|
||||
context->mVoices = std::move(voices);
|
||||
context->mVoiceCount.store(static_cast<ALuint>(v_count), std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3444,7 +3444,7 @@ START_API_FUNC
|
|||
dev->LastError.store(ALC_NO_ERROR);
|
||||
|
||||
ContextRef context{new ALCcontext{dev.get()}};
|
||||
ALCdevice_IncRef(context->Device);
|
||||
ALCdevice_IncRef(context->mDevice);
|
||||
|
||||
ALCenum err{UpdateDeviceParams(dev.get(), attrList)};
|
||||
if(err != ALC_NO_ERROR)
|
||||
|
@ -3461,12 +3461,12 @@ START_API_FUNC
|
|||
if(DefaultEffect.type != AL_EFFECT_NULL && dev->Type == Playback)
|
||||
{
|
||||
void *ptr{al_calloc(16, sizeof(ALeffectslot))};
|
||||
context->DefaultSlot = std::unique_ptr<ALeffectslot>{new (ptr) ALeffectslot{}};
|
||||
if(InitEffectSlot(context->DefaultSlot.get()) == AL_NO_ERROR)
|
||||
aluInitEffectPanning(context->DefaultSlot.get(), dev.get());
|
||||
context->mDefaultSlot = std::unique_ptr<ALeffectslot>{new (ptr) ALeffectslot{}};
|
||||
if(InitEffectSlot(context->mDefaultSlot.get()) == AL_NO_ERROR)
|
||||
aluInitEffectPanning(context->mDefaultSlot.get(), dev.get());
|
||||
else
|
||||
{
|
||||
context->DefaultSlot = nullptr;
|
||||
context->mDefaultSlot = nullptr;
|
||||
ERR("Failed to initialize the default effect slot\n");
|
||||
}
|
||||
}
|
||||
|
@ -3483,8 +3483,8 @@ START_API_FUNC
|
|||
const ALfloat db{clampf(valf, -24.0f, 24.0f)};
|
||||
if(db != valf)
|
||||
WARN("volume-adjust clamped: %f, range: +/-%f\n", valf, 24.0f);
|
||||
context->GainBoost = std::pow(10.0f, db/20.0f);
|
||||
TRACE("volume-adjust gain: %f\n", context->GainBoost);
|
||||
context->mGainBoost = std::pow(10.0f, db/20.0f);
|
||||
TRACE("volume-adjust gain: %f\n", context->mGainBoost);
|
||||
}
|
||||
}
|
||||
UpdateListenerProps(context.get());
|
||||
|
@ -3526,10 +3526,10 @@ START_API_FUNC
|
|||
ContextList.insert(iter, ContextRef{context.get()});
|
||||
}
|
||||
|
||||
if(context->DefaultSlot)
|
||||
if(context->mDefaultSlot)
|
||||
{
|
||||
if(InitializeEffect(context.get(), context->DefaultSlot.get(), &DefaultEffect) == AL_NO_ERROR)
|
||||
UpdateEffectSlotProps(context->DefaultSlot.get(), context.get());
|
||||
if(InitializeEffect(context.get(), context->mDefaultSlot.get(), &DefaultEffect) == AL_NO_ERROR)
|
||||
UpdateEffectSlotProps(context->mDefaultSlot.get(), context.get());
|
||||
else
|
||||
ERR("Failed to initialize the default effect\n");
|
||||
}
|
||||
|
@ -3560,7 +3560,7 @@ START_API_FUNC
|
|||
ContextRef ctx{std::move(*iter)};
|
||||
ContextList.erase(iter);
|
||||
|
||||
ALCdevice *Device{ctx->Device};
|
||||
ALCdevice *Device{ctx->mDevice};
|
||||
|
||||
std::lock_guard<std::mutex> _{Device->StateLock};
|
||||
if(!ReleaseContext(ctx.get(), Device) && Device->Flags.get<DeviceRunning>())
|
||||
|
@ -3671,7 +3671,7 @@ START_API_FUNC
|
|||
alcSetError(nullptr, ALC_INVALID_CONTEXT);
|
||||
return nullptr;
|
||||
}
|
||||
return ctx->Device;
|
||||
return ctx->mDevice;
|
||||
}
|
||||
END_API_FUNC
|
||||
|
||||
|
|
|
@ -73,70 +73,70 @@ struct EffectSlotSubList {
|
|||
};
|
||||
|
||||
struct ALCcontext {
|
||||
RefCount ref{1u};
|
||||
RefCount mRef{1u};
|
||||
|
||||
al::vector<SourceSubList> SourceList;
|
||||
ALuint NumSources{0};
|
||||
std::mutex SourceLock;
|
||||
al::vector<SourceSubList> mSourceList;
|
||||
ALuint mNumSources{0};
|
||||
std::mutex mSourceLock;
|
||||
|
||||
al::vector<EffectSlotSubList> EffectSlotList;
|
||||
ALuint NumEffectSlots{0u};
|
||||
std::mutex EffectSlotLock;
|
||||
al::vector<EffectSlotSubList> mEffectSlotList;
|
||||
ALuint mNumEffectSlots{0u};
|
||||
std::mutex mEffectSlotLock;
|
||||
|
||||
std::atomic<ALenum> LastError{AL_NO_ERROR};
|
||||
std::atomic<ALenum> mLastError{AL_NO_ERROR};
|
||||
|
||||
DistanceModel mDistanceModel{DistanceModel::Default};
|
||||
ALboolean SourceDistanceModel{AL_FALSE};
|
||||
ALboolean mSourceDistanceModel{AL_FALSE};
|
||||
|
||||
ALfloat DopplerFactor{1.0f};
|
||||
ALfloat DopplerVelocity{1.0f};
|
||||
ALfloat SpeedOfSound{};
|
||||
ALfloat MetersPerUnit{1.0f};
|
||||
ALfloat mDopplerFactor{1.0f};
|
||||
ALfloat mDopplerVelocity{1.0f};
|
||||
ALfloat mSpeedOfSound{};
|
||||
ALfloat mMetersPerUnit{1.0f};
|
||||
|
||||
std::atomic_flag PropsClean;
|
||||
std::atomic<bool> DeferUpdates{false};
|
||||
std::atomic_flag mPropsClean;
|
||||
std::atomic<bool> mDeferUpdates{false};
|
||||
|
||||
std::mutex PropLock;
|
||||
std::mutex mPropLock;
|
||||
|
||||
/* Counter for the pre-mixing updates, in 31.1 fixed point (lowest bit
|
||||
* indicates if updates are currently happening).
|
||||
*/
|
||||
RefCount UpdateCount{0u};
|
||||
std::atomic<bool> HoldUpdates{false};
|
||||
RefCount mUpdateCount{0u};
|
||||
std::atomic<bool> mHoldUpdates{false};
|
||||
|
||||
ALfloat GainBoost{1.0f};
|
||||
ALfloat mGainBoost{1.0f};
|
||||
|
||||
std::atomic<ALcontextProps*> Update{nullptr};
|
||||
std::atomic<ALcontextProps*> mUpdate{nullptr};
|
||||
|
||||
/* Linked lists of unused property containers, free to use for future
|
||||
* updates.
|
||||
*/
|
||||
std::atomic<ALcontextProps*> FreeContextProps{nullptr};
|
||||
std::atomic<ALlistenerProps*> FreeListenerProps{nullptr};
|
||||
std::atomic<ALvoiceProps*> FreeVoiceProps{nullptr};
|
||||
std::atomic<ALeffectslotProps*> FreeEffectslotProps{nullptr};
|
||||
std::atomic<ALcontextProps*> mFreeContextProps{nullptr};
|
||||
std::atomic<ALlistenerProps*> mFreeListenerProps{nullptr};
|
||||
std::atomic<ALvoiceProps*> mFreeVoiceProps{nullptr};
|
||||
std::atomic<ALeffectslotProps*> mFreeEffectslotProps{nullptr};
|
||||
|
||||
std::unique_ptr<al::FlexArray<ALvoice>> Voices{nullptr};
|
||||
std::atomic<ALuint> VoiceCount{0u};
|
||||
std::unique_ptr<al::FlexArray<ALvoice>> mVoices{nullptr};
|
||||
std::atomic<ALuint> mVoiceCount{0u};
|
||||
|
||||
using ALeffectslotArray = al::FlexArray<ALeffectslot*>;
|
||||
std::atomic<ALeffectslotArray*> ActiveAuxSlots{nullptr};
|
||||
std::atomic<ALeffectslotArray*> mActiveAuxSlots{nullptr};
|
||||
|
||||
std::thread EventThread;
|
||||
al::semaphore EventSem;
|
||||
std::unique_ptr<RingBuffer> AsyncEvents;
|
||||
std::atomic<ALbitfieldSOFT> EnabledEvts{0u};
|
||||
std::mutex EventCbLock;
|
||||
ALEVENTPROCSOFT EventCb{};
|
||||
void *EventParam{nullptr};
|
||||
std::thread mEventThread;
|
||||
al::semaphore mEventSem;
|
||||
std::unique_ptr<RingBuffer> mAsyncEvents;
|
||||
std::atomic<ALbitfieldSOFT> mEnabledEvts{0u};
|
||||
std::mutex mEventCbLock;
|
||||
ALEVENTPROCSOFT mEventCb{};
|
||||
void *mEventParam{nullptr};
|
||||
|
||||
/* Default effect slot */
|
||||
std::unique_ptr<ALeffectslot> DefaultSlot;
|
||||
std::unique_ptr<ALeffectslot> mDefaultSlot;
|
||||
|
||||
ALCdevice *const Device;
|
||||
const ALCchar *ExtensionList{nullptr};
|
||||
ALCdevice *const mDevice;
|
||||
const ALCchar *mExtensionList{nullptr};
|
||||
|
||||
ALlistener Listener{};
|
||||
ALlistener mListener{};
|
||||
|
||||
|
||||
ALCcontext(ALCdevice *device);
|
||||
|
|
60
alc/alu.cpp
60
alc/alu.cpp
|
@ -279,10 +279,10 @@ alu::Vector operator*(const alu::Matrix &mtx, const alu::Vector &vec) noexcept
|
|||
|
||||
bool CalcContextParams(ALCcontext *Context)
|
||||
{
|
||||
ALcontextProps *props{Context->Update.exchange(nullptr, std::memory_order_acq_rel)};
|
||||
ALcontextProps *props{Context->mUpdate.exchange(nullptr, std::memory_order_acq_rel)};
|
||||
if(!props) return false;
|
||||
|
||||
ALlistener &Listener = Context->Listener;
|
||||
ALlistener &Listener = Context->mListener;
|
||||
Listener.Params.MetersPerUnit = props->MetersPerUnit;
|
||||
|
||||
Listener.Params.DopplerFactor = props->DopplerFactor;
|
||||
|
@ -294,13 +294,13 @@ bool CalcContextParams(ALCcontext *Context)
|
|||
Listener.Params.SourceDistanceModel = props->SourceDistanceModel;
|
||||
Listener.Params.mDistanceModel = props->mDistanceModel;
|
||||
|
||||
AtomicReplaceHead(Context->FreeContextProps, props);
|
||||
AtomicReplaceHead(Context->mFreeContextProps, props);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CalcListenerParams(ALCcontext *Context)
|
||||
{
|
||||
ALlistener &Listener = Context->Listener;
|
||||
ALlistener &Listener = Context->mListener;
|
||||
|
||||
ALlistenerProps *props{Listener.Update.exchange(nullptr, std::memory_order_acq_rel)};
|
||||
if(!props) return false;
|
||||
|
@ -328,9 +328,9 @@ bool CalcListenerParams(ALCcontext *Context)
|
|||
const alu::Vector vel{props->Velocity[0], props->Velocity[1], props->Velocity[2], 0.0f};
|
||||
Listener.Params.Velocity = Listener.Params.Matrix * vel;
|
||||
|
||||
Listener.Params.Gain = props->Gain * Context->GainBoost;
|
||||
Listener.Params.Gain = props->Gain * Context->mGainBoost;
|
||||
|
||||
AtomicReplaceHead(Context->FreeListenerProps, props);
|
||||
AtomicReplaceHead(Context->mFreeListenerProps, props);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -391,14 +391,14 @@ bool CalcEffectSlotParams(ALeffectslot *slot, ALCcontext *context, bool force)
|
|||
/* Otherwise, if it would be deleted, send it off with a release
|
||||
* event.
|
||||
*/
|
||||
RingBuffer *ring{context->AsyncEvents.get()};
|
||||
RingBuffer *ring{context->mAsyncEvents.get()};
|
||||
auto evt_vec = ring->getWriteVector();
|
||||
if(LIKELY(evt_vec.first.len > 0))
|
||||
{
|
||||
AsyncEvent *evt{new (evt_vec.first.buf) AsyncEvent{EventType_ReleaseEffectState}};
|
||||
evt->u.mEffectState = oldstate;
|
||||
ring->writeAdvance(1);
|
||||
context->EventSem.post();
|
||||
context->mEventSem.post();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -411,7 +411,7 @@ bool CalcEffectSlotParams(ALeffectslot *slot, ALCcontext *context, bool force)
|
|||
}
|
||||
}
|
||||
|
||||
AtomicReplaceHead(context->FreeEffectslotProps, props);
|
||||
AtomicReplaceHead(context->mFreeEffectslotProps, props);
|
||||
}
|
||||
|
||||
EffectTarget output;
|
||||
|
@ -419,7 +419,7 @@ bool CalcEffectSlotParams(ALeffectslot *slot, ALCcontext *context, bool force)
|
|||
output = EffectTarget{&target->Wet, nullptr};
|
||||
else
|
||||
{
|
||||
ALCdevice *device{context->Device};
|
||||
ALCdevice *device{context->mDevice};
|
||||
output = EffectTarget{&device->Dry, &device->RealOut};
|
||||
}
|
||||
state->update(context, slot, &slot->Params.mEffectProps, output);
|
||||
|
@ -960,7 +960,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo
|
|||
|
||||
void CalcNonAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const ALCcontext *ALContext)
|
||||
{
|
||||
const ALCdevice *Device{ALContext->Device};
|
||||
const ALCdevice *Device{ALContext->mDevice};
|
||||
ALeffectslot *SendSlots[MAX_SENDS];
|
||||
|
||||
voice->mDirect.Buffer = Device->Dry.Buffer;
|
||||
|
@ -968,7 +968,7 @@ void CalcNonAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, cons
|
|||
{
|
||||
SendSlots[i] = props->Send[i].Slot;
|
||||
if(!SendSlots[i] && i == 0)
|
||||
SendSlots[i] = ALContext->DefaultSlot.get();
|
||||
SendSlots[i] = ALContext->mDefaultSlot.get();
|
||||
if(!SendSlots[i] || SendSlots[i]->Params.EffectType == AL_EFFECT_NULL)
|
||||
{
|
||||
SendSlots[i] = nullptr;
|
||||
|
@ -992,7 +992,7 @@ void CalcNonAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, cons
|
|||
voice->mResampler = SelectResampler(props->mResampler);
|
||||
|
||||
/* Calculate gains */
|
||||
const ALlistener &Listener = ALContext->Listener;
|
||||
const ALlistener &Listener = ALContext->mListener;
|
||||
ALfloat DryGain{clampf(props->Gain, props->MinGain, props->MaxGain)};
|
||||
DryGain *= props->Direct.Gain * Listener.Params.Gain;
|
||||
DryGain = minf(DryGain, GAIN_MIX_MAX);
|
||||
|
@ -1014,9 +1014,9 @@ void CalcNonAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, cons
|
|||
|
||||
void CalcAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const ALCcontext *ALContext)
|
||||
{
|
||||
const ALCdevice *Device{ALContext->Device};
|
||||
const ALCdevice *Device{ALContext->mDevice};
|
||||
const ALsizei NumSends{Device->NumAuxSends};
|
||||
const ALlistener &Listener = ALContext->Listener;
|
||||
const ALlistener &Listener = ALContext->mListener;
|
||||
|
||||
/* Set mixing buffers and get send parameters. */
|
||||
voice->mDirect.Buffer = Device->Dry.Buffer;
|
||||
|
@ -1029,7 +1029,7 @@ void CalcAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const A
|
|||
{
|
||||
SendSlots[i] = props->Send[i].Slot;
|
||||
if(!SendSlots[i] && i == 0)
|
||||
SendSlots[i] = ALContext->DefaultSlot.get();
|
||||
SendSlots[i] = ALContext->mDefaultSlot.get();
|
||||
if(!SendSlots[i] || SendSlots[i]->Params.EffectType == AL_EFFECT_NULL)
|
||||
{
|
||||
SendSlots[i] = nullptr;
|
||||
|
@ -1342,7 +1342,7 @@ void CalcSourceParams(ALvoice *voice, ALCcontext *context, bool force)
|
|||
{
|
||||
voice->mProps = *props;
|
||||
|
||||
AtomicReplaceHead(context->FreeVoiceProps, props);
|
||||
AtomicReplaceHead(context->mFreeVoiceProps, props);
|
||||
}
|
||||
|
||||
if((voice->mProps.mSpatializeMode == SpatializeAuto && voice->mFmtChannels == FmtMono) ||
|
||||
|
@ -1355,8 +1355,8 @@ void CalcSourceParams(ALvoice *voice, ALCcontext *context, bool force)
|
|||
|
||||
void ProcessParamUpdates(ALCcontext *ctx, const ALeffectslotArray *slots)
|
||||
{
|
||||
IncrementRef(&ctx->UpdateCount);
|
||||
if(LIKELY(!ctx->HoldUpdates.load(std::memory_order_acquire)))
|
||||
IncrementRef(&ctx->mUpdateCount);
|
||||
if(LIKELY(!ctx->mHoldUpdates.load(std::memory_order_acquire)))
|
||||
{
|
||||
bool cforce{CalcContextParams(ctx)};
|
||||
bool force{CalcListenerParams(ctx) || cforce};
|
||||
|
@ -1365,8 +1365,8 @@ void ProcessParamUpdates(ALCcontext *ctx, const ALeffectslotArray *slots)
|
|||
{ return CalcEffectSlotParams(slot, ctx, cforce) | force; }
|
||||
);
|
||||
|
||||
std::for_each(ctx->Voices->begin(),
|
||||
ctx->Voices->begin() + ctx->VoiceCount.load(std::memory_order_acquire),
|
||||
std::for_each(ctx->mVoices->begin(),
|
||||
ctx->mVoices->begin() + ctx->mVoiceCount.load(std::memory_order_acquire),
|
||||
[ctx,force](ALvoice &voice) -> void
|
||||
{
|
||||
ALuint sid{voice.mSourceID.load(std::memory_order_acquire)};
|
||||
|
@ -1374,14 +1374,14 @@ void ProcessParamUpdates(ALCcontext *ctx, const ALeffectslotArray *slots)
|
|||
}
|
||||
);
|
||||
}
|
||||
IncrementRef(&ctx->UpdateCount);
|
||||
IncrementRef(&ctx->mUpdateCount);
|
||||
}
|
||||
|
||||
void ProcessContext(ALCcontext *ctx, const ALsizei SamplesToDo)
|
||||
{
|
||||
ASSUME(SamplesToDo > 0);
|
||||
|
||||
const ALeffectslotArray *auxslots{ctx->ActiveAuxSlots.load(std::memory_order_acquire)};
|
||||
const ALeffectslotArray *auxslots{ctx->mActiveAuxSlots.load(std::memory_order_acquire)};
|
||||
|
||||
/* Process pending propery updates for objects on the context. */
|
||||
ProcessParamUpdates(ctx, auxslots);
|
||||
|
@ -1396,8 +1396,8 @@ void ProcessContext(ALCcontext *ctx, const ALsizei SamplesToDo)
|
|||
);
|
||||
|
||||
/* Process voices that have a playing source. */
|
||||
std::for_each(ctx->Voices->begin(),
|
||||
ctx->Voices->begin() + ctx->VoiceCount.load(std::memory_order_acquire),
|
||||
std::for_each(ctx->mVoices->begin(),
|
||||
ctx->mVoices->begin() + ctx->mVoiceCount.load(std::memory_order_acquire),
|
||||
[SamplesToDo,ctx](ALvoice &voice) -> void
|
||||
{
|
||||
const ALvoice::State vstate{voice.mPlayState.load(std::memory_order_acquire)};
|
||||
|
@ -1772,16 +1772,16 @@ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...)
|
|||
|
||||
for(ALCcontext *ctx : *device->mContexts.load())
|
||||
{
|
||||
const ALbitfieldSOFT enabledevt{ctx->EnabledEvts.load(std::memory_order_acquire)};
|
||||
const ALbitfieldSOFT enabledevt{ctx->mEnabledEvts.load(std::memory_order_acquire)};
|
||||
if((enabledevt&EventType_Disconnected))
|
||||
{
|
||||
RingBuffer *ring{ctx->AsyncEvents.get()};
|
||||
RingBuffer *ring{ctx->mAsyncEvents.get()};
|
||||
auto evt_data = ring->getWriteVector().first;
|
||||
if(evt_data.len > 0)
|
||||
{
|
||||
new (evt_data.buf) AsyncEvent{evt};
|
||||
ring->writeAdvance(1);
|
||||
ctx->EventSem.post();
|
||||
ctx->mEventSem.post();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1792,8 +1792,8 @@ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...)
|
|||
voice.mSourceID.store(0u, std::memory_order_relaxed);
|
||||
voice.mPlayState.store(ALvoice::Stopped, std::memory_order_release);
|
||||
};
|
||||
std::for_each(ctx->Voices->begin(),
|
||||
ctx->Voices->begin() + ctx->VoiceCount.load(std::memory_order_acquire),
|
||||
std::for_each(ctx->mVoices->begin(),
|
||||
ctx->mVoices->begin() + ctx->mVoiceCount.load(std::memory_order_acquire),
|
||||
stop_voice);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ ALboolean ALautowahState::deviceUpdate(const ALCdevice*)
|
|||
|
||||
void ALautowahState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target)
|
||||
{
|
||||
const ALCdevice *device{context->Device};
|
||||
const ALCdevice *device{context->mDevice};
|
||||
|
||||
const ALfloat ReleaseTime{clampf(props->Autowah.ReleaseTime, 0.001f, 1.0f)};
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, co
|
|||
/* 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->Device};
|
||||
const ALCdevice *device{Context->mDevice};
|
||||
const auto frequency = static_cast<ALfloat>(device->Frequency);
|
||||
mDelay = maxi(float2int(props->Chorus.Delay*frequency*FRACTIONONE + 0.5f), mindelay);
|
||||
mDepth = minf(props->Chorus.Depth * mDelay, static_cast<ALfloat>(mDelay - mindelay));
|
||||
|
|
|
@ -64,7 +64,7 @@ ALboolean DistortionState::deviceUpdate(const ALCdevice*)
|
|||
|
||||
void DistortionState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target)
|
||||
{
|
||||
const ALCdevice *device{context->Device};
|
||||
const ALCdevice *device{context->mDevice};
|
||||
|
||||
/* Store waveshaper edge settings. */
|
||||
const ALfloat edge{
|
||||
|
|
|
@ -94,7 +94,7 @@ ALboolean EchoState::deviceUpdate(const ALCdevice *Device)
|
|||
|
||||
void EchoState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target)
|
||||
{
|
||||
const ALCdevice *device = context->Device;
|
||||
const ALCdevice *device = context->mDevice;
|
||||
const auto frequency = static_cast<ALfloat>(device->Frequency);
|
||||
|
||||
mTap[0].delay = maxi(float2int(props->Echo.Delay*frequency + 0.5f), 1);
|
||||
|
|
|
@ -112,7 +112,7 @@ ALboolean EqualizerState::deviceUpdate(const ALCdevice*)
|
|||
|
||||
void EqualizerState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target)
|
||||
{
|
||||
const ALCdevice *device = context->Device;
|
||||
const ALCdevice *device = context->mDevice;
|
||||
auto frequency = static_cast<ALfloat>(device->Frequency);
|
||||
ALfloat gain, f0norm;
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ ALboolean FshifterState::deviceUpdate(const ALCdevice*)
|
|||
|
||||
void FshifterState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target)
|
||||
{
|
||||
const ALCdevice *device{context->Device};
|
||||
const ALCdevice *device{context->mDevice};
|
||||
|
||||
ALfloat step{props->Fshifter.Frequency / static_cast<ALfloat>(device->Frequency)};
|
||||
mPhaseStep = fastf2i(minf(step, 0.5f) * FRACTIONONE);
|
||||
|
|
|
@ -110,7 +110,7 @@ ALboolean ModulatorState::deviceUpdate(const ALCdevice*)
|
|||
|
||||
void ModulatorState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target)
|
||||
{
|
||||
const ALCdevice *device{context->Device};
|
||||
const ALCdevice *device{context->mDevice};
|
||||
|
||||
const float step{props->Modulator.Frequency / static_cast<ALfloat>(device->Frequency)};
|
||||
mStep = fastf2i(clampf(step*WAVEFORM_FRACONE, 0.0f, ALfloat{WAVEFORM_FRACONE-1}));
|
||||
|
|
|
@ -906,8 +906,8 @@ void ReverbState::update3DPanning(const ALfloat *ReflectionsPan, const ALfloat *
|
|||
|
||||
void ReverbState::update(const ALCcontext *Context, const ALeffectslot *Slot, const EffectProps *props, const EffectTarget target)
|
||||
{
|
||||
const ALCdevice *Device{Context->Device};
|
||||
const ALlistener &Listener = Context->Listener;
|
||||
const ALCdevice *Device{Context->mDevice};
|
||||
const ALlistener &Listener = Context->mListener;
|
||||
const auto frequency = static_cast<ALfloat>(Device->Frequency);
|
||||
|
||||
/* Calculate the master filters */
|
||||
|
|
|
@ -210,7 +210,7 @@ ALboolean VmorpherState::deviceUpdate(const ALCdevice* /*device*/)
|
|||
|
||||
void VmorpherState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target)
|
||||
{
|
||||
const ALCdevice *device{context->Device};
|
||||
const ALCdevice *device{context->mDevice};
|
||||
const ALfloat frequency{static_cast<ALfloat>(device->Frequency)};
|
||||
const ALfloat step{props->Vmorpher.Rate / static_cast<ALfloat>(device->Frequency)};
|
||||
mStep = fastf2i(clampf(step*WAVEFORM_FRACONE, 0.0f, ALfloat{WAVEFORM_FRACONE-1}));
|
||||
|
|
|
@ -291,10 +291,10 @@ constexpr ALshort aLawDecompressionTable[256] = {
|
|||
|
||||
void SendSourceStoppedEvent(ALCcontext *context, ALuint id)
|
||||
{
|
||||
ALbitfieldSOFT enabledevt{context->EnabledEvts.load(std::memory_order_acquire)};
|
||||
ALbitfieldSOFT enabledevt{context->mEnabledEvts.load(std::memory_order_acquire)};
|
||||
if(!(enabledevt&EventType_SourceStateChange)) return;
|
||||
|
||||
RingBuffer *ring{context->AsyncEvents.get()};
|
||||
RingBuffer *ring{context->mAsyncEvents.get()};
|
||||
auto evt_vec = ring->getWriteVector();
|
||||
if(evt_vec.first.len < 1) return;
|
||||
|
||||
|
@ -303,7 +303,7 @@ void SendSourceStoppedEvent(ALCcontext *context, ALuint id)
|
|||
evt->u.srcstate.state = AL_STOPPED;
|
||||
|
||||
ring->writeAdvance(1);
|
||||
context->EventSem.post();
|
||||
context->mEventSem.post();
|
||||
}
|
||||
|
||||
|
||||
|
@ -544,7 +544,7 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
|
|||
ASSUME(SampleSize > 0);
|
||||
ASSUME(increment > 0);
|
||||
|
||||
ALCdevice *Device{Context->Device};
|
||||
ALCdevice *Device{Context->mDevice};
|
||||
const ALsizei NumSends{Device->NumAuxSends};
|
||||
const ALsizei IrSize{Device->mHrtf ? Device->mHrtf->irSize : 0};
|
||||
|
||||
|
@ -929,10 +929,10 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
|
|||
std::atomic_thread_fence(std::memory_order_release);
|
||||
|
||||
/* Send any events now, after the position/buffer info was updated. */
|
||||
ALbitfieldSOFT enabledevt{Context->EnabledEvts.load(std::memory_order_acquire)};
|
||||
ALbitfieldSOFT enabledevt{Context->mEnabledEvts.load(std::memory_order_acquire)};
|
||||
if(buffers_done > 0 && (enabledevt&EventType_BufferCompleted))
|
||||
{
|
||||
RingBuffer *ring{Context->AsyncEvents.get()};
|
||||
RingBuffer *ring{Context->mAsyncEvents.get()};
|
||||
auto evt_vec = ring->getWriteVector();
|
||||
if(evt_vec.first.len > 0)
|
||||
{
|
||||
|
@ -940,7 +940,7 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
|
|||
evt->u.bufcomp.id = SourceID;
|
||||
evt->u.bufcomp.count = buffers_done;
|
||||
ring->writeAdvance(1);
|
||||
Context->EventSem.post();
|
||||
Context->mEventSem.post();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue