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