diff options
Diffstat (limited to 'alc')
-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 |
13 files changed, 20 insertions, 23 deletions
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}; |