Change thread check to race check. Also, add comment to explain implementation of RaceChecker.
BUG=webrtc:6345 Review-Url: https://codereview.webrtc.org/2350663002 Cr-Commit-Position: refs/heads/master@{#14369}
This commit is contained in:
parent
f1b08da5b4
commit
347ec5c72e
@ -14,6 +14,14 @@ namespace rtc {
|
||||
|
||||
RaceChecker::RaceChecker() {}
|
||||
|
||||
// Note that the implementation here is in itself racy, but we pretend it does
|
||||
// not matter because we want this useful in release builds without having to
|
||||
// pay the cost of using atomics. A race hitting the race checker is likely to
|
||||
// cause access_count_ to diverge from zero and therefore cause the ThreadRef
|
||||
// comparison to fail, signaling a race, although it may not be in the exact
|
||||
// spot where a race *first* appeared in the code we're trying to protect. There
|
||||
// is also a chance that an actual race is missed, however the probability of
|
||||
// that has been considered small enough to be an acceptable trade off.
|
||||
bool RaceChecker::Acquire() const {
|
||||
const PlatformThreadRef current_thread = CurrentThreadRef();
|
||||
// Set new accessing thread if this is a new use.
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/helpers.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/race_checker.h"
|
||||
#include "webrtc/base/stringencode.h"
|
||||
#include "webrtc/base/stringutils.h"
|
||||
#include "webrtc/base/trace_event.h"
|
||||
@ -1155,7 +1156,6 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
|
||||
// TODO(solenberg): Once we're not using FakeWebRtcVoiceEngine anymore:
|
||||
// RTC_DCHECK(voe_audio_transport);
|
||||
RTC_DCHECK(call);
|
||||
audio_capture_thread_checker_.DetachFromThread();
|
||||
config_.rtp.ssrc = ssrc;
|
||||
config_.rtp.c_name = c_name;
|
||||
config_.voe_channel_id = ch;
|
||||
@ -1270,7 +1270,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
|
||||
int sample_rate,
|
||||
size_t number_of_channels,
|
||||
size_t number_of_frames) override {
|
||||
RTC_DCHECK(audio_capture_thread_checker_.CalledOnValidThread());
|
||||
RTC_CHECK_RUNS_SERIALIZED(&audio_capture_race_checker_);
|
||||
RTC_DCHECK(voe_audio_transport_);
|
||||
voe_audio_transport_->PushCaptureData(config_.voe_channel_id, audio_data,
|
||||
bits_per_sample, sample_rate,
|
||||
@ -1317,7 +1317,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
|
||||
}
|
||||
|
||||
rtc::ThreadChecker worker_thread_checker_;
|
||||
rtc::ThreadChecker audio_capture_thread_checker_;
|
||||
rtc::RaceChecker audio_capture_race_checker_;
|
||||
webrtc::AudioTransport* const voe_audio_transport_ = nullptr;
|
||||
webrtc::Call* call_ = nullptr;
|
||||
webrtc::AudioSendStream::Config config_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user