From 3d4c28778e5f262ccc82f5ba4ebb671ca8496c7b Mon Sep 17 00:00:00 2001 From: eladalon Date: Wed, 2 Aug 2017 07:17:04 -0700 Subject: [PATCH] Make FlexfecReceiveStreamImpl::started_ into std::atomic FlexfecReceiveStreamImpl::crit_ was only protecting one boolean, so it's probably better to just make sure that boolean is atomic. BUG=None Review-Url: https://codereview.webrtc.org/2991533002 Cr-Commit-Position: refs/heads/master@{#19217} --- webrtc/call/flexfec_receive_stream_impl.cc | 13 ++++--------- webrtc/call/flexfec_receive_stream_impl.h | 4 ++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/webrtc/call/flexfec_receive_stream_impl.cc b/webrtc/call/flexfec_receive_stream_impl.cc index 16edadd803..ffb3455349 100644 --- a/webrtc/call/flexfec_receive_stream_impl.cc +++ b/webrtc/call/flexfec_receive_stream_impl.cc @@ -168,11 +168,8 @@ FlexfecReceiveStreamImpl::~FlexfecReceiveStreamImpl() { } void FlexfecReceiveStreamImpl::OnRtpPacket(const RtpPacketReceived& packet) { - { - rtc::CritScope cs(&crit_); - if (!started_) - return; - } + if (!started_.load()) + return; if (!receiver_) return; @@ -191,13 +188,11 @@ void FlexfecReceiveStreamImpl::OnRtpPacket(const RtpPacketReceived& packet) { } void FlexfecReceiveStreamImpl::Start() { - rtc::CritScope cs(&crit_); - started_ = true; + started_.store(true); } void FlexfecReceiveStreamImpl::Stop() { - rtc::CritScope cs(&crit_); - started_ = false; + started_.store(false); } // TODO(brandtr): Implement this member function when we have designed the diff --git a/webrtc/call/flexfec_receive_stream_impl.h b/webrtc/call/flexfec_receive_stream_impl.h index de5de4190c..d1c19ffc70 100644 --- a/webrtc/call/flexfec_receive_stream_impl.h +++ b/webrtc/call/flexfec_receive_stream_impl.h @@ -11,6 +11,7 @@ #ifndef WEBRTC_CALL_FLEXFEC_RECEIVE_STREAM_IMPL_H_ #define WEBRTC_CALL_FLEXFEC_RECEIVE_STREAM_IMPL_H_ +#include #include #include "webrtc/call/flexfec_receive_stream.h" @@ -52,8 +53,7 @@ class FlexfecReceiveStreamImpl : public FlexfecReceiveStream, private: // Config. const Config config_; - bool started_ GUARDED_BY(crit_); - rtc::CriticalSection crit_; + std::atomic started_; // Erasure code interfacing. const std::unique_ptr receiver_;