diff options
-rw-r--r-- | al/auxeffectslot.cpp | 10 | ||||
-rw-r--r-- | al/buffer.cpp | 40 | ||||
-rw-r--r-- | al/effect.cpp | 22 | ||||
-rw-r--r-- | al/event.cpp | 3 | ||||
-rw-r--r-- | al/filter.cpp | 22 | ||||
-rw-r--r-- | al/source.cpp | 32 | ||||
-rw-r--r-- | alc/alc.cpp | 13 | ||||
-rw-r--r-- | alc/alcontext.h | 4 | ||||
-rw-r--r-- | alc/alu.cpp | 6 | ||||
-rw-r--r-- | alc/effects/autowah.cpp | 2 | ||||
-rw-r--r-- | alc/effects/chorus.cpp | 2 | ||||
-rw-r--r-- | alc/effects/distortion.cpp | 2 | ||||
-rw-r--r-- | alc/effects/echo.cpp | 2 | ||||
-rw-r--r-- | alc/effects/equalizer.cpp | 2 | ||||
-rw-r--r-- | alc/effects/fshifter.cpp | 2 | ||||
-rw-r--r-- | alc/effects/modulator.cpp | 2 | ||||
-rw-r--r-- | alc/effects/reverb.cpp | 2 | ||||
-rw-r--r-- | alc/effects/vmorpher.cpp | 2 | ||||
-rw-r--r-- | alc/mixvoice.cpp | 2 |
19 files changed, 84 insertions, 88 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp index b4e93858..912765fc 100644 --- a/al/auxeffectslot.cpp +++ b/al/auxeffectslot.cpp @@ -114,7 +114,7 @@ void AddActiveEffectSlots(const ALuint *slotids, ALsizei count, ALCcontext *cont } curarray = context->mActiveAuxSlots.exchange(newarray, std::memory_order_acq_rel); - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; while((device->MixCount.load(std::memory_order_acquire)&1)) std::this_thread::yield(); delete curarray; @@ -150,7 +150,7 @@ void RemoveActiveEffectSlots(const ALuint *slotids, ALsizei count, ALCcontext *c } curarray = context->mActiveAuxSlots.exchange(newarray, std::memory_order_acq_rel); - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; while((device->MixCount.load(std::memory_order_acquire)&1)) std::this_thread::yield(); delete curarray; @@ -159,7 +159,7 @@ void RemoveActiveEffectSlots(const ALuint *slotids, ALsizei count, ALCcontext *c ALeffectslot *AllocEffectSlot(ALCcontext *context) { - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{context->mEffectSlotLock}; if(context->mNumEffectSlots >= device->AuxiliaryEffectSlotMax) { @@ -376,7 +376,7 @@ START_API_FUNC switch(param) { case AL_EFFECTSLOT_EFFECT: - device = context->mDevice; + device = context->mDevice.get(); { std::lock_guard<std::mutex> ___{device->EffectLock}; ALeffect *effect{value ? LookupEffect(device, value) : nullptr}; @@ -644,7 +644,7 @@ ALenum InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect if(!State) return AL_OUT_OF_MEMORY; FPUCtl mixer_mode{}; - ALCdevice *Device{Context->mDevice}; + ALCdevice *Device{Context->mDevice.get()}; std::unique_lock<std::mutex> statelock{Device->StateLock}; State->mOutTarget = Device->Dry.Buffer; if(State->deviceUpdate(Device) == AL_FALSE) diff --git a/al/buffer.cpp b/al/buffer.cpp index 173c76bd..a068399c 100644 --- a/al/buffer.cpp +++ b/al/buffer.cpp @@ -246,7 +246,7 @@ constexpr ALbitfieldSOFT INVALID_MAP_FLAGS{~unsigned(AL_MAP_READ_BIT_SOFT | AL_M ALbuffer *AllocBuffer(ALCcontext *context) { - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; auto sublist = std::find_if(device->BufferList.begin(), device->BufferList.end(), [](const BufferSubList &entry) noexcept -> bool @@ -656,7 +656,7 @@ START_API_FUNC if(UNLIKELY(n == 0)) return; - ALCdevice *device = context->mDevice; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; /* First try to find any buffers that are invalid or in-use. */ @@ -699,7 +699,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(LIKELY(context)) { - ALCdevice *device = context->mDevice; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; if(!buffer || LookupBuffer(device, buffer)) return AL_TRUE; @@ -720,7 +720,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device = context->mDevice; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); @@ -754,7 +754,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return nullptr; - ALCdevice *device = context->mDevice; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); @@ -806,7 +806,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device = context->mDevice; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); @@ -829,7 +829,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device = context->mDevice; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); @@ -861,7 +861,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device = context->mDevice; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); @@ -989,7 +989,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device = context->mDevice; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; if(UNLIKELY(LookupBuffer(device, buffer) == nullptr)) @@ -1009,7 +1009,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device = context->mDevice; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; if(UNLIKELY(LookupBuffer(device, buffer) == nullptr)) @@ -1028,7 +1028,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device = context->mDevice; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; if(UNLIKELY(LookupBuffer(device, buffer) == nullptr)) @@ -1050,7 +1050,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device = context->mDevice; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); @@ -1085,7 +1085,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device = context->mDevice; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; if(UNLIKELY(LookupBuffer(device, buffer) == nullptr)) @@ -1115,7 +1115,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device = context->mDevice; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); @@ -1153,7 +1153,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device = context->mDevice; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); @@ -1175,7 +1175,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device = context->mDevice; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; if(UNLIKELY(LookupBuffer(device, buffer) == nullptr)) @@ -1203,7 +1203,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device = context->mDevice; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; if(UNLIKELY(LookupBuffer(device, buffer) == nullptr)) @@ -1225,7 +1225,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device = context->mDevice; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); if(UNLIKELY(!albuf)) @@ -1270,7 +1270,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device = context->mDevice; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; if(UNLIKELY(LookupBuffer(device, buffer) == nullptr)) context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer); @@ -1305,7 +1305,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device = context->mDevice; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->BufferLock}; ALbuffer *albuf = LookupBuffer(device, buffer); if(UNLIKELY(!albuf)) diff --git a/al/effect.cpp b/al/effect.cpp index 2d72916e..15200a88 100644 --- a/al/effect.cpp +++ b/al/effect.cpp @@ -138,7 +138,7 @@ void InitEffectParams(ALeffect *effect, ALenum type) ALeffect *AllocEffect(ALCcontext *context) { - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; auto sublist = std::find_if(device->EffectList.begin(), device->EffectList.end(), [](const EffectSubList &entry) noexcept -> bool @@ -269,7 +269,7 @@ START_API_FUNC if(UNLIKELY(n == 0)) return; - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; /* First try to find any effects that are invalid. */ @@ -307,7 +307,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(LIKELY(context)) { - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; if(!effect || LookupEffect(device, effect)) return AL_TRUE; @@ -322,7 +322,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; ALeffect *aleffect{LookupEffect(device, effect)}; @@ -372,7 +372,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; ALeffect *aleffect{LookupEffect(device, effect)}; @@ -392,7 +392,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; ALeffect *aleffect{LookupEffect(device, effect)}; @@ -412,7 +412,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; ALeffect *aleffect{LookupEffect(device, effect)}; @@ -432,7 +432,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; const ALeffect *aleffect{LookupEffect(device, effect)}; @@ -464,7 +464,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; const ALeffect *aleffect{LookupEffect(device, effect)}; @@ -484,7 +484,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; const ALeffect *aleffect{LookupEffect(device, effect)}; @@ -504,7 +504,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->EffectLock}; const ALeffect *aleffect{LookupEffect(device, effect)}; diff --git a/al/event.cpp b/al/event.cpp index 75827b59..06a2e008 100644 --- a/al/event.cpp +++ b/al/event.cpp @@ -120,7 +120,6 @@ void StartEventThrd(ALCcontext *ctx) void StopEventThrd(ALCcontext *ctx) { - static constexpr AsyncEvent kill_evt{EventType_KillThread}; RingBuffer *ring{ctx->mAsyncEvents.get()}; auto evt_data = ring->getWriteVector().first; if(evt_data.len == 0) @@ -130,7 +129,7 @@ void StopEventThrd(ALCcontext *ctx) evt_data = ring->getWriteVector().first; } while(evt_data.len == 0); } - new (evt_data.buf) AsyncEvent{kill_evt}; + new (evt_data.buf) AsyncEvent{EventType_KillThread}; ring->writeAdvance(1); ctx->mEventSem.post(); diff --git a/al/filter.cpp b/al/filter.cpp index 5009daae..b52267f1 100644 --- a/al/filter.cpp +++ b/al/filter.cpp @@ -278,7 +278,7 @@ void InitFilterParams(ALfilter *filter, ALenum type) ALfilter *AllocFilter(ALCcontext *context) { - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; auto sublist = std::find_if(device->FilterList.begin(), device->FilterList.end(), [](const FilterSubList &entry) noexcept -> bool @@ -410,7 +410,7 @@ START_API_FUNC if(UNLIKELY(n == 0)) return; - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; /* First try to find any filters that are invalid. */ @@ -448,7 +448,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(LIKELY(context)) { - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; if(!filter || LookupFilter(device, filter)) return AL_TRUE; @@ -464,7 +464,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; ALfilter *alfilt{LookupFilter(device, filter)}; @@ -502,7 +502,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; ALfilter *alfilt{LookupFilter(device, filter)}; @@ -522,7 +522,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; ALfilter *alfilt{LookupFilter(device, filter)}; @@ -542,7 +542,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; ALfilter *alfilt{LookupFilter(device, filter)}; @@ -562,7 +562,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; ALfilter *alfilt{LookupFilter(device, filter)}; @@ -594,7 +594,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; ALfilter *alfilt{LookupFilter(device, filter)}; @@ -614,7 +614,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; ALfilter *alfilt{LookupFilter(device, filter)}; @@ -634,7 +634,7 @@ START_API_FUNC ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{device->FilterLock}; ALfilter *alfilt{LookupFilter(device, filter)}; diff --git a/al/source.cpp b/al/source.cpp index 1e0940de..5ba36524 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -175,7 +175,7 @@ void UpdateSourceProps(const ALsource *source, ALvoice *voice, ALCcontext *conte */ int64_t GetSourceSampleOffset(ALsource *Source, ALCcontext *context, std::chrono::nanoseconds *clocktime) { - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; const ALbufferlistitem *Current; uint64_t readPos; ALuint refcount; @@ -221,7 +221,7 @@ int64_t GetSourceSampleOffset(ALsource *Source, ALCcontext *context, std::chrono */ ALdouble GetSourceSecOffset(ALsource *Source, ALCcontext *context, std::chrono::nanoseconds *clocktime) { - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; const ALbufferlistitem *Current; uint64_t readPos; ALuint refcount; @@ -281,7 +281,7 @@ ALdouble GetSourceSecOffset(ALsource *Source, ALCcontext *context, std::chrono:: */ ALdouble GetSourceOffset(ALsource *Source, ALenum name, ALCcontext *context) { - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; const ALbufferlistitem *Current; ALuint readPos; ALsizei readPosFrac; @@ -483,7 +483,7 @@ ALboolean ApplyOffset(ALsource *Source, ALvoice *voice) ALsource *AllocSource(ALCcontext *context) { - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; std::lock_guard<std::mutex> _{context->mSourceLock}; if(context->mNumSources >= device->SourcesMax) { @@ -545,7 +545,7 @@ void FreeSource(ALCcontext *context, ALsource *source) ALsizei lidx = id >> 6; ALsizei slidx = id & 0x3f; - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; BackendUniqueLock backlock{*device->Backend}; if(ALvoice *voice{GetSourceVoice(source, context)}) { @@ -1126,7 +1126,7 @@ ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SourceProp prop, co if(IsPlayingOrPaused(Source)) { - ALCdevice *device{Context->mDevice}; + ALCdevice *device{Context->mDevice.get()}; BackendLockGuard _{*device->Backend}; /* Double-check that the source is still playing while we have * the lock. @@ -1230,7 +1230,7 @@ ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SourceProp prop, co ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, const ALint *values) { - ALCdevice *device{Context->mDevice}; + ALCdevice *device{Context->mDevice.get()}; ALbuffer *buffer{nullptr}; ALfilter *filter{nullptr}; ALeffectslot *slot{nullptr}; @@ -1346,7 +1346,7 @@ ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, co if(IsPlayingOrPaused(Source)) { - ALCdevice *device{Context->mDevice}; + ALCdevice *device{Context->mDevice.get()}; BackendLockGuard _{*device->Backend}; if(ALvoice *voice{GetSourceVoice(Source, Context)}) { @@ -1662,7 +1662,7 @@ ALboolean GetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp prop, ALboolean GetSourcedv(ALsource *Source, ALCcontext *Context, SourceProp prop, ALdouble *values) { - ALCdevice *device{Context->mDevice}; + ALCdevice *device{Context->mDevice.get()}; ClockLatency clocktime; std::chrono::nanoseconds srcclock; ALint ivals[3]; @@ -1995,7 +1995,7 @@ ALboolean GetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, AL ALboolean GetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp prop, ALint64SOFT *values) { - ALCdevice *device = Context->mDevice; + ALCdevice *device = Context->mDevice.get(); ClockLatency clocktime; std::chrono::nanoseconds srcclock; ALdouble dvals[6]; @@ -2780,7 +2780,7 @@ START_API_FUNC SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid source ID %u", sources[i]); } - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; BackendLockGuard __{*device->Backend}; /* If the device is disconnected, go right to stopped. */ if(UNLIKELY(!device->Connected.load(std::memory_order_acquire))) @@ -3041,7 +3041,7 @@ START_API_FUNC SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid source ID %u", sources[i]); } - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; BackendLockGuard __{*device->Backend}; auto pause_source = [&context](ALsource *source) -> void { @@ -3096,7 +3096,7 @@ START_API_FUNC SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid source ID %u", sources[i]); } - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; BackendLockGuard __{*device->Backend}; auto stop_source = [&context](ALsource *source) -> void { @@ -3158,7 +3158,7 @@ START_API_FUNC SETERR_RETURN(context, AL_INVALID_NAME,, "Invalid source ID %u", sources[i]); } - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; BackendLockGuard __{*device->Backend}; auto rewind_source = [&context](ALsource *source) -> void { @@ -3207,7 +3207,7 @@ START_API_FUNC SETERR_RETURN(context, AL_INVALID_OPERATION,, "Queueing onto static source %u", src); /* Check for a valid Buffer, for its frequency and format */ - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; ALbuffer *BufferFmt{nullptr}; ALbufferlistitem *BufferList{source->queue}; while(BufferList) @@ -3319,7 +3319,7 @@ START_API_FUNC SETERR_RETURN(context, AL_INVALID_OPERATION,, "Queueing onto static source %u", src); /* Check for a valid Buffer, for its frequency and format */ - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; ALbuffer *BufferFmt{nullptr}; ALbufferlistitem *BufferList{source->queue}; while(BufferList) diff --git a/alc/alc.cpp b/alc/alc.cpp index 6837d107..20776fba 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -2304,7 +2304,7 @@ static DeviceRef VerifyDevice(ALCdevice *device) } -ALCcontext::ALCcontext(ALCdevice *device) : mDevice{device} +ALCcontext::ALCcontext(al::intrusive_ptr<ALCdevice> device) : mDevice{std::move(device)} { mPropsClean.test_and_set(std::memory_order_relaxed); } @@ -2464,8 +2464,6 @@ ALCcontext::~ALCcontext() TRACE("Destructed %zu orphaned event%s\n", count, (count==1)?"":"s"); mAsyncEvents->readAdvance(count); } - - mDevice->release(); } /* ReleaseContext @@ -3346,9 +3344,6 @@ START_API_FUNC dev->LastError.store(ALC_NO_ERROR); - ContextRef context{new ALCcontext{dev.get()}}; - dev->add_ref(); - ALCenum err{UpdateDeviceParams(dev.get(), attrList)}; if(err != ALC_NO_ERROR) { @@ -3357,6 +3352,8 @@ START_API_FUNC aluHandleDisconnect(dev.get(), "Device update failure"); return nullptr; } + + ContextRef context{new ALCcontext{dev}}; context->allocVoices(256); if(DefaultEffect.type != AL_EFFECT_NULL && dev->Type == Playback) @@ -3461,7 +3458,7 @@ START_API_FUNC ContextRef ctx{std::move(*iter)}; ContextList.erase(iter); - ALCdevice *Device{ctx->mDevice}; + ALCdevice *Device{ctx->mDevice.get()}; std::lock_guard<std::mutex> _{Device->StateLock}; if(!ReleaseContext(ctx.get(), Device) && Device->Flags.get<DeviceRunning>()) @@ -3572,7 +3569,7 @@ START_API_FUNC alcSetError(nullptr, ALC_INVALID_CONTEXT); return nullptr; } - return ctx->mDevice; + return ctx->mDevice.get(); } END_API_FUNC diff --git a/alc/alcontext.h b/alc/alcontext.h index ebb70a79..c4f23dfb 100644 --- a/alc/alcontext.h +++ b/alc/alcontext.h @@ -144,13 +144,13 @@ struct ALCcontext : public al::intrusive_ref<ALCcontext> { /* Default effect slot */ std::unique_ptr<ALeffectslot> mDefaultSlot; - ALCdevice *const mDevice; + const al::intrusive_ptr<ALCdevice> mDevice; const ALCchar *mExtensionList{nullptr}; ALlistener mListener{}; - ALCcontext(ALCdevice *device); + ALCcontext(al::intrusive_ptr<ALCdevice> device); ALCcontext(const ALCcontext&) = delete; ALCcontext& operator=(const ALCcontext&) = delete; ~ALCcontext(); diff --git a/alc/alu.cpp b/alc/alu.cpp index 8d627b97..7d333fcb 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -409,7 +409,7 @@ bool CalcEffectSlotParams(ALeffectslot *slot, ALCcontext *context, bool force) output = EffectTarget{&target->Wet, nullptr}; else { - ALCdevice *device{context->mDevice}; + ALCdevice *device{context->mDevice.get()}; output = EffectTarget{&device->Dry, &device->RealOut}; } state->update(context, slot, &slot->Params.mEffectProps, output); @@ -950,7 +950,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo void CalcNonAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const ALCcontext *ALContext) { - const ALCdevice *Device{ALContext->mDevice}; + const ALCdevice *Device{ALContext->mDevice.get()}; ALeffectslot *SendSlots[MAX_SENDS]; voice->mDirect.Buffer = Device->Dry.Buffer; @@ -1004,7 +1004,7 @@ void CalcNonAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, cons void CalcAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const ALCcontext *ALContext) { - const ALCdevice *Device{ALContext->mDevice}; + const ALCdevice *Device{ALContext->mDevice.get()}; const ALsizei NumSends{Device->NumAuxSends}; const ALlistener &Listener = ALContext->mListener; diff --git a/alc/effects/autowah.cpp b/alc/effects/autowah.cpp index 1aac749e..f16c5ba5 100644 --- a/alc/effects/autowah.cpp +++ b/alc/effects/autowah.cpp @@ -106,7 +106,7 @@ ALboolean ALautowahState::deviceUpdate(const ALCdevice*) void ALautowahState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) { - const ALCdevice *device{context->mDevice}; + const ALCdevice *device{context->mDevice.get()}; const ALfloat ReleaseTime{clampf(props->Autowah.ReleaseTime, 0.001f, 1.0f)}; diff --git a/alc/effects/chorus.cpp b/alc/effects/chorus.cpp index 31f10c81..5966d3bd 100644 --- a/alc/effects/chorus.cpp +++ b/alc/effects/chorus.cpp @@ -157,7 +157,7 @@ void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, co /* The LFO depth is scaled to be relative to the sample delay. Clamp the * delay and depth to allow enough padding for resampling. */ - const ALCdevice *device{Context->mDevice}; + const ALCdevice *device{Context->mDevice.get()}; const auto frequency = static_cast<ALfloat>(device->Frequency); mDelay = maxi(float2int(props->Chorus.Delay*frequency*FRACTIONONE + 0.5f), mindelay); mDepth = minf(props->Chorus.Depth * mDelay, static_cast<ALfloat>(mDelay - mindelay)); diff --git a/alc/effects/distortion.cpp b/alc/effects/distortion.cpp index 3fd08229..ec1550f5 100644 --- a/alc/effects/distortion.cpp +++ b/alc/effects/distortion.cpp @@ -63,7 +63,7 @@ ALboolean DistortionState::deviceUpdate(const ALCdevice*) void DistortionState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) { - const ALCdevice *device{context->mDevice}; + const ALCdevice *device{context->mDevice.get()}; /* Store waveshaper edge settings. */ const ALfloat edge{ diff --git a/alc/effects/echo.cpp b/alc/effects/echo.cpp index d14db80c..d41c4f67 100644 --- a/alc/effects/echo.cpp +++ b/alc/effects/echo.cpp @@ -93,7 +93,7 @@ ALboolean EchoState::deviceUpdate(const ALCdevice *Device) void EchoState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) { - const ALCdevice *device = context->mDevice; + const ALCdevice *device{context->mDevice.get()}; const auto frequency = static_cast<ALfloat>(device->Frequency); mTap[0].delay = maxi(float2int(props->Echo.Delay*frequency + 0.5f), 1); diff --git a/alc/effects/equalizer.cpp b/alc/effects/equalizer.cpp index 4b900bcf..a8e81b37 100644 --- a/alc/effects/equalizer.cpp +++ b/alc/effects/equalizer.cpp @@ -111,7 +111,7 @@ ALboolean EqualizerState::deviceUpdate(const ALCdevice*) void EqualizerState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) { - const ALCdevice *device = context->mDevice; + const ALCdevice *device{context->mDevice.get()}; auto frequency = static_cast<ALfloat>(device->Frequency); ALfloat gain, f0norm; diff --git a/alc/effects/fshifter.cpp b/alc/effects/fshifter.cpp index bca29bba..a6c2c747 100644 --- a/alc/effects/fshifter.cpp +++ b/alc/effects/fshifter.cpp @@ -108,7 +108,7 @@ ALboolean FshifterState::deviceUpdate(const ALCdevice*) void FshifterState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) { - const ALCdevice *device{context->mDevice}; + const ALCdevice *device{context->mDevice.get()}; ALfloat step{props->Fshifter.Frequency / static_cast<ALfloat>(device->Frequency)}; mPhaseStep = fastf2i(minf(step, 0.5f) * FRACTIONONE); diff --git a/alc/effects/modulator.cpp b/alc/effects/modulator.cpp index d7118285..8a6378cd 100644 --- a/alc/effects/modulator.cpp +++ b/alc/effects/modulator.cpp @@ -109,7 +109,7 @@ ALboolean ModulatorState::deviceUpdate(const ALCdevice*) void ModulatorState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) { - const ALCdevice *device{context->mDevice}; + const ALCdevice *device{context->mDevice.get()}; const float step{props->Modulator.Frequency / static_cast<ALfloat>(device->Frequency)}; mStep = fastf2i(clampf(step*WAVEFORM_FRACONE, 0.0f, ALfloat{WAVEFORM_FRACONE-1})); diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp index 6e6844e0..51a57360 100644 --- a/alc/effects/reverb.cpp +++ b/alc/effects/reverb.cpp @@ -905,7 +905,7 @@ void ReverbState::update3DPanning(const ALfloat *ReflectionsPan, const ALfloat * void ReverbState::update(const ALCcontext *Context, const ALeffectslot *Slot, const EffectProps *props, const EffectTarget target) { - const ALCdevice *Device{Context->mDevice}; + const ALCdevice *Device{Context->mDevice.get()}; const ALlistener &Listener = Context->mListener; const auto frequency = static_cast<ALfloat>(Device->Frequency); diff --git a/alc/effects/vmorpher.cpp b/alc/effects/vmorpher.cpp index 95016105..ad0f026b 100644 --- a/alc/effects/vmorpher.cpp +++ b/alc/effects/vmorpher.cpp @@ -209,7 +209,7 @@ ALboolean VmorpherState::deviceUpdate(const ALCdevice* /*device*/) void VmorpherState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) { - const ALCdevice *device{context->mDevice}; + const ALCdevice *device{context->mDevice.get()}; const ALfloat frequency{static_cast<ALfloat>(device->Frequency)}; const ALfloat step{props->Vmorpher.Rate / static_cast<ALfloat>(device->Frequency)}; mStep = fastf2i(clampf(step*WAVEFORM_FRACONE, 0.0f, ALfloat{WAVEFORM_FRACONE-1})); diff --git a/alc/mixvoice.cpp b/alc/mixvoice.cpp index e2b2bf51..b1d7500a 100644 --- a/alc/mixvoice.cpp +++ b/alc/mixvoice.cpp @@ -540,7 +540,7 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc ASSUME(SampleSize > 0); ASSUME(increment > 0); - ALCdevice *Device{Context->mDevice}; + ALCdevice *Device{Context->mDevice.get()}; const ALsizei NumSends{Device->NumAuxSends}; const ALsizei IrSize{Device->mHrtf ? Device->mHrtf->irSize : 0}; |