diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp index 8c2369151..3cc45fd84 100644 --- a/al/auxeffectslot.cpp +++ b/al/auxeffectslot.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -111,7 +110,7 @@ auto LookupEffectSlot(ALCcontext *context, ALuint id) noexcept -> ALeffectslot* return al::to_address(sublist.EffectSlots->begin() + slidx); } -inline auto LookupEffect(ALCdevice *device, ALuint id) noexcept -> ALeffect* +inline auto LookupEffect(al::Device *device, ALuint id) noexcept -> ALeffect* { const size_t lidx{(id-1) >> 6}; const ALuint slidx{(id-1) & 0x3f}; @@ -124,7 +123,7 @@ inline auto LookupEffect(ALCdevice *device, ALuint id) noexcept -> ALeffect* return al::to_address(sublist.Effects->begin() + slidx); } -inline auto LookupBuffer(ALCdevice *device, ALuint id) noexcept -> ALbuffer* +inline auto LookupBuffer(al::Device *device, ALuint id) noexcept -> ALbuffer* { const size_t lidx{(id-1) >> 6}; const ALuint slidx{(id-1) & 0x3f}; @@ -325,8 +324,8 @@ try { throw al::context_error{AL_INVALID_VALUE, "Generating %d effect slots", n}; if(n <= 0) UNLIKELY return; - std::lock_guard slotlock{context->mEffectSlotLock}; - ALCdevice *device{context->mALDevice.get()}; + auto slotlock = std::lock_guard{context->mEffectSlotLock}; + auto *device = context->mALDevice.get(); const al::span eids{effectslots, static_cast(n)}; if(eids.size() > device->AuxiliaryEffectSlotMax-context->mNumEffectSlots) @@ -482,9 +481,9 @@ try { { case AL_EFFECTSLOT_EFFECT: { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard effectlock{device->EffectLock}; - ALeffect *effect{value ? LookupEffect(device, static_cast(value)) : nullptr}; + auto *device = context->mALDevice.get(); + auto effectlock = std::lock_guard{device->EffectLock}; + auto *effect = value ? LookupEffect(device, static_cast(value)) : nullptr; if(effect) err = slot->initEffect(effect->id, effect->type, effect->Props, context); else @@ -569,7 +568,7 @@ try { assert(factory); al::intrusive_ptr state{factory->create()}; - ALCdevice *device{context->mALDevice.get()}; + auto *device = context->mALDevice.get(); auto bufferlock = std::unique_lock{device->BufferLock}; ALbuffer *buffer{}; if(value) @@ -605,7 +604,7 @@ try { } else { - ALCdevice *device{context->mALDevice.get()}; + auto *device = context->mALDevice.get(); auto bufferlock = std::unique_lock{device->BufferLock}; ALbuffer *buffer{}; if(value) @@ -895,7 +894,7 @@ ALenum ALeffectslot::initEffect(ALuint effectId, ALenum effectType, const Effect } al::intrusive_ptr state{factory->create()}; - ALCdevice *device{context->mALDevice.get()}; + auto *device = context->mALDevice.get(); state->mOutTarget = device->Dry.Buffer; { FPUCtl mixer_mode{}; diff --git a/al/buffer.cpp b/al/buffer.cpp index dfc7665f7..83487e277 100644 --- a/al/buffer.cpp +++ b/al/buffer.cpp @@ -136,8 +136,8 @@ constexpr auto EnumFromEaxStorage(EaxStorage storage) -> ALenum } -bool eax_x_ram_check_availability(const ALCdevice &device, const ALbuffer &buffer, - const ALuint newsize) noexcept +auto eax_x_ram_check_availability(const al::Device &device, const ALbuffer &buffer, + const ALuint newsize) noexcept -> bool { ALuint freemem{device.eax_x_ram_free_size}; /* If the buffer is currently in "hardware", add its memory to the free @@ -148,7 +148,7 @@ bool eax_x_ram_check_availability(const ALCdevice &device, const ALbuffer &buffe return freemem >= newsize; } -void eax_x_ram_apply(ALCdevice &device, ALbuffer &buffer) noexcept +void eax_x_ram_apply(al::Device &device, ALbuffer &buffer) noexcept { if(buffer.eax_x_ram_is_hardware) return; @@ -160,7 +160,7 @@ void eax_x_ram_apply(ALCdevice &device, ALbuffer &buffer) noexcept } } -void eax_x_ram_clear(ALCdevice& al_device, ALbuffer& al_buffer) noexcept +void eax_x_ram_clear(al::Device& al_device, ALbuffer& al_buffer) noexcept { if(al_buffer.eax_x_ram_is_hardware) al_device.eax_x_ram_free_size += al_buffer.OriginalSize; @@ -176,7 +176,7 @@ constexpr ALbitfieldSOFT INVALID_MAP_FLAGS{~unsigned(AL_MAP_READ_BIT_SOFT | AL_M AL_MAP_PERSISTENT_BIT_SOFT)}; -auto EnsureBuffers(ALCdevice *device, size_t needed) noexcept -> bool +auto EnsureBuffers(al::Device *device, size_t needed) noexcept -> bool try { size_t count{std::accumulate(device->BufferList.cbegin(), device->BufferList.cend(), 0_uz, [](size_t cur, const BufferSubList &sublist) noexcept -> size_t @@ -199,7 +199,7 @@ catch(...) { return false; } -ALbuffer *AllocBuffer(ALCdevice *device) noexcept +auto AllocBuffer(al::Device *device) noexcept -> ALbuffer* { auto sublist = std::find_if(device->BufferList.begin(), device->BufferList.end(), [](const BufferSubList &entry) noexcept -> bool @@ -218,7 +218,7 @@ ALbuffer *AllocBuffer(ALCdevice *device) noexcept return buffer; } -void FreeBuffer(ALCdevice *device, ALbuffer *buffer) +void FreeBuffer(al::Device *device, ALbuffer *buffer) { #if ALSOFT_EAX eax_x_ram_clear(*device, *buffer); @@ -235,7 +235,7 @@ void FreeBuffer(ALCdevice *device, ALbuffer *buffer) device->BufferList[lidx].FreeMask |= 1_u64 << slidx; } -auto LookupBuffer(ALCdevice *device, ALuint id) noexcept -> ALbuffer* +auto LookupBuffer(al::Device *device, ALuint id) noexcept -> ALbuffer* { const size_t lidx{(id-1) >> 6}; const ALuint slidx{(id-1) & 0x3f}; @@ -336,7 +336,7 @@ void LoadData(ALCcontext *context [[maybe_unused]], ALbuffer *ALBuf, ALsizei fre #if ALSOFT_EAX if(ALBuf->eax_x_ram_mode == EaxStorage::Hardware) { - ALCdevice &device = *context->mALDevice; + auto &device = *context->mALDevice; if(!eax_x_ram_check_availability(device, *ALBuf, size)) throw al::context_error{AL_OUT_OF_MEMORY, "Out of X-RAM memory (avail: %u, needed: %u)", device.eax_x_ram_free_size, size}; @@ -510,7 +510,7 @@ void PrepareUserPtr(ALCcontext *context [[maybe_unused]], ALbuffer *ALBuf, ALsiz #if ALSOFT_EAX if(ALBuf->eax_x_ram_mode == EaxStorage::Hardware) { - ALCdevice &device = *context->mALDevice; + auto &device = *context->mALDevice; if(!eax_x_ram_check_availability(device, *ALBuf, sdatalen)) throw al::context_error{AL_OUT_OF_MEMORY, "Out of X-RAM memory (avail: %u, needed: %u)", device.eax_x_ram_free_size, @@ -667,8 +667,8 @@ try { throw al::context_error{AL_INVALID_VALUE, "Generating %d buffers", n}; if(n <= 0) UNLIKELY return; - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; const al::span bids{buffers, static_cast(n)}; if(!EnsureBuffers(device, bids.size())) @@ -689,8 +689,8 @@ try { throw al::context_error{AL_INVALID_VALUE, "Deleting %d buffers", n}; if(n <= 0) UNLIKELY return; - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; /* First try to find any buffers that are invalid or in-use. */ auto validate_buffer = [device](const ALuint bid) @@ -721,8 +721,8 @@ catch(al::context_error& e) { AL_API DECL_FUNC1(ALboolean, alIsBuffer, ALuint,buffer) FORCE_ALIGN ALboolean AL_APIENTRY alIsBufferDirect(ALCcontext *context, ALuint buffer) noexcept { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; if(!buffer || LookupBuffer(device, buffer)) return AL_TRUE; return AL_FALSE; @@ -743,8 +743,8 @@ AL_API DECL_FUNCEXT6(void, alBufferStorage,SOFT, ALuint,buffer, ALenum,format, c FORCE_ALIGN void AL_APIENTRY alBufferStorageDirectSOFT(ALCcontext *context, ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq, ALbitfieldSOFT flags) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; ALbuffer *albuf{LookupBuffer(device, buffer)}; if(!albuf) @@ -776,8 +776,8 @@ FORCE_ALIGN DECL_FUNC5(void, alBufferDataStatic, ALuint,buffer, ALenum,format, A FORCE_ALIGN void AL_APIENTRY alBufferDataStaticDirect(ALCcontext *context, const ALuint buffer, ALenum format, ALvoid *data, ALsizei size, ALsizei freq) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; ALbuffer *albuf{LookupBuffer(device, buffer)}; if(!albuf) @@ -802,8 +802,8 @@ AL_API DECL_FUNCEXT4(void*, alMapBuffer,SOFT, ALuint,buffer, ALsizei,offset, ALs FORCE_ALIGN void* AL_APIENTRY alMapBufferDirectSOFT(ALCcontext *context, ALuint buffer, ALsizei offset, ALsizei length, ALbitfieldSOFT access) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; ALbuffer *albuf{LookupBuffer(device, buffer)}; if(!albuf) @@ -849,8 +849,8 @@ catch(al::context_error& e) { AL_API DECL_FUNCEXT1(void, alUnmapBuffer,SOFT, ALuint,buffer) FORCE_ALIGN void AL_APIENTRY alUnmapBufferDirectSOFT(ALCcontext *context, ALuint buffer) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; ALbuffer *albuf{LookupBuffer(device, buffer)}; if(!albuf) @@ -870,8 +870,8 @@ AL_API DECL_FUNCEXT3(void, alFlushMappedBuffer,SOFT, ALuint,buffer, ALsizei,offs FORCE_ALIGN void AL_APIENTRY alFlushMappedBufferDirectSOFT(ALCcontext *context, ALuint buffer, ALsizei offset, ALsizei length) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; ALbuffer *albuf{LookupBuffer(device, buffer)}; if(!albuf) @@ -900,8 +900,8 @@ AL_API DECL_FUNCEXT5(void, alBufferSubData,SOFT, ALuint,buffer, ALenum,format, c FORCE_ALIGN void AL_APIENTRY alBufferSubDataDirectSOFT(ALCcontext *context, ALuint buffer, ALenum format, const ALvoid *data, ALsizei offset, ALsizei length) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; ALbuffer *albuf{LookupBuffer(device, buffer)}; if(!albuf) @@ -958,8 +958,8 @@ AL_API DECL_FUNC3(void, alBufferf, ALuint,buffer, ALenum,param, ALfloat,value) FORCE_ALIGN void AL_APIENTRY alBufferfDirect(ALCcontext *context, ALuint buffer, ALenum param, ALfloat value [[maybe_unused]]) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; if(LookupBuffer(device, buffer) == nullptr) throw al::context_error{AL_INVALID_NAME, "Invalid buffer ID %u", buffer}; @@ -978,8 +978,8 @@ FORCE_ALIGN void AL_APIENTRY alBuffer3fDirect(ALCcontext *context, ALuint buffer ALfloat value1 [[maybe_unused]], ALfloat value2 [[maybe_unused]], ALfloat value3 [[maybe_unused]]) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; if(LookupBuffer(device, buffer) == nullptr) throw al::context_error{AL_INVALID_NAME, "Invalid buffer ID %u", buffer}; @@ -997,8 +997,8 @@ AL_API DECL_FUNC3(void, alBufferfv, ALuint,buffer, ALenum,param, const ALfloat*, FORCE_ALIGN void AL_APIENTRY alBufferfvDirect(ALCcontext *context, ALuint buffer, ALenum param, const ALfloat *values) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; if(LookupBuffer(device, buffer) == nullptr) throw al::context_error{AL_INVALID_NAME, "Invalid buffer ID %u", buffer}; @@ -1019,8 +1019,8 @@ AL_API DECL_FUNC3(void, alBufferi, ALuint,buffer, ALenum,param, ALint,value) FORCE_ALIGN void AL_APIENTRY alBufferiDirect(ALCcontext *context, ALuint buffer, ALenum param, ALint value) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; ALbuffer *albuf{LookupBuffer(device, buffer)}; if(!albuf) @@ -1079,8 +1079,8 @@ AL_API DECL_FUNC5(void, alBuffer3i, ALuint,buffer, ALenum,param, ALint,value1, A FORCE_ALIGN void AL_APIENTRY alBuffer3iDirect(ALCcontext *context, ALuint buffer, ALenum param, ALint value1 [[maybe_unused]], ALint value2 [[maybe_unused]], ALint value3 [[maybe_unused]]) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; if(LookupBuffer(device, buffer) == nullptr) throw al::context_error{AL_INVALID_NAME, "Invalid buffer ID %u", buffer}; @@ -1112,8 +1112,8 @@ try { return; } - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; ALbuffer *albuf{LookupBuffer(device, buffer)}; if(!albuf) @@ -1147,8 +1147,8 @@ AL_API DECL_FUNC3(void, alGetBufferf, ALuint,buffer, ALenum,param, ALfloat*,valu FORCE_ALIGN void AL_APIENTRY alGetBufferfDirect(ALCcontext *context, ALuint buffer, ALenum param, ALfloat *value) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; ALbuffer *albuf{LookupBuffer(device, buffer)}; if(!albuf) @@ -1174,8 +1174,8 @@ AL_API DECL_FUNC5(void, alGetBuffer3f, ALuint,buffer, ALenum,param, ALfloat*,val FORCE_ALIGN void AL_APIENTRY alGetBuffer3fDirect(ALCcontext *context, ALuint buffer, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; if(LookupBuffer(device, buffer) == nullptr) throw al::context_error{AL_INVALID_NAME, "Invalid buffer ID %u", buffer}; @@ -1202,8 +1202,8 @@ try { return; } - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; if(LookupBuffer(device, buffer) == nullptr) throw al::context_error{AL_INVALID_NAME, "Invalid buffer ID %u", buffer}; @@ -1224,8 +1224,8 @@ AL_API DECL_FUNC3(void, alGetBufferi, ALuint,buffer, ALenum,param, ALint*,value) FORCE_ALIGN void AL_APIENTRY alGetBufferiDirect(ALCcontext *context, ALuint buffer, ALenum param, ALint *value) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; ALbuffer *albuf{LookupBuffer(device, buffer)}; if(!albuf) @@ -1292,8 +1292,8 @@ AL_API DECL_FUNC5(void, alGetBuffer3i, ALuint,buffer, ALenum,param, ALint*,value FORCE_ALIGN void AL_APIENTRY alGetBuffer3iDirect(ALCcontext *context, ALuint buffer, ALenum param, ALint *value1, ALint *value2, ALint *value3) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; if(LookupBuffer(device, buffer) == nullptr) throw al::context_error{AL_INVALID_NAME, "Invalid buffer ID %u", buffer}; @@ -1331,8 +1331,8 @@ try { return; } - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; ALbuffer *albuf{LookupBuffer(device, buffer)}; if(!albuf) @@ -1361,8 +1361,8 @@ AL_API DECL_FUNCEXT5(void, alBufferCallback,SOFT, ALuint,buffer, ALenum,format, FORCE_ALIGN void AL_APIENTRY alBufferCallbackDirectSOFT(ALCcontext *context, ALuint buffer, ALenum format, ALsizei freq, ALBUFFERCALLBACKTYPESOFT callback, ALvoid *userptr) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; ALbuffer *albuf{LookupBuffer(device, buffer)}; if(!albuf) @@ -1386,8 +1386,8 @@ AL_API DECL_FUNCEXT3(void, alGetBufferPtr,SOFT, ALuint,buffer, ALenum,param, ALv FORCE_ALIGN void AL_APIENTRY alGetBufferPtrDirectSOFT(ALCcontext *context, ALuint buffer, ALenum param, ALvoid **value) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; ALbuffer *albuf{LookupBuffer(device, buffer)}; if(!albuf) @@ -1415,8 +1415,8 @@ AL_API DECL_FUNCEXT5(void, alGetBuffer3Ptr,SOFT, ALuint,buffer, ALenum,param, AL FORCE_ALIGN void AL_APIENTRY alGetBuffer3PtrDirectSOFT(ALCcontext *context, ALuint buffer, ALenum param, ALvoid **value1, ALvoid **value2, ALvoid **value3) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; if(LookupBuffer(device, buffer) == nullptr) throw al::context_error{AL_INVALID_NAME, "Invalid buffer ID %u", buffer}; @@ -1444,8 +1444,8 @@ try { return; } - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; if(LookupBuffer(device, buffer) == nullptr) throw al::context_error{AL_INVALID_NAME, "Invalid buffer ID %u", buffer}; @@ -1503,8 +1503,8 @@ AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum /*format*/) no void ALbuffer::SetName(ALCcontext *context, ALuint id, std::string_view name) { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; auto buffer = LookupBuffer(device, id); if(!buffer) diff --git a/al/debug.cpp b/al/debug.cpp index 0a477d187..8637c0505 100644 --- a/al/debug.cpp +++ b/al/debug.cpp @@ -579,20 +579,20 @@ try { } else if(identifier == AL_BUFFER) { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard buflock{device->BufferLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->BufferLock}; copy_name(device->mBufferNames); } else if(identifier == AL_FILTER_EXT) { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard filterlock{device->FilterLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->FilterLock}; copy_name(device->mFilterNames); } else if(identifier == AL_EFFECT_EXT) { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard effectlock{device->EffectLock}; + auto *device = context->mALDevice.get(); + auto buflock = std::lock_guard{device->EffectLock}; copy_name(device->mEffectNames); } else if(identifier == AL_AUXILIARY_EFFECT_SLOT_EXT) diff --git a/al/effect.cpp b/al/effect.cpp index 6509d755d..d72b9df2e 100644 --- a/al/effect.cpp +++ b/al/effect.cpp @@ -139,7 +139,7 @@ void InitEffectParams(ALeffect *effect, ALenum type) noexcept effect->type = type; } -auto EnsureEffects(ALCdevice *device, size_t needed) noexcept -> bool +auto EnsureEffects(al::Device *device, size_t needed) noexcept -> bool try { size_t count{std::accumulate(device->EffectList.cbegin(), device->EffectList.cend(), 0_uz, [](size_t cur, const EffectSubList &sublist) noexcept -> size_t @@ -162,7 +162,7 @@ catch(...) { return false; } -ALeffect *AllocEffect(ALCdevice *device) noexcept +auto AllocEffect(al::Device *device) noexcept -> ALeffect* { auto sublist = std::find_if(device->EffectList.begin(), device->EffectList.end(), [](const EffectSubList &entry) noexcept -> bool @@ -182,7 +182,7 @@ ALeffect *AllocEffect(ALCdevice *device) noexcept return effect; } -void FreeEffect(ALCdevice *device, ALeffect *effect) +void FreeEffect(al::Device *device, ALeffect *effect) { device->mEffectNames.erase(effect->id); @@ -195,7 +195,7 @@ void FreeEffect(ALCdevice *device, ALeffect *effect) device->EffectList[lidx].FreeMask |= 1_u64 << slidx; } -inline auto LookupEffect(ALCdevice *device, ALuint id) noexcept -> ALeffect* +inline auto LookupEffect(al::Device *device, ALuint id) noexcept -> ALeffect* { const size_t lidx{(id-1) >> 6}; const ALuint slidx{(id-1) & 0x3f}; @@ -217,8 +217,8 @@ try { throw al::context_error{AL_INVALID_VALUE, "Generating %d effects", n}; if(n <= 0) UNLIKELY return; - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard effectlock{device->EffectLock}; + auto *device = context->mALDevice.get(); + auto effectlock = std::lock_guard{device->EffectLock}; const al::span eids{effects, static_cast(n)}; if(!EnsureEffects(device, eids.size())) @@ -239,8 +239,8 @@ try { throw al::context_error{AL_INVALID_VALUE, "Deleting %d effects", n}; if(n <= 0) UNLIKELY return; - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard effectlock{device->EffectLock}; + auto *device = context->mALDevice.get(); + auto effectlock = std::lock_guard{device->EffectLock}; /* First try to find any effects that are invalid. */ auto validate_effect = [device](const ALuint eid) -> bool @@ -266,8 +266,8 @@ catch(al::context_error& e) { AL_API DECL_FUNC1(ALboolean, alIsEffect, ALuint,effect) FORCE_ALIGN ALboolean AL_APIENTRY alIsEffectDirect(ALCcontext *context, ALuint effect) noexcept { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard effectlock{device->EffectLock}; + auto *device = context->mALDevice.get(); + auto effectlock = std::lock_guard{device->EffectLock}; if(!effect || LookupEffect(device, effect)) return AL_TRUE; return AL_FALSE; @@ -277,8 +277,8 @@ AL_API DECL_FUNC3(void, alEffecti, ALuint,effect, ALenum,param, ALint,value) FORCE_ALIGN void AL_APIENTRY alEffectiDirect(ALCcontext *context, ALuint effect, ALenum param, ALint value) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard effectlock{device->EffectLock}; + auto *device = context->mALDevice.get(); + auto effectlock = std::lock_guard{device->EffectLock}; ALeffect *aleffect{LookupEffect(device, effect)}; if(!aleffect) @@ -323,8 +323,8 @@ try { return; } - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard effectlock{device->EffectLock}; + auto *device = context->mALDevice.get(); + auto effectlock = std::lock_guard{device->EffectLock}; ALeffect *aleffect{LookupEffect(device, effect)}; if(!aleffect) @@ -346,8 +346,8 @@ AL_API DECL_FUNC3(void, alEffectf, ALuint,effect, ALenum,param, ALfloat,value) FORCE_ALIGN void AL_APIENTRY alEffectfDirect(ALCcontext *context, ALuint effect, ALenum param, ALfloat value) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard effectlock{device->EffectLock}; + auto *device = context->mALDevice.get(); + auto effectlock = std::lock_guard{device->EffectLock}; ALeffect *aleffect{LookupEffect(device, effect)}; if(!aleffect) UNLIKELY @@ -369,8 +369,8 @@ AL_API DECL_FUNC3(void, alEffectfv, ALuint,effect, ALenum,param, const ALfloat*, FORCE_ALIGN void AL_APIENTRY alEffectfvDirect(ALCcontext *context, ALuint effect, ALenum param, const ALfloat *values) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard effectlock{device->EffectLock}; + auto *device = context->mALDevice.get(); + auto effectlock = std::lock_guard{device->EffectLock}; ALeffect *aleffect{LookupEffect(device, effect)}; if(!aleffect) @@ -392,8 +392,8 @@ AL_API DECL_FUNC3(void, alGetEffecti, ALuint,effect, ALenum,param, ALint*,value) FORCE_ALIGN void AL_APIENTRY alGetEffectiDirect(ALCcontext *context, ALuint effect, ALenum param, ALint *value) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard effectlock{device->EffectLock}; + auto *device = context->mALDevice.get(); + auto effectlock = std::lock_guard{device->EffectLock}; const ALeffect *aleffect{LookupEffect(device, effect)}; if(!aleffect) @@ -429,8 +429,8 @@ try { return; } - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard effectlock{device->EffectLock}; + auto *device = context->mALDevice.get(); + auto effectlock = std::lock_guard{device->EffectLock}; const ALeffect *aleffect{LookupEffect(device, effect)}; if(!aleffect) @@ -452,8 +452,8 @@ AL_API DECL_FUNC3(void, alGetEffectf, ALuint,effect, ALenum,param, ALfloat*,valu FORCE_ALIGN void AL_APIENTRY alGetEffectfDirect(ALCcontext *context, ALuint effect, ALenum param, ALfloat *value) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard effectlock{device->EffectLock}; + auto *device = context->mALDevice.get(); + auto effectlock = std::lock_guard{device->EffectLock}; const ALeffect *aleffect{LookupEffect(device, effect)}; if(!aleffect) @@ -475,8 +475,8 @@ AL_API DECL_FUNC3(void, alGetEffectfv, ALuint,effect, ALenum,param, ALfloat*,val FORCE_ALIGN void AL_APIENTRY alGetEffectfvDirect(ALCcontext *context, ALuint effect, ALenum param, ALfloat *values) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard effectlock{device->EffectLock}; + auto *device = context->mALDevice.get(); + auto effectlock = std::lock_guard{device->EffectLock}; const ALeffect *aleffect{LookupEffect(device, effect)}; if(!aleffect) @@ -502,8 +502,8 @@ void InitEffect(ALeffect *effect) void ALeffect::SetName(ALCcontext* context, ALuint id, std::string_view name) { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard effectlock{device->EffectLock}; + auto *device = context->mALDevice.get(); + auto effectlock = std::lock_guard{device->EffectLock}; auto effect = LookupEffect(device, id); if(!effect) diff --git a/al/error.cpp b/al/error.cpp index 1ed829791..f852d5ed4 100644 --- a/al/error.cpp +++ b/al/error.cpp @@ -27,7 +27,6 @@ #include #endif -#include #include #include #include @@ -45,7 +44,6 @@ #include "al/debug.h" #include "alc/alconfig.h" #include "alc/context.h" -#include "alc/inprogext.h" #include "core/logging.h" #include "opthelpers.h" #include "strutils.h" diff --git a/al/filter.cpp b/al/filter.cpp index 5e56c6f04..4ef6b9583 100644 --- a/al/filter.cpp +++ b/al/filter.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -41,7 +40,6 @@ #include "albit.h" #include "alc/context.h" #include "alc/device.h" -#include "alc/inprogext.h" #include "almalloc.h" #include "alnumeric.h" #include "alspan.h" @@ -97,7 +95,7 @@ void InitFilterParams(ALfilter *filter, ALenum type) filter->type = type; } -auto EnsureFilters(ALCdevice *device, size_t needed) noexcept -> bool +auto EnsureFilters(al::Device *device, size_t needed) noexcept -> bool try { size_t count{std::accumulate(device->FilterList.cbegin(), device->FilterList.cend(), 0_uz, [](size_t cur, const FilterSubList &sublist) noexcept -> size_t @@ -121,7 +119,7 @@ catch(...) { } -ALfilter *AllocFilter(ALCdevice *device) noexcept +auto AllocFilter(al::Device *device) noexcept -> ALfilter* { auto sublist = std::find_if(device->FilterList.begin(), device->FilterList.end(), [](const FilterSubList &entry) noexcept -> bool @@ -141,7 +139,7 @@ ALfilter *AllocFilter(ALCdevice *device) noexcept return filter; } -void FreeFilter(ALCdevice *device, ALfilter *filter) +void FreeFilter(al::Device *device, ALfilter *filter) { device->mFilterNames.erase(filter->id); @@ -155,7 +153,7 @@ void FreeFilter(ALCdevice *device, ALfilter *filter) } -auto LookupFilter(ALCdevice *device, ALuint id) noexcept -> ALfilter* +auto LookupFilter(al::Device *device, ALuint id) noexcept -> ALfilter* { const size_t lidx{(id-1) >> 6}; const ALuint slidx{(id-1) & 0x3f}; @@ -358,8 +356,8 @@ try { throw al::context_error{AL_INVALID_VALUE, "Generating %d filters", n}; if(n <= 0) UNLIKELY return; - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard filterlock{device->FilterLock}; + auto *device = context->mALDevice.get(); + auto filterlock = std::lock_guard{device->FilterLock}; const al::span fids{filters, static_cast(n)}; if(!EnsureFilters(device, fids.size())) @@ -380,8 +378,8 @@ try { throw al::context_error{AL_INVALID_VALUE, "Deleting %d filters", n}; if(n <= 0) UNLIKELY return; - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard filterlock{device->FilterLock}; + auto *device = context->mALDevice.get(); + auto filterlock = std::lock_guard{device->FilterLock}; /* First try to find any filters that are invalid. */ auto validate_filter = [device](const ALuint fid) -> bool @@ -407,8 +405,8 @@ catch(al::context_error& e) { AL_API DECL_FUNC1(ALboolean, alIsFilter, ALuint,filter) FORCE_ALIGN ALboolean AL_APIENTRY alIsFilterDirect(ALCcontext *context, ALuint filter) noexcept { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard filterlock{device->FilterLock}; + auto *device = context->mALDevice.get(); + auto filterlock = std::lock_guard{device->FilterLock}; if(!filter || LookupFilter(device, filter)) return AL_TRUE; return AL_FALSE; @@ -419,8 +417,8 @@ AL_API DECL_FUNC3(void, alFilteri, ALuint,filter, ALenum,param, ALint,value) FORCE_ALIGN void AL_APIENTRY alFilteriDirect(ALCcontext *context, ALuint filter, ALenum param, ALint value) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard filterlock{device->FilterLock}; + auto *device = context->mALDevice.get(); + auto filterlock = std::lock_guard{device->FilterLock}; ALfilter *alfilt{LookupFilter(device, filter)}; if(!alfilt) @@ -455,8 +453,8 @@ try { return; } - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard filterlock{device->FilterLock}; + auto *device = context->mALDevice.get(); + auto filterlock = std::lock_guard{device->FilterLock}; ALfilter *alfilt{LookupFilter(device, filter)}; if(!alfilt) @@ -474,8 +472,8 @@ AL_API DECL_FUNC3(void, alFilterf, ALuint,filter, ALenum,param, ALfloat,value) FORCE_ALIGN void AL_APIENTRY alFilterfDirect(ALCcontext *context, ALuint filter, ALenum param, ALfloat value) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard filterlock{device->FilterLock}; + auto *device = context->mALDevice.get(); + auto filterlock = std::lock_guard{device->FilterLock}; ALfilter *alfilt{LookupFilter(device, filter)}; if(!alfilt) @@ -493,8 +491,8 @@ AL_API DECL_FUNC3(void, alFilterfv, ALuint,filter, ALenum,param, const ALfloat*, FORCE_ALIGN void AL_APIENTRY alFilterfvDirect(ALCcontext *context, ALuint filter, ALenum param, const ALfloat *values) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard filterlock{device->FilterLock}; + auto *device = context->mALDevice.get(); + auto filterlock = std::lock_guard{device->FilterLock}; ALfilter *alfilt{LookupFilter(device, filter)}; if(!alfilt) @@ -512,8 +510,8 @@ AL_API DECL_FUNC3(void, alGetFilteri, ALuint,filter, ALenum,param, ALint*,value) FORCE_ALIGN void AL_APIENTRY alGetFilteriDirect(ALCcontext *context, ALuint filter, ALenum param, ALint *value) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard filterlock{device->FilterLock}; + auto *device = context->mALDevice.get(); + auto filterlock = std::lock_guard{device->FilterLock}; const ALfilter *alfilt{LookupFilter(device, filter)}; if(!alfilt) @@ -545,8 +543,8 @@ try { return; } - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard filterlock{device->FilterLock}; + auto *device = context->mALDevice.get(); + auto filterlock = std::lock_guard{device->FilterLock}; const ALfilter *alfilt{LookupFilter(device, filter)}; if(!alfilt) @@ -564,8 +562,8 @@ AL_API DECL_FUNC3(void, alGetFilterf, ALuint,filter, ALenum,param, ALfloat*,valu FORCE_ALIGN void AL_APIENTRY alGetFilterfDirect(ALCcontext *context, ALuint filter, ALenum param, ALfloat *value) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard filterlock{device->FilterLock}; + auto *device = context->mALDevice.get(); + auto filterlock = std::lock_guard{device->FilterLock}; const ALfilter *alfilt{LookupFilter(device, filter)}; if(!alfilt) UNLIKELY @@ -583,8 +581,8 @@ AL_API DECL_FUNC3(void, alGetFilterfv, ALuint,filter, ALenum,param, ALfloat*,val FORCE_ALIGN void AL_APIENTRY alGetFilterfvDirect(ALCcontext *context, ALuint filter, ALenum param, ALfloat *values) noexcept try { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard filterlock{device->FilterLock}; + auto *device = context->mALDevice.get(); + auto filterlock = std::lock_guard{device->FilterLock}; const ALfilter *alfilt{LookupFilter(device, filter)}; if(!alfilt) UNLIKELY @@ -601,8 +599,8 @@ catch(al::context_error& e) { void ALfilter::SetName(ALCcontext *context, ALuint id, std::string_view name) { - ALCdevice *device{context->mALDevice.get()}; - std::lock_guard filterlock{device->FilterLock}; + auto *device = context->mALDevice.get(); + auto filterlock = std::lock_guard{device->FilterLock}; auto filter = LookupFilter(device, id); if(!filter) diff --git a/al/source.cpp b/al/source.cpp index f47692fe2..383ec01df 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -32,14 +32,12 @@ #include #include #include -#include #include #include #include #include #include #include -#include #include #include #include @@ -203,7 +201,7 @@ void UpdateSourceProps(const ALsource *source, Voice *voice, ALCcontext *context */ int64_t GetSourceSampleOffset(ALsource *Source, ALCcontext *context, nanoseconds *clocktime) { - ALCdevice *device{context->mALDevice.get()}; + auto *device = context->mALDevice.get(); const VoiceBufferItem *Current{}; int64_t readPos{}; uint refcount{}; @@ -243,7 +241,7 @@ int64_t GetSourceSampleOffset(ALsource *Source, ALCcontext *context, nanoseconds */ double GetSourceSecOffset(ALsource *Source, ALCcontext *context, nanoseconds *clocktime) { - ALCdevice *device{context->mALDevice.get()}; + auto *device = context->mALDevice.get(); const VoiceBufferItem *Current{}; int64_t readPos{}; uint refcount{}; @@ -293,7 +291,7 @@ double GetSourceSecOffset(ALsource *Source, ALCcontext *context, nanoseconds *cl template NOINLINE T GetSourceOffset(ALsource *Source, ALenum name, ALCcontext *context) { - ALCdevice *device{context->mALDevice.get()}; + auto *device = context->mALDevice.get(); const VoiceBufferItem *Current{}; int64_t readPos{}; uint readPosFrac{}; @@ -528,7 +526,7 @@ std::optional GetSampleOffset(std::deque &BufferLis void InitVoice(Voice *voice, ALsource *source, ALbufferQueueItem *BufferList, ALCcontext *context, - ALCdevice *device) + al::Device *device) { voice->mLoopBuffer.store(source->Looping ? &source->mQueue.front() : nullptr, std::memory_order_relaxed); @@ -579,7 +577,7 @@ VoiceChange *GetVoiceChanger(ALCcontext *ctx) void SendVoiceChanges(ALCcontext *ctx, VoiceChange *tail) { - ALCdevice *device{ctx->mALDevice.get()}; + auto *device = ctx->mALDevice.get(); VoiceChange *oldhead{ctx->mCurrentVoiceChange.load(std::memory_order_acquire)}; while(VoiceChange *next{oldhead->mNext.load(std::memory_order_relaxed)}) @@ -608,8 +606,8 @@ void SendVoiceChanges(ALCcontext *ctx, VoiceChange *tail) } -bool SetVoiceOffset(Voice *oldvoice, const VoicePos &vpos, ALsource *source, ALCcontext *context, - ALCdevice *device) +auto SetVoiceOffset(Voice *oldvoice, const VoicePos &vpos, ALsource *source, ALCcontext *context, + al::Device *device) -> bool { /* First, get a free voice to start at the new offset. */ auto voicelist = context->getVoicesSpan(); @@ -815,7 +813,7 @@ inline ALsource *LookupSource(ALCcontext *context, ALuint id) noexcept return al::to_address(sublist.Sources->begin() + slidx); } -auto LookupBuffer = [](ALCdevice *device, auto id) noexcept -> ALbuffer* +auto LookupBuffer = [](al::Device *device, auto id) noexcept -> ALbuffer* { const auto lidx{(id-1) >> 6}; const auto slidx{(id-1) & 0x3f}; @@ -828,7 +826,7 @@ auto LookupBuffer = [](ALCdevice *device, auto id) noexcept -> ALbuffer* return al::to_address(sublist.Buffers->begin() + static_cast(slidx)); }; -auto LookupFilter = [](ALCdevice *device, auto id) noexcept -> ALfilter* +auto LookupFilter = [](al::Device *device, auto id) noexcept -> ALfilter* { const auto lidx{(id-1) >> 6}; const auto slidx{(id-1) & 0x3f}; @@ -1437,7 +1435,7 @@ NOINLINE void SetProperty(ALsource *const Source, ALCcontext *const Context, con const al::span values) { auto [CheckSize, CheckValue] = GetCheckers(prop, values); - ALCdevice *device{Context->mALDevice.get()}; + auto *device = Context->mALDevice.get(); switch(prop) { @@ -2059,7 +2057,7 @@ NOINLINE void GetProperty(ALsource *const Source, ALCcontext *const Context, con { using std::chrono::duration_cast; auto CheckSize = GetSizeChecker(prop, values); - ALCdevice *device{Context->mALDevice.get()}; + auto *device = Context->mALDevice.get(); switch(prop) { @@ -2518,7 +2516,7 @@ NOINLINE void GetProperty(ALsource *const Source, ALCcontext *const Context, con void StartSources(ALCcontext *const context, const al::span srchandles, const nanoseconds start_time=nanoseconds::min()) { - ALCdevice *device{context->mALDevice.get()}; + auto *device = context->mALDevice.get(); /* If the device is disconnected, and voices stop on disconnect, go right * to stopped. */ @@ -2693,8 +2691,8 @@ try { throw al::context_error{AL_INVALID_VALUE, "Generating %d sources", n}; if(n <= 0) UNLIKELY return; - std::unique_lock srclock{context->mSourceLock}; - ALCdevice *device{context->mALDevice.get()}; + auto srclock = std::unique_lock{context->mSourceLock}; + auto *device = context->mALDevice.get(); const al::span sids{sources, static_cast(n)}; if(sids.size() > device->SourcesMax-context->mNumSources) @@ -3503,7 +3501,7 @@ try { throw al::context_error{AL_INVALID_OPERATION, "Queueing onto static source %u", src}; /* Check for a valid Buffer, for its frequency and format */ - ALCdevice *device{context->mALDevice.get()}; + auto *device = context->mALDevice.get(); ALbuffer *BufferFmt{nullptr}; for(auto &item : source->mQueue) { diff --git a/alc/alc.cpp b/alc/alc.cpp index 05d8dc55f..932b38d91 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -364,13 +364,13 @@ constexpr int alcEFXMajorVersion{1}; constexpr int alcEFXMinorVersion{0}; -using DeviceRef = al::intrusive_ptr; +using DeviceRef = al::intrusive_ptr; /************************************************ * Device lists ************************************************/ -std::vector DeviceList; +std::vector DeviceList; std::vector ContextList; std::recursive_mutex ListLock; @@ -1008,7 +1008,8 @@ constexpr std::array X71Downmix{ }; -std::unique_ptr CreateDeviceLimiter(const ALCdevice *device, const float threshold) +auto CreateDeviceLimiter(const al::Device *device, const float threshold) + -> std::unique_ptr { static constexpr bool AutoKnee{true}; static constexpr bool AutoAttack{true}; @@ -1035,7 +1036,7 @@ std::unique_ptr CreateDeviceLimiter(const ALCdevice *device, const f * to jump forward or back. Must not be called while the device is running/ * mixing. */ -inline void UpdateClockBase(ALCdevice *device) +inline void UpdateClockBase(al::Device *device) { const auto mixLock = device->getWriteMixLock(); @@ -1051,7 +1052,7 @@ inline void UpdateClockBase(ALCdevice *device) * Updates device parameters according to the attribute list (caller is * responsible for holding the list lock). */ -ALCenum UpdateDeviceParams(ALCdevice *device, const al::span attrList) +auto UpdateDeviceParams(al::Device *device, const al::span attrList) -> ALCenum { if(attrList.empty() && device->Type == DeviceType::Loopback) { @@ -1353,7 +1354,7 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const al::span attrList if(outmode != ALC_ANY_SOFT) { - using OutputMode = ALCdevice::OutputMode; + using OutputMode = al::Device::OutputMode; switch(OutputMode(outmode)) { case OutputMode::Any: break; @@ -1857,7 +1858,7 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const al::span attrList * Updates device parameters as above, and also first clears the disconnected * status, if set. */ -bool ResetDeviceParams(ALCdevice *device, const al::span attrList) +auto ResetDeviceParams(al::Device *device, const al::span attrList) -> bool { /* If the device was disconnected, reset it since we're opened anew. */ if(!device->Connected.load(std::memory_order_relaxed)) UNLIKELY @@ -1956,7 +1957,7 @@ ContextRef GetContextRef() noexcept return ContextRef{context}; } -void alcSetError(ALCdevice *device, ALCenum errorCode) +void alcSetError(al::Device *device, ALCenum errorCode) { WARN("Error generated on device %p, code 0x%04x\n", voidp{device}, errorCode); if(TrapALCError) @@ -2131,8 +2132,8 @@ ALC_API auto ALC_APIENTRY alcGetString(ALCdevice *Device, ALCenum param) noexcep return nullptr; } - -static size_t GetIntegerv(ALCdevice *device, ALCenum param, const al::span values) +namespace { +auto GetIntegerv(al::Device *device, ALCenum param, const al::span values) -> size_t { if(values.empty()) { @@ -2451,6 +2452,7 @@ static size_t GetIntegerv(ALCdevice *device, ALCenum param, const al::span } return 0; } +} // namespace ALC_API void ALC_APIENTRY alcGetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *values) noexcept { @@ -2478,7 +2480,7 @@ ALC_API void ALC_APIENTRY alcGetInteger64vSOFT(ALCdevice *device, ALCenum pname, return; } /* render device */ - auto NumAttrsForDevice = [](ALCdevice *aldev) noexcept -> size_t + auto NumAttrsForDevice = [](al::Device *aldev) noexcept -> size_t { if(aldev->Type == DeviceType::Loopback && aldev->FmtChans == DevFmtAmbi3D) return 41; @@ -2944,7 +2946,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) noexcep uint{DefaultSendCount} }; - DeviceRef device{new(std::nothrow) ALCdevice{DeviceType::Playback}}; + auto device = DeviceRef{new(std::nothrow) al::Device{DeviceType::Playback}}; if(!device) { WARN("Failed to create playback device handle\n"); @@ -3101,7 +3103,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, else TRACE("Opening default capture device\n"); - DeviceRef device{new(std::nothrow) ALCdevice{DeviceType::Capture}}; + auto device = DeviceRef{new(std::nothrow) al::Device{DeviceType::Capture}}; if(!device) { WARN("Failed to create capture device handle\n"); @@ -3285,7 +3287,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN uint{DefaultSendCount} }; - DeviceRef device{new(std::nothrow) ALCdevice{DeviceType::Loopback}}; + auto device = DeviceRef{new(std::nothrow) al::Device{DeviceType::Loopback}}; if(!device) { WARN("Failed to create loopback device handle\n"); @@ -3364,12 +3366,15 @@ ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device #endif ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffer, ALCsizei samples) noexcept { - if(!device || device->Type != DeviceType::Loopback) UNLIKELY - alcSetError(device, ALC_INVALID_DEVICE); + if(!device) UNLIKELY + return alcSetError(nullptr, ALC_INVALID_DEVICE); + auto aldev = static_cast(device); + if(aldev->Type != DeviceType::Loopback) UNLIKELY + alcSetError(aldev, ALC_INVALID_DEVICE); else if(samples < 0 || (samples > 0 && buffer == nullptr)) UNLIKELY - alcSetError(device, ALC_INVALID_VALUE); + alcSetError(aldev, ALC_INVALID_VALUE); else - device->renderSamples(buffer, static_cast(samples), device->channelsFromFmt()); + aldev->renderSamples(buffer, static_cast(samples), aldev->channelsFromFmt()); } diff --git a/alc/alu.h b/alc/alu.h index ef7ddd4c5..6da8d9174 100644 --- a/alc/alu.h +++ b/alc/alu.h @@ -11,6 +11,9 @@ struct EffectSlot; enum class StereoEncoding : std::uint8_t; +namespace al { +struct Device; +} // namespace al constexpr float GainMixMax{1000.0f}; /* +60dB */ @@ -31,7 +34,7 @@ void aluInit(CompatFlagBitset flags, const float nfcscale); * Set up the appropriate panning method and mixing method given the device * properties. */ -void aluInitRenderer(ALCdevice *device, int hrtf_id, std::optional stereomode); +void aluInitRenderer(al::Device *device, int hrtf_id, std::optional stereomode); void aluInitEffectPanning(EffectSlot *slot, ALCcontext *context); diff --git a/alc/context.cpp b/alc/context.cpp index 7bba18002..12740f189 100644 --- a/alc/context.cpp +++ b/alc/context.cpp @@ -119,7 +119,7 @@ thread_local ALCcontext::ThreadCtx ALCcontext::sThreadContext; ALeffect ALCcontext::sDefaultEffect; -ALCcontext::ALCcontext(al::intrusive_ptr device, ContextFlagBitset flags) +ALCcontext::ALCcontext(al::intrusive_ptr device, ContextFlagBitset flags) : ContextBase{device.get()}, mALDevice{std::move(device)}, mContextFlags{flags} { mDebugGroups.emplace_back(DebugSource::Other, 0, std::string{}); diff --git a/alc/context.h b/alc/context.h index 49398e4f8..e9d8db6ac 100644 --- a/alc/context.h +++ b/alc/context.h @@ -72,8 +72,12 @@ struct DebugLogEntry { }; +namespace al { +struct Device; +} // namespace al + struct ALCcontext final : public al::intrusive_ref, ContextBase { - const al::intrusive_ptr mALDevice; + const al::intrusive_ptr mALDevice; bool mPropsDirty{true}; bool mDeferUpdates{false}; @@ -122,7 +126,7 @@ struct ALCcontext final : public al::intrusive_ref, ContextBase { std::unordered_map mSourceNames; std::unordered_map mEffectSlotNames; - ALCcontext(al::intrusive_ptr device, ContextFlagBitset flags); + ALCcontext(al::intrusive_ptr device, ContextFlagBitset flags); ALCcontext(const ALCcontext&) = delete; ALCcontext& operator=(const ALCcontext&) = delete; ~ALCcontext() final; diff --git a/alc/device.cpp b/alc/device.cpp index 86fddcabd..64c339983 100644 --- a/alc/device.cpp +++ b/alc/device.cpp @@ -27,11 +27,12 @@ using voidp = void*; } // namespace +namespace al { -ALCdevice::ALCdevice(DeviceType type) : DeviceBase{type} +Device::Device(DeviceType type) : DeviceBase{type} { } -ALCdevice::~ALCdevice() +Device::~Device() { TRACE("Freeing device %p\n", voidp{this}); @@ -56,7 +57,7 @@ ALCdevice::~ALCdevice() WARN("%zu Filter%s not deleted\n", count, (count==1)?"":"s"); } -void ALCdevice::enumerateHrtfs() +void Device::enumerateHrtfs() { mHrtfList = EnumerateHrtf(configValue({}, "hrtf-paths")); if(auto defhrtfopt = configValue({}, "default-hrtf")) @@ -69,7 +70,7 @@ void ALCdevice::enumerateHrtfs() } } -auto ALCdevice::getOutputMode1() const noexcept -> OutputMode1 +auto Device::getOutputMode1() const noexcept -> OutputMode1 { if(mContexts.load(std::memory_order_relaxed)->empty()) return OutputMode1::Any; @@ -95,3 +96,5 @@ auto ALCdevice::getOutputMode1() const noexcept -> OutputMode1 } return OutputMode1::Any; } + +} // namespace al diff --git a/alc/device.h b/alc/device.h index f80c5e147..32e587c44 100644 --- a/alc/device.h +++ b/alc/device.h @@ -32,7 +32,11 @@ struct FilterSubList; using uint = unsigned int; -struct ALCdevice final : public al::intrusive_ref, DeviceBase { +struct ALCdevice { }; + +namespace al { + +struct Device final : public ALCdevice, al::intrusive_ref, DeviceBase { /* This lock protects the device state (format, update size, etc) from * being from being changed in multiple threads, or being accessed while * being changed. It's also used to serialize calls to the backend. @@ -95,35 +99,37 @@ struct ALCdevice final : public al::intrusive_ref, DeviceBase { std::string mVersionOverride; std::string mRendererOverride; - ALCdevice(DeviceType type); - ~ALCdevice(); + Device(DeviceType type); + ~Device(); void enumerateHrtfs(); bool getConfigValueBool(const std::string_view block, const std::string_view key, bool def) { return GetConfigValueBool(mDeviceName, block, key, def); } - template - inline std::optional configValue(const std::string_view block, const std::string_view key) = delete; + template inline + auto configValue(const std::string_view block, const std::string_view key) -> std::optional = delete; }; -template<> -inline std::optional ALCdevice::configValue(const std::string_view block, const std::string_view key) +template<> inline +auto Device::configValue(const std::string_view block, const std::string_view key) -> std::optional { return ConfigValueStr(mDeviceName, block, key); } -template<> -inline std::optional ALCdevice::configValue(const std::string_view block, const std::string_view key) +template<> inline +auto Device::configValue(const std::string_view block, const std::string_view key) -> std::optional { return ConfigValueInt(mDeviceName, block, key); } -template<> -inline std::optional ALCdevice::configValue(const std::string_view block, const std::string_view key) +template<> inline +auto Device::configValue(const std::string_view block, const std::string_view key) -> std::optional { return ConfigValueUInt(mDeviceName, block, key); } -template<> -inline std::optional ALCdevice::configValue(const std::string_view block, const std::string_view key) +template<> inline +auto Device::configValue(const std::string_view block, const std::string_view key) -> std::optional { return ConfigValueFloat(mDeviceName, block, key); } -template<> -inline std::optional ALCdevice::configValue(const std::string_view block, const std::string_view key) +template<> inline +auto Device::configValue(const std::string_view block, const std::string_view key) -> std::optional { return ConfigValueBool(mDeviceName, block, key); } +} // namespace al + /** Stores the latest ALC device error. */ -void alcSetError(ALCdevice *device, ALCenum errorCode); +void alcSetError(al::Device *device, ALCenum errorCode); #endif diff --git a/alc/panning.cpp b/alc/panning.cpp index 40a71295e..f144186cb 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -161,7 +161,7 @@ std::unique_ptr CreateStablizer(const size_t outchans, const uin return stablizer; } -void AllocChannels(ALCdevice *device, const size_t main_chans, const size_t real_chans) +void AllocChannels(al::Device *device, const size_t main_chans, const size_t real_chans) { TRACE("Channel config, Main: %zu, Real: %zu\n", main_chans, real_chans); @@ -260,7 +260,8 @@ struct DecoderConfig { using DecoderView = DecoderConfig; -void InitNearFieldCtrl(ALCdevice *device, const float ctrl_dist, const uint order, const bool is3d) +void InitNearFieldCtrl(al::Device *device, const float ctrl_dist, const uint order, + const bool is3d) { static const std::array chans_per_order2d{{1, 2, 2, 2}}; static const std::array chans_per_order3d{{1, 3, 5, 7}}; @@ -281,7 +282,7 @@ void InitNearFieldCtrl(ALCdevice *device, const float ctrl_dist, const uint orde std::fill(iter, device->NumChannelsPerOrder.end(), 0u); } -void InitDistanceComp(ALCdevice *device, const al::span channels, +void InitDistanceComp(al::Device *device, const al::span channels, const al::span dists) { const float maxdist{std::accumulate(dists.begin(), dists.end(), 0.0f, @@ -366,8 +367,8 @@ constexpr auto GetAmbiLayout(DevAmbiLayout layouttype) noexcept } -DecoderView MakeDecoderView(ALCdevice *device, const AmbDecConf *conf, - DecoderConfig &decoder) +auto MakeDecoderView(al::Device *device, const AmbDecConf *conf, + DecoderConfig &decoder) -> DecoderView { DecoderView ret{}; @@ -670,7 +671,7 @@ constexpr DecoderConfig X7144Config{ }} }; -void InitPanning(ALCdevice *device, const bool hqdec=false, const bool stablize=false, +void InitPanning(al::Device *device, const bool hqdec=false, const bool stablize=false, DecoderView decoder={}) { if(!decoder) @@ -795,7 +796,7 @@ void InitPanning(ALCdevice *device, const bool hqdec=false, const bool stablize= device->mXOverFreq/static_cast(device->Frequency), std::move(stablizer)); } -void InitHrtfPanning(ALCdevice *device) +void InitHrtfPanning(al::Device *device) { static constexpr float Deg180{al::numbers::pi_v}; static constexpr float Deg_90{Deg180 / 2.0f /* 90 degrees*/}; @@ -1007,7 +1008,7 @@ void InitHrtfPanning(ALCdevice *device) InitNearFieldCtrl(device, Hrtf->mFields[0].distance, ambi_order, true); } -void InitUhjPanning(ALCdevice *device) +void InitUhjPanning(al::Device *device) { /* UHJ is always 2D first-order. */ static constexpr size_t count{Ambi2DChannelsFromOrder(1)}; @@ -1024,7 +1025,7 @@ void InitUhjPanning(ALCdevice *device) } // namespace -void aluInitRenderer(ALCdevice *device, int hrtf_id, std::optional stereomode) +void aluInitRenderer(al::Device *device, int hrtf_id, std::optional stereomode) { /* Hold the HRTF the device last used, in case it's used again. */ HrtfStorePtr old_hrtf{std::move(device->mHrtf)}; @@ -1137,8 +1138,8 @@ void aluInitRenderer(ALCdevice *device, int hrtf_id, std::optionalAmbiDecoder.get()}) { - device->PostProcess = ambidec->hasStablizer() ? &ALCdevice::ProcessAmbiDecStablized - : &ALCdevice::ProcessAmbiDec; + device->PostProcess = ambidec->hasStablizer() ? &al::Device::ProcessAmbiDecStablized + : &al::Device::ProcessAmbiDec; } return; } @@ -1189,7 +1190,7 @@ void aluInitRenderer(ALCdevice *device, int hrtf_id, std::optionalPostProcess = &ALCdevice::ProcessHrtf; + device->PostProcess = &al::Device::ProcessHrtf; device->mHrtfStatus = ALC_HRTF_ENABLED_SOFT; return; } @@ -1218,7 +1219,7 @@ void aluInitRenderer(ALCdevice *device, int hrtf_id, std::optionalPostProcess = &ALCdevice::ProcessUhj; + device->PostProcess = &al::Device::ProcessUhj; return; } @@ -1234,7 +1235,7 @@ void aluInitRenderer(ALCdevice *device, int hrtf_id, std::optionalBs2b = std::move(bs2b); TRACE("BS2B enabled\n"); InitPanning(device); - device->PostProcess = &ALCdevice::ProcessBs2b; + device->PostProcess = &al::Device::ProcessBs2b; return; } } @@ -1242,7 +1243,7 @@ void aluInitRenderer(ALCdevice *device, int hrtf_id, std::optionalPostProcess = &ALCdevice::ProcessAmbiDec; + device->PostProcess = &al::Device::ProcessAmbiDec; }