From 1bf50cb4f251cd3dcfa89ffbb5d07367301fa465 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 11 Oct 2017 17:29:12 -0700 Subject: [PATCH] Make a variable non-atomic It's only accessed while under a lock, which which ensures proper memory ordering. --- src/source.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/source.cpp b/src/source.cpp index e4300da..e788a77 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -39,7 +39,7 @@ class ALBufferStream { uint64_t mSamplePos; std::pair mLoopPts; - std::atomic mHasLooped; + bool mHasLooped; std::atomic mDone; public: @@ -71,7 +71,7 @@ public: if(!mDecoder->seek(pos)) return false; mSamplePos = pos; - mHasLooped.store(false, std::memory_order_relaxed); + mHasLooped = false; mDone.store(false, std::memory_order_release); return true; } @@ -111,7 +111,7 @@ public: int64_t getLoopStart() const { return mLoopPts.first; } int64_t getLoopEnd() const { return mLoopPts.second; } - bool hasLooped() const { return mHasLooped.load(std::memory_order_acquire); } + bool hasLooped() const { return mHasLooped; } bool hasMoreData() const { return !mDone.load(std::memory_order_acquire); } bool streamMoreData(ALuint srcid, bool loop) { @@ -139,7 +139,7 @@ public: if(!mDecoder->seek(mLoopPts.first)) break; mSamplePos = mLoopPts.first; - mHasLooped.store(true, std::memory_order_release); + mHasLooped = true; len = std::min(mUpdateLen-frames, mLoopPts.second-mLoopPts.first); ALuint got = mDecoder->read(&mData[frames*mFrameSize], len); -- 2.11.4.GIT