From 9f5c9a2260849240bd680b8fdf533acdef7f9de1 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 30 Dec 2018 21:38:42 -0800 Subject: Rename BackendLock to StateLock --- OpenAL32/Include/alMain.h | 6 +++++- OpenAL32/Include/alu.h | 2 +- OpenAL32/alAuxEffectSlot.cpp | 4 ++-- OpenAL32/alSource.cpp | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) (limited to 'OpenAL32') diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index e23eb1fb..5e53a047 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -785,7 +785,11 @@ struct ALCdevice_struct { // Contexts created on this device std::atomic ContextList{nullptr}; - std::mutex BackendLock; + /* 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. + */ + std::mutex StateLock; std::unique_ptr Backend; std::atomic next{nullptr}; diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index 7a378562..4fcc4c9c 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -478,7 +478,7 @@ void ComputePanGains(const ALeffectslot *slot, const ALfloat*RESTRICT coeffs, AL ALboolean MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, const ALsizei SamplesToDo); void aluMixData(ALCdevice *device, ALvoid *OutBuffer, ALsizei NumSamples); -/* Caller must lock the device, and the mixer must not be running. */ +/* Caller must lock the device state, and the mixer must not be running. */ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...) DECL_FORMAT(printf, 2, 3); extern MixerFunc MixSamples; diff --git a/OpenAL32/alAuxEffectSlot.cpp b/OpenAL32/alAuxEffectSlot.cpp index 1b3b97be..fc43edbe 100644 --- a/OpenAL32/alAuxEffectSlot.cpp +++ b/OpenAL32/alAuxEffectSlot.cpp @@ -556,12 +556,12 @@ ALenum InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect FPUCtl mixer_mode{}; ALCdevice *Device{Context->Device}; - std::unique_lock backlock{Device->BackendLock}; + std::unique_lock statelock{Device->StateLock}; State->mOutBuffer = Device->Dry.Buffer; State->mOutChannels = Device->Dry.NumChannels; if(State->deviceUpdate(Device) == AL_FALSE) { - backlock.unlock(); + statelock.unlock(); mixer_mode.leave(); State->DecRef(); return AL_OUT_OF_MEMORY; diff --git a/OpenAL32/alSource.cpp b/OpenAL32/alSource.cpp index 069d600b..a3428e02 100644 --- a/OpenAL32/alSource.cpp +++ b/OpenAL32/alSource.cpp @@ -1726,7 +1726,7 @@ ALboolean GetSourcedv(ALsource *Source, ALCcontext *Context, SourceProp prop, AL * clock time with the device latency. Order is important. */ values[0] = GetSourceSecOffset(Source, Context, &srcclock); - { std::lock_guard _{device->BackendLock}; + { std::lock_guard _{device->StateLock}; clocktime = GetClockLatency(device); } if(srcclock == clocktime.ClockTime) @@ -1989,7 +1989,7 @@ ALboolean GetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp prop, * clock time with the device latency. Order is important. */ values[0] = GetSourceSampleOffset(Source, Context, &srcclock); - { std::lock_guard _{device->BackendLock}; + { std::lock_guard _{device->StateLock}; clocktime = GetClockLatency(device); } if(srcclock == clocktime.ClockTime) -- cgit v1.2.3