remove more CriticalSectionWrappers.

BUG=webrtc:7035

Review-Url: https://codereview.webrtc.org/2779623002
Cr-Commit-Position: refs/heads/master@{#17392}
This commit is contained in:
kthelgason
2017-03-27 07:24:57 -07:00
committed by Commit bot
parent 1c07c70d88
commit d701dfdeef
14 changed files with 69 additions and 91 deletions

View File

@ -148,8 +148,8 @@ private:
bool LimitMixedAudio(AudioFrame* mixedAudio) const; bool LimitMixedAudio(AudioFrame* mixedAudio) const;
const rtc::CriticalSection _crit; rtc::CriticalSection _crit;
const rtc::CriticalSection _cbCrit; rtc::CriticalSection _cbCrit;
int32_t _id; int32_t _id;

View File

@ -33,8 +33,7 @@ struct MediaOptimization::EncodedFrameSample {
}; };
MediaOptimization::MediaOptimization(Clock* clock) MediaOptimization::MediaOptimization(Clock* clock)
: crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), : clock_(clock),
clock_(clock),
max_bit_rate_(0), max_bit_rate_(0),
codec_width_(0), codec_width_(0),
codec_height_(0), codec_height_(0),
@ -56,7 +55,7 @@ MediaOptimization::~MediaOptimization(void) {
} }
void MediaOptimization::Reset() { void MediaOptimization::Reset() {
CriticalSectionScoped lock(crit_sect_.get()); rtc::CritScope lock(&crit_sect_);
SetEncodingDataInternal(0, 0, 0, 0, 0, 0, max_payload_size_); SetEncodingDataInternal(0, 0, 0, 0, 0, 0, max_payload_size_);
memset(incoming_frame_times_, -1, sizeof(incoming_frame_times_)); memset(incoming_frame_times_, -1, sizeof(incoming_frame_times_));
incoming_frame_rate_ = 0.0; incoming_frame_rate_ = 0.0;
@ -79,7 +78,7 @@ void MediaOptimization::SetEncodingData(int32_t max_bit_rate,
uint32_t frame_rate, uint32_t frame_rate,
int num_layers, int num_layers,
int32_t mtu) { int32_t mtu) {
CriticalSectionScoped lock(crit_sect_.get()); rtc::CritScope lock(&crit_sect_);
SetEncodingDataInternal(max_bit_rate, frame_rate, target_bitrate, width, SetEncodingDataInternal(max_bit_rate, frame_rate, target_bitrate, width,
height, num_layers, mtu); height, num_layers, mtu);
} }
@ -107,7 +106,7 @@ void MediaOptimization::SetEncodingDataInternal(int32_t max_bit_rate,
} }
uint32_t MediaOptimization::SetTargetRates(uint32_t target_bitrate) { uint32_t MediaOptimization::SetTargetRates(uint32_t target_bitrate) {
CriticalSectionScoped lock(crit_sect_.get()); rtc::CritScope lock(&crit_sect_);
video_target_bitrate_ = target_bitrate; video_target_bitrate_ = target_bitrate;
@ -125,7 +124,7 @@ uint32_t MediaOptimization::SetTargetRates(uint32_t target_bitrate) {
} }
uint32_t MediaOptimization::InputFrameRate() { uint32_t MediaOptimization::InputFrameRate() {
CriticalSectionScoped lock(crit_sect_.get()); rtc::CritScope lock(&crit_sect_);
return InputFrameRateInternal(); return InputFrameRateInternal();
} }
@ -137,7 +136,7 @@ uint32_t MediaOptimization::InputFrameRateInternal() {
} }
uint32_t MediaOptimization::SentFrameRate() { uint32_t MediaOptimization::SentFrameRate() {
CriticalSectionScoped lock(crit_sect_.get()); rtc::CritScope lock(&crit_sect_);
return SentFrameRateInternal(); return SentFrameRateInternal();
} }
@ -148,7 +147,7 @@ uint32_t MediaOptimization::SentFrameRateInternal() {
} }
uint32_t MediaOptimization::SentBitRate() { uint32_t MediaOptimization::SentBitRate() {
CriticalSectionScoped lock(crit_sect_.get()); rtc::CritScope lock(&crit_sect_);
const int64_t now_ms = clock_->TimeInMilliseconds(); const int64_t now_ms = clock_->TimeInMilliseconds();
PurgeOldFrameSamples(now_ms); PurgeOldFrameSamples(now_ms);
UpdateSentBitrate(now_ms); UpdateSentBitrate(now_ms);
@ -159,7 +158,7 @@ int32_t MediaOptimization::UpdateWithEncodedData(
const EncodedImage& encoded_image) { const EncodedImage& encoded_image) {
size_t encoded_length = encoded_image._length; size_t encoded_length = encoded_image._length;
uint32_t timestamp = encoded_image._timeStamp; uint32_t timestamp = encoded_image._timeStamp;
CriticalSectionScoped lock(crit_sect_.get()); rtc::CritScope lock(&crit_sect_);
const int64_t now_ms = clock_->TimeInMilliseconds(); const int64_t now_ms = clock_->TimeInMilliseconds();
PurgeOldFrameSamples(now_ms); PurgeOldFrameSamples(now_ms);
if (encoded_frame_samples_.size() > 0 && if (encoded_frame_samples_.size() > 0 &&
@ -184,12 +183,12 @@ int32_t MediaOptimization::UpdateWithEncodedData(
} }
void MediaOptimization::EnableFrameDropper(bool enable) { void MediaOptimization::EnableFrameDropper(bool enable) {
CriticalSectionScoped lock(crit_sect_.get()); rtc::CritScope lock(&crit_sect_);
frame_dropper_->Enable(enable); frame_dropper_->Enable(enable);
} }
bool MediaOptimization::DropFrame() { bool MediaOptimization::DropFrame() {
CriticalSectionScoped lock(crit_sect_.get()); rtc::CritScope lock(&crit_sect_);
UpdateIncomingFrameRate(); UpdateIncomingFrameRate();
// Leak appropriate number of bytes. // Leak appropriate number of bytes.
frame_dropper_->Leak((uint32_t)(InputFrameRateInternal() + 0.5f)); frame_dropper_->Leak((uint32_t)(InputFrameRateInternal() + 0.5f));

View File

@ -101,7 +101,7 @@ class MediaOptimization {
uint32_t SentFrameRateInternal() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); uint32_t SentFrameRateInternal() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
// Protect all members. // Protect all members.
std::unique_ptr<CriticalSectionWrapper> crit_sect_; rtc::CriticalSection crit_sect_;
Clock* clock_ GUARDED_BY(crit_sect_); Clock* clock_ GUARDED_BY(crit_sect_);
int32_t max_bit_rate_ GUARDED_BY(crit_sect_); int32_t max_bit_rate_ GUARDED_BY(crit_sect_);

View File

@ -72,8 +72,7 @@ VCMReceiver::VCMReceiver(VCMTiming* timing,
std::unique_ptr<EventWrapper> jitter_buffer_event, std::unique_ptr<EventWrapper> jitter_buffer_event,
NackSender* nack_sender, NackSender* nack_sender,
KeyFrameRequestSender* keyframe_request_sender) KeyFrameRequestSender* keyframe_request_sender)
: crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), : clock_(clock),
clock_(clock),
jitter_buffer_(clock_, jitter_buffer_(clock_,
std::move(jitter_buffer_event), std::move(jitter_buffer_event),
nack_sender, nack_sender,
@ -86,11 +85,10 @@ VCMReceiver::VCMReceiver(VCMTiming* timing,
VCMReceiver::~VCMReceiver() { VCMReceiver::~VCMReceiver() {
render_wait_event_->Set(); render_wait_event_->Set();
delete crit_sect_;
} }
void VCMReceiver::Reset() { void VCMReceiver::Reset() {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
if (!jitter_buffer_.Running()) { if (!jitter_buffer_.Running()) {
jitter_buffer_.Start(); jitter_buffer_.Start();
} else { } else {
@ -242,7 +240,7 @@ void VCMReceiver::ReceiveStatistics(uint32_t* bitrate, uint32_t* framerate) {
void VCMReceiver::SetNackMode(VCMNackMode nackMode, void VCMReceiver::SetNackMode(VCMNackMode nackMode,
int64_t low_rtt_nack_threshold_ms, int64_t low_rtt_nack_threshold_ms,
int64_t high_rtt_nack_threshold_ms) { int64_t high_rtt_nack_threshold_ms) {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
// Default to always having NACK enabled in hybrid mode. // Default to always having NACK enabled in hybrid mode.
jitter_buffer_.SetNackMode(nackMode, low_rtt_nack_threshold_ms, jitter_buffer_.SetNackMode(nackMode, low_rtt_nack_threshold_ms,
high_rtt_nack_threshold_ms); high_rtt_nack_threshold_ms);
@ -256,7 +254,7 @@ void VCMReceiver::SetNackSettings(size_t max_nack_list_size,
} }
VCMNackMode VCMReceiver::NackMode() const { VCMNackMode VCMReceiver::NackMode() const {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
return jitter_buffer_.nack_mode(); return jitter_buffer_.nack_mode();
} }
@ -273,7 +271,7 @@ VCMDecodeErrorMode VCMReceiver::DecodeErrorMode() const {
} }
int VCMReceiver::SetMinReceiverDelay(int desired_delay_ms) { int VCMReceiver::SetMinReceiverDelay(int desired_delay_ms) {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
if (desired_delay_ms < 0 || desired_delay_ms > kMaxReceiverDelayMs) { if (desired_delay_ms < 0 || desired_delay_ms > kMaxReceiverDelayMs) {
return -1; return -1;
} }

View File

@ -14,10 +14,10 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "webrtc/base/criticalsection.h"
#include "webrtc/modules/video_coding/jitter_buffer.h" #include "webrtc/modules/video_coding/jitter_buffer.h"
#include "webrtc/modules/video_coding/packet.h" #include "webrtc/modules/video_coding/packet.h"
#include "webrtc/modules/video_coding/timing.h" #include "webrtc/modules/video_coding/timing.h"
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
#include "webrtc/modules/video_coding/include/video_coding.h" #include "webrtc/modules/video_coding/include/video_coding.h"
#include "webrtc/modules/video_coding/include/video_coding_defines.h" #include "webrtc/modules/video_coding/include/video_coding_defines.h"
@ -91,7 +91,7 @@ class VCMReceiver {
void TriggerDecoderShutdown(); void TriggerDecoderShutdown();
private: private:
CriticalSectionWrapper* crit_sect_; rtc::CriticalSection crit_sect_;
Clock* const clock_; Clock* const clock_;
VCMJitterBuffer jitter_buffer_; VCMJitterBuffer jitter_buffer_;
VCMTiming* timing_; VCMTiming* timing_;

View File

@ -21,22 +21,21 @@
namespace webrtc { namespace webrtc {
VCMTiming::VCMTiming(Clock* clock, VCMTiming* master_timing) VCMTiming::VCMTiming(Clock* clock, VCMTiming* master_timing)
: crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), : clock_(clock),
clock_(clock), master_(false),
master_(false), ts_extrapolator_(),
ts_extrapolator_(), codec_timer_(new VCMCodecTimer()),
codec_timer_(new VCMCodecTimer()), render_delay_ms_(kDefaultRenderDelayMs),
render_delay_ms_(kDefaultRenderDelayMs), min_playout_delay_ms_(0),
min_playout_delay_ms_(0), max_playout_delay_ms_(10000),
max_playout_delay_ms_(10000), jitter_delay_ms_(0),
jitter_delay_ms_(0), current_delay_ms_(0),
current_delay_ms_(0), last_decode_ms_(0),
last_decode_ms_(0), prev_frame_timestamp_(0),
prev_frame_timestamp_(0), num_decoded_frames_(0),
num_decoded_frames_(0), num_delayed_decoded_frames_(0),
num_delayed_decoded_frames_(0), first_decoded_frame_ms_(-1),
first_decoded_frame_ms_(-1), sum_missed_render_deadline_ms_(0) {
sum_missed_render_deadline_ms_(0) {
if (master_timing == NULL) { if (master_timing == NULL) {
master_ = true; master_ = true;
ts_extrapolator_ = new TimestampExtrapolator(clock_->TimeInMilliseconds()); ts_extrapolator_ = new TimestampExtrapolator(clock_->TimeInMilliseconds());
@ -50,11 +49,10 @@ VCMTiming::~VCMTiming() {
if (master_) { if (master_) {
delete ts_extrapolator_; delete ts_extrapolator_;
} }
delete crit_sect_;
} }
void VCMTiming::UpdateHistograms() const { void VCMTiming::UpdateHistograms() const {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
if (num_decoded_frames_ == 0) { if (num_decoded_frames_ == 0) {
return; return;
} }
@ -77,7 +75,7 @@ void VCMTiming::UpdateHistograms() const {
} }
void VCMTiming::Reset() { void VCMTiming::Reset() {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
ts_extrapolator_->Reset(clock_->TimeInMilliseconds()); ts_extrapolator_->Reset(clock_->TimeInMilliseconds());
codec_timer_.reset(new VCMCodecTimer()); codec_timer_.reset(new VCMCodecTimer());
render_delay_ms_ = kDefaultRenderDelayMs; render_delay_ms_ = kDefaultRenderDelayMs;
@ -88,37 +86,37 @@ void VCMTiming::Reset() {
} }
void VCMTiming::ResetDecodeTime() { void VCMTiming::ResetDecodeTime() {
CriticalSectionScoped lock(crit_sect_); rtc::CritScope cs(&crit_sect_);
codec_timer_.reset(new VCMCodecTimer()); codec_timer_.reset(new VCMCodecTimer());
} }
void VCMTiming::set_render_delay(int render_delay_ms) { void VCMTiming::set_render_delay(int render_delay_ms) {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
render_delay_ms_ = render_delay_ms; render_delay_ms_ = render_delay_ms;
} }
void VCMTiming::set_min_playout_delay(int min_playout_delay_ms) { void VCMTiming::set_min_playout_delay(int min_playout_delay_ms) {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
min_playout_delay_ms_ = min_playout_delay_ms; min_playout_delay_ms_ = min_playout_delay_ms;
} }
int VCMTiming::min_playout_delay() { int VCMTiming::min_playout_delay() {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
return min_playout_delay_ms_; return min_playout_delay_ms_;
} }
void VCMTiming::set_max_playout_delay(int max_playout_delay_ms) { void VCMTiming::set_max_playout_delay(int max_playout_delay_ms) {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
max_playout_delay_ms_ = max_playout_delay_ms; max_playout_delay_ms_ = max_playout_delay_ms;
} }
int VCMTiming::max_playout_delay() { int VCMTiming::max_playout_delay() {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
return max_playout_delay_ms_; return max_playout_delay_ms_;
} }
void VCMTiming::SetJitterDelay(int jitter_delay_ms) { void VCMTiming::SetJitterDelay(int jitter_delay_ms) {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
if (jitter_delay_ms != jitter_delay_ms_) { if (jitter_delay_ms != jitter_delay_ms_) {
jitter_delay_ms_ = jitter_delay_ms; jitter_delay_ms_ = jitter_delay_ms;
// When in initial state, set current delay to minimum delay. // When in initial state, set current delay to minimum delay.
@ -129,7 +127,7 @@ void VCMTiming::SetJitterDelay(int jitter_delay_ms) {
} }
void VCMTiming::UpdateCurrentDelay(uint32_t frame_timestamp) { void VCMTiming::UpdateCurrentDelay(uint32_t frame_timestamp) {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
int target_delay_ms = TargetDelayInternal(); int target_delay_ms = TargetDelayInternal();
if (current_delay_ms_ == 0) { if (current_delay_ms_ == 0) {
@ -171,7 +169,7 @@ void VCMTiming::UpdateCurrentDelay(uint32_t frame_timestamp) {
void VCMTiming::UpdateCurrentDelay(int64_t render_time_ms, void VCMTiming::UpdateCurrentDelay(int64_t render_time_ms,
int64_t actual_decode_time_ms) { int64_t actual_decode_time_ms) {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
uint32_t target_delay_ms = TargetDelayInternal(); uint32_t target_delay_ms = TargetDelayInternal();
int64_t delayed_ms = int64_t delayed_ms =
actual_decode_time_ms - actual_decode_time_ms -
@ -190,7 +188,7 @@ int32_t VCMTiming::StopDecodeTimer(uint32_t time_stamp,
int32_t decode_time_ms, int32_t decode_time_ms,
int64_t now_ms, int64_t now_ms,
int64_t render_time_ms) { int64_t render_time_ms) {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
codec_timer_->AddTiming(decode_time_ms, now_ms); codec_timer_->AddTiming(decode_time_ms, now_ms);
assert(decode_time_ms >= 0); assert(decode_time_ms >= 0);
last_decode_ms_ = decode_time_ms; last_decode_ms_ = decode_time_ms;
@ -209,13 +207,13 @@ int32_t VCMTiming::StopDecodeTimer(uint32_t time_stamp,
} }
void VCMTiming::IncomingTimestamp(uint32_t time_stamp, int64_t now_ms) { void VCMTiming::IncomingTimestamp(uint32_t time_stamp, int64_t now_ms) {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
ts_extrapolator_->Update(now_ms, time_stamp); ts_extrapolator_->Update(now_ms, time_stamp);
} }
int64_t VCMTiming::RenderTimeMs(uint32_t frame_timestamp, int64_t VCMTiming::RenderTimeMs(uint32_t frame_timestamp,
int64_t now_ms) const { int64_t now_ms) const {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
const int64_t render_time_ms = RenderTimeMsInternal(frame_timestamp, now_ms); const int64_t render_time_ms = RenderTimeMsInternal(frame_timestamp, now_ms);
return render_time_ms; return render_time_ms;
} }
@ -249,7 +247,7 @@ int VCMTiming::RequiredDecodeTimeMs() const {
uint32_t VCMTiming::MaxWaitingTime(int64_t render_time_ms, uint32_t VCMTiming::MaxWaitingTime(int64_t render_time_ms,
int64_t now_ms) const { int64_t now_ms) const {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
const int64_t max_wait_time_ms = const int64_t max_wait_time_ms =
render_time_ms - now_ms - RequiredDecodeTimeMs() - render_delay_ms_; render_time_ms - now_ms - RequiredDecodeTimeMs() - render_delay_ms_;
@ -262,7 +260,7 @@ uint32_t VCMTiming::MaxWaitingTime(int64_t render_time_ms,
bool VCMTiming::EnoughTimeToDecode( bool VCMTiming::EnoughTimeToDecode(
uint32_t available_processing_time_ms) const { uint32_t available_processing_time_ms) const {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
int64_t required_decode_time_ms = RequiredDecodeTimeMs(); int64_t required_decode_time_ms = RequiredDecodeTimeMs();
if (required_decode_time_ms < 0) { if (required_decode_time_ms < 0) {
// Haven't decoded any frames yet, try decoding one to get an estimate // Haven't decoded any frames yet, try decoding one to get an estimate
@ -279,7 +277,7 @@ bool VCMTiming::EnoughTimeToDecode(
} }
int VCMTiming::TargetVideoDelay() const { int VCMTiming::TargetVideoDelay() const {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
return TargetDelayInternal(); return TargetDelayInternal();
} }
@ -295,7 +293,7 @@ bool VCMTiming::GetTimings(int* decode_ms,
int* jitter_buffer_ms, int* jitter_buffer_ms,
int* min_playout_delay_ms, int* min_playout_delay_ms,
int* render_delay_ms) const { int* render_delay_ms) const {
CriticalSectionScoped cs(crit_sect_); rtc::CritScope cs(&crit_sect_);
*decode_ms = last_decode_ms_; *decode_ms = last_decode_ms_;
*max_decode_ms = RequiredDecodeTimeMs(); *max_decode_ms = RequiredDecodeTimeMs();
*current_delay_ms = current_delay_ms_; *current_delay_ms = current_delay_ms_;

View File

@ -13,9 +13,9 @@
#include <memory> #include <memory>
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/thread_annotations.h" #include "webrtc/base/thread_annotations.h"
#include "webrtc/modules/video_coding/codec_timer.h" #include "webrtc/modules/video_coding/codec_timer.h"
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
#include "webrtc/typedefs.h" #include "webrtc/typedefs.h"
namespace webrtc { namespace webrtc {
@ -114,7 +114,7 @@ class VCMTiming {
private: private:
void UpdateHistograms() const; void UpdateHistograms() const;
CriticalSectionWrapper* crit_sect_; rtc::CriticalSection crit_sect_;
Clock* const clock_; Clock* const clock_;
bool master_ GUARDED_BY(crit_sect_); bool master_ GUARDED_BY(crit_sect_);
TimestampExtrapolator* ts_extrapolator_ GUARDED_BY(crit_sect_); TimestampExtrapolator* ts_extrapolator_ GUARDED_BY(crit_sect_);

View File

@ -50,21 +50,19 @@ namespace {
// a register method all the way down to the function calling it. // a register method all the way down to the function calling it.
class EncodedImageCallbackWrapper : public EncodedImageCallback { class EncodedImageCallbackWrapper : public EncodedImageCallback {
public: public:
EncodedImageCallbackWrapper() EncodedImageCallbackWrapper() : callback_(nullptr) {}
: cs_(CriticalSectionWrapper::CreateCriticalSection()),
callback_(nullptr) {}
virtual ~EncodedImageCallbackWrapper() {} virtual ~EncodedImageCallbackWrapper() {}
void Register(EncodedImageCallback* callback) { void Register(EncodedImageCallback* callback) {
CriticalSectionScoped cs(cs_.get()); rtc::CritScope lock(&cs_);
callback_ = callback; callback_ = callback;
} }
virtual Result OnEncodedImage(const EncodedImage& encoded_image, virtual Result OnEncodedImage(const EncodedImage& encoded_image,
const CodecSpecificInfo* codec_specific_info, const CodecSpecificInfo* codec_specific_info,
const RTPFragmentationHeader* fragmentation) { const RTPFragmentationHeader* fragmentation) {
CriticalSectionScoped cs(cs_.get()); rtc::CritScope lock(&cs_);
if (callback_) { if (callback_) {
return callback_->OnEncodedImage(encoded_image, codec_specific_info, return callback_->OnEncodedImage(encoded_image, codec_specific_info,
fragmentation); fragmentation);
@ -73,7 +71,7 @@ class EncodedImageCallbackWrapper : public EncodedImageCallback {
} }
private: private:
std::unique_ptr<CriticalSectionWrapper> cs_; rtc::CriticalSection cs_;
EncodedImageCallback* callback_ GUARDED_BY(cs_); EncodedImageCallback* callback_ GUARDED_BY(cs_);
}; };

View File

@ -13,7 +13,7 @@
#include <assert.h> #include <assert.h>
#include "webrtc/system_wrappers/include/critical_section_wrapper.h" #include "webrtc/base/criticalsection.h"
#ifdef _WIN32 #ifdef _WIN32
#include "webrtc/system_wrappers/include/fix_interlocked_exchange_pointer_win.h" #include "webrtc/system_wrappers/include/fix_interlocked_exchange_pointer_win.h"
#endif #endif
@ -40,14 +40,8 @@ static T* GetStaticInstance(CountOperation count_operation) {
static T* volatile instance = NULL; static T* volatile instance = NULL;
CreateOperation state = kInstanceExists; CreateOperation state = kInstanceExists;
#ifndef _WIN32 #ifndef _WIN32
// This memory is staticly allocated once. The application does not try to rtc::CriticalSection crit_sect;
// free this memory. This approach is taken to avoid issues with rtc::CritScope lock(&crit_sect);
// destruction order for statically allocated memory. The memory will be
// reclaimed by the OS and memory leak tools will not recognize memory
// reachable from statics leaked so no noise is added by doing this.
static CriticalSectionWrapper* crit_sect(
CriticalSectionWrapper::CreateCriticalSection());
CriticalSectionScoped lock(crit_sect);
if (count_operation == if (count_operation ==
kAddRefNoCreate && instance_count == 0) { kAddRefNoCreate && instance_count == 0) {
@ -77,13 +71,13 @@ static T* GetStaticInstance(CountOperation count_operation) {
// since the thread owned by the tracing class also traces). // since the thread owned by the tracing class also traces).
// TODO(hellner): this is a bit out of place but here goes, de-couple // TODO(hellner): this is a bit out of place but here goes, de-couple
// thread implementation with trace implementation. // thread implementation with trace implementation.
crit_sect->Leave(); crit_sect.Leave();
if (old_instance) { if (old_instance) {
delete old_instance; delete old_instance;
} }
// Re-acquire the lock since the scoped critical section will release // Re-acquire the lock since the scoped critical section will release
// it. // it.
crit_sect->Enter(); crit_sect.Enter();
return NULL; return NULL;
} }
#else // _WIN32 #else // _WIN32

View File

@ -19,17 +19,12 @@
namespace webrtc { namespace webrtc {
TracePosix::TracePosix() TracePosix::TracePosix() {
: crit_sect_(*CriticalSectionWrapper::CreateCriticalSection()) {
struct timeval system_time_high_res; struct timeval system_time_high_res;
gettimeofday(&system_time_high_res, 0); gettimeofday(&system_time_high_res, 0);
prev_api_tick_count_ = prev_tick_count_ = system_time_high_res.tv_sec; prev_api_tick_count_ = prev_tick_count_ = system_time_high_res.tv_sec;
} }
TracePosix::~TracePosix() {
delete &crit_sect_;
}
int32_t TracePosix::AddTime(char* trace_message, const TraceLevel level) const { int32_t TracePosix::AddTime(char* trace_message, const TraceLevel level) const {
struct timeval system_time_high_res; struct timeval system_time_high_res;
if (gettimeofday(&system_time_high_res, 0) == -1) { if (gettimeofday(&system_time_high_res, 0) == -1) {
@ -42,7 +37,7 @@ int32_t TracePosix::AddTime(char* trace_message, const TraceLevel level) const {
const uint32_t ms_time = system_time_high_res.tv_usec / 1000; const uint32_t ms_time = system_time_high_res.tv_usec / 1000;
uint32_t prev_tickCount = 0; uint32_t prev_tickCount = 0;
{ {
CriticalSectionScoped lock(&crit_sect_); rtc::CritScope lock(&crit_sect_);
if (level == kTraceApiCall) { if (level == kTraceApiCall) {
prev_tickCount = prev_tick_count_; prev_tickCount = prev_tick_count_;
prev_tick_count_ = ms_time; prev_tick_count_ = ms_time;

View File

@ -11,7 +11,7 @@
#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_POSIX_H_ #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_POSIX_H_
#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_POSIX_H_ #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_TRACE_POSIX_H_
#include "webrtc/system_wrappers/include/critical_section_wrapper.h" #include "webrtc/base/criticalsection.h"
#include "webrtc/system_wrappers/source/trace_impl.h" #include "webrtc/system_wrappers/source/trace_impl.h"
namespace webrtc { namespace webrtc {
@ -19,7 +19,7 @@ namespace webrtc {
class TracePosix : public TraceImpl { class TracePosix : public TraceImpl {
public: public:
TracePosix(); TracePosix();
~TracePosix() override; ~TracePosix() override = default;
// This method can be called on several different threads different from // This method can be called on several different threads different from
// the creating thread. // the creating thread.
@ -31,7 +31,7 @@ class TracePosix : public TraceImpl {
volatile mutable uint32_t prev_api_tick_count_; volatile mutable uint32_t prev_api_tick_count_;
volatile mutable uint32_t prev_tick_count_; volatile mutable uint32_t prev_tick_count_;
CriticalSectionWrapper& crit_sect_; rtc::CriticalSection crit_sect_;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -24,7 +24,6 @@
namespace webrtc { namespace webrtc {
class Clock; class Clock;
class CriticalSectionWrapper;
class PacketReceiver; class PacketReceiver;
class NetworkPacket { class NetworkPacket {

View File

@ -21,7 +21,6 @@
namespace webrtc { namespace webrtc {
class CriticalSectionWrapper;
class EventTimerWrapper; class EventTimerWrapper;
namespace test { namespace test {

View File

@ -32,8 +32,6 @@ enum { MAX_AUDIO_BUFFER_IN_SAMPLES = 60 * 32 };
enum { MAX_AUDIO_BUFFER_IN_BYTES = MAX_AUDIO_BUFFER_IN_SAMPLES * 2 }; enum { MAX_AUDIO_BUFFER_IN_BYTES = MAX_AUDIO_BUFFER_IN_SAMPLES * 2 };
enum { kMaxAudioBufferQueueLength = 100 }; enum { kMaxAudioBufferQueueLength = 100 };
class CriticalSectionWrapper;
class FileRecorderImpl : public FileRecorder { class FileRecorderImpl : public FileRecorder {
public: public:
FileRecorderImpl(uint32_t instanceID, FileFormats fileFormat); FileRecorderImpl(uint32_t instanceID, FileFormats fileFormat);