Make FlexfecReceiveStreamImpl::started_ into std::atomic<bool>

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}
This commit is contained in:
eladalon 2017-08-02 07:17:04 -07:00 committed by Commit Bot
parent a1eef11516
commit 3d4c28778e
2 changed files with 6 additions and 11 deletions

View File

@ -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

View File

@ -11,6 +11,7 @@
#ifndef WEBRTC_CALL_FLEXFEC_RECEIVE_STREAM_IMPL_H_
#define WEBRTC_CALL_FLEXFEC_RECEIVE_STREAM_IMPL_H_
#include <atomic>
#include <memory>
#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<bool> started_;
// Erasure code interfacing.
const std::unique_ptr<FlexfecReceiver> receiver_;