Skip to content

Commit

Permalink
Separate ALCdevice from the implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
kcat committed Nov 18, 2024
1 parent c204b31 commit 290fb4e
Show file tree
Hide file tree
Showing 14 changed files with 228 additions and 213 deletions.
21 changes: 10 additions & 11 deletions al/auxeffectslot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <mutex>
#include <numeric>
#include <stdexcept>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
Expand Down Expand Up @@ -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};
Expand All @@ -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};
Expand Down Expand Up @@ -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<std::mutex> 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<ALuint>(n)};
if(eids.size() > device->AuxiliaryEffectSlotMax-context->mNumEffectSlots)
Expand Down Expand Up @@ -482,9 +481,9 @@ try {
{
case AL_EFFECTSLOT_EFFECT:
{
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> effectlock{device->EffectLock};
ALeffect *effect{value ? LookupEffect(device, static_cast<ALuint>(value)) : nullptr};
auto *device = context->mALDevice.get();
auto effectlock = std::lock_guard{device->EffectLock};
auto *effect = value ? LookupEffect(device, static_cast<ALuint>(value)) : nullptr;
if(effect)
err = slot->initEffect(effect->id, effect->type, effect->Props, context);
else
Expand Down Expand Up @@ -569,7 +568,7 @@ try {
assert(factory);
al::intrusive_ptr<EffectState> state{factory->create()};

ALCdevice *device{context->mALDevice.get()};
auto *device = context->mALDevice.get();
auto bufferlock = std::unique_lock{device->BufferLock};
ALbuffer *buffer{};
if(value)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -895,7 +894,7 @@ ALenum ALeffectslot::initEffect(ALuint effectId, ALenum effectType, const Effect
}
al::intrusive_ptr<EffectState> state{factory->create()};

ALCdevice *device{context->mALDevice.get()};
auto *device = context->mALDevice.get();
state->mOutTarget = device->Dry.Buffer;
{
FPUCtl mixer_mode{};
Expand Down
Loading

0 comments on commit 290fb4e

Please sign in to comment.