From 145bf52b7a6b4c1bc4738deb3d04d8cf8ee6743c Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 1 Jan 2018 01:11:11 -0800 Subject: Use a less-intense memory order to check for quitting --- examples/alffplay.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'examples/alffplay.cpp') diff --git a/examples/alffplay.cpp b/examples/alffplay.cpp index e7df67ee..68e101a0 100644 --- a/examples/alffplay.cpp +++ b/examples/alffplay.cpp @@ -388,7 +388,7 @@ int AudioState::getSync() int AudioState::decodeFrame() { - while(!mMovie.mQuit.load()) + while(!mMovie.mQuit.load(std::memory_order_relaxed)) { std::unique_lock lock(mQueueMtx); int ret = avcodec_receive_frame(mCodecCtx, mDecodedFrame); @@ -685,7 +685,7 @@ int AudioState::handler() if(do_direct_out) alSourcei(mSource, AL_DIRECT_CHANNELS_SOFT, AL_TRUE); - while(alGetError() == AL_NO_ERROR && !mMovie.mQuit.load()) + while(alGetError() == AL_NO_ERROR && !mMovie.mQuit.load(std::memory_order_relaxed)) { /* First remove any processed buffers. */ ALint processed; @@ -1005,11 +1005,11 @@ int VideoState::queuePicture(std::chrono::nanoseconds pts) { /* Wait until we have space for a new pic */ std::unique_lock lock(mPictQMutex); - while(mPictQSize >= mPictQ.size() && !mMovie.mQuit.load()) + while(mPictQSize >= mPictQ.size() && !mMovie.mQuit.load(std::memory_order_relaxed)) mPictQCond.wait(lock); lock.unlock(); - if(mMovie.mQuit.load()) + if(mMovie.mQuit.load(std::memory_order_relaxed)) return -1; Picture *vp = &mPictQ[mPictQWrite]; @@ -1023,9 +1023,9 @@ int VideoState::queuePicture(std::chrono::nanoseconds pts) /* Wait until the picture is updated. */ lock.lock(); - while(!vp->mUpdated && !mMovie.mQuit.load()) + while(!vp->mUpdated && !mMovie.mQuit.load(std::memory_order_relaxed)) mPictQCond.wait(lock); - if(mMovie.mQuit.load()) + if(mMovie.mQuit.load(std::memory_order_relaxed)) return -1; vp->mPts = pts; @@ -1056,7 +1056,7 @@ std::chrono::nanoseconds VideoState::synchronize(std::chrono::nanoseconds pts) int VideoState::handler() { mDecodedFrame = av_frame_alloc(); - while(!mMovie.mQuit) + while(!mMovie.mQuit.load(std::memory_order_relaxed)) { std::unique_lock lock(mQueueMtx); /* Decode video frame */ @@ -1096,7 +1096,7 @@ int VideoState::handler() av_frame_free(&mDecodedFrame); std::unique_lock lock(mPictQMutex); - if(mMovie.mQuit) + if(mMovie.mQuit.load(std::memory_order_relaxed)) { mPictQRead = 0; mPictQWrite = 0; @@ -1111,7 +1111,7 @@ int VideoState::handler() int MovieState::decode_interrupt_cb(void *ctx) { - return reinterpret_cast(ctx)->mQuit; + return reinterpret_cast(ctx)->mQuit.load(std::memory_order_relaxed); } bool MovieState::prepare() -- cgit v1.2.3