Migrate pc/ to webrtc::Mutex.

Bug: webrtc:11567
Change-Id: I1adc22d2998966958750138e66108cf39a8c3d57
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178840
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31654}
This commit is contained in:
Markus Handell 2020-07-07 19:08:53 +02:00 committed by Commit Bot
parent 0eba415fb4
commit 6fcd0f8031
16 changed files with 88 additions and 81 deletions

View File

@ -116,6 +116,7 @@ rtc_library("rtc_pc_base") {
"../rtc_base:deprecation",
"../rtc_base:rtc_task_queue",
"../rtc_base:stringutils",
"../rtc_base/synchronization:mutex",
"../rtc_base/system:file_wrapper",
"../rtc_base/system:rtc_export",
"../rtc_base/third_party/base64",
@ -266,6 +267,7 @@ rtc_library("peerconnection") {
"../rtc_base:safe_minmax",
"../rtc_base:weak_ptr",
"../rtc_base/experiments:field_trial_parser",
"../rtc_base/synchronization:mutex",
"../rtc_base/system:file_wrapper",
"../rtc_base/system:rtc_export",
"../rtc_base/third_party/base64",
@ -496,6 +498,7 @@ if (rtc_include_tests) {
"../rtc_base:rtc_base_approved",
"../rtc_base:rtc_task_queue",
"../rtc_base:task_queue_for_test",
"../rtc_base/synchronization:mutex",
"../rtc_base/synchronization:sequence_checker",
"../rtc_base/task_utils:repeating_task",
"../rtc_base/third_party/sigslot",
@ -595,6 +598,7 @@ if (rtc_include_tests) {
"../rtc_base:gunit_helpers",
"../rtc_base:rtc_base_tests_utils",
"../rtc_base:rtc_json",
"../rtc_base/synchronization:mutex",
"../rtc_base/third_party/base64",
"../rtc_base/third_party/sigslot",
"../system_wrappers:metrics",

View File

@ -56,7 +56,7 @@ DtlsTransport::~DtlsTransport() {
}
DtlsTransportInformation DtlsTransport::Information() {
rtc::CritScope scope(&lock_);
MutexLock lock(&lock_);
return info_;
}
@ -85,7 +85,7 @@ void DtlsTransport::Clear() {
// into DtlsTransport, so we can't hold the lock while releasing.
std::unique_ptr<cricket::DtlsTransportInternal> transport_to_release;
{
rtc::CritScope scope(&lock_);
MutexLock lock(&lock_);
transport_to_release = std::move(internal_dtls_transport_);
ice_transport_->Clear();
}
@ -109,7 +109,7 @@ void DtlsTransport::OnInternalDtlsState(
void DtlsTransport::UpdateInformation() {
RTC_DCHECK_RUN_ON(owner_thread_);
rtc::CritScope scope(&lock_);
MutexLock lock(&lock_);
if (internal_dtls_transport_) {
if (internal_dtls_transport_->dtls_state() ==
cricket::DTLS_TRANSPORT_CONNECTED) {

View File

@ -17,6 +17,7 @@
#include "api/ice_transport_interface.h"
#include "api/scoped_refptr.h"
#include "p2p/base/dtls_transport.h"
#include "rtc_base/synchronization/mutex.h"
namespace webrtc {
@ -42,12 +43,12 @@ class DtlsTransport : public DtlsTransportInterface,
void Clear();
cricket::DtlsTransportInternal* internal() {
rtc::CritScope scope(&lock_);
MutexLock lock(&lock_);
return internal_dtls_transport_.get();
}
const cricket::DtlsTransportInternal* internal() const {
rtc::CritScope scope(&lock_);
MutexLock lock(&lock_);
return internal_dtls_transport_.get();
}
@ -61,7 +62,7 @@ class DtlsTransport : public DtlsTransportInterface,
DtlsTransportObserverInterface* observer_ = nullptr;
rtc::Thread* owner_thread_;
rtc::CriticalSection lock_;
mutable Mutex lock_;
DtlsTransportInformation info_ RTC_GUARDED_BY(lock_);
std::unique_ptr<cricket::DtlsTransportInternal> internal_dtls_transport_
RTC_GUARDED_BY(lock_);

View File

@ -127,7 +127,7 @@ void RemoteAudioSource::AddSink(AudioTrackSinkInterface* sink) {
return;
}
rtc::CritScope lock(&sink_lock_);
MutexLock lock(&sink_lock_);
RTC_DCHECK(!absl::c_linear_search(sinks_, sink));
sinks_.push_back(sink);
}
@ -136,13 +136,13 @@ void RemoteAudioSource::RemoveSink(AudioTrackSinkInterface* sink) {
RTC_DCHECK(main_thread_->IsCurrent());
RTC_DCHECK(sink);
rtc::CritScope lock(&sink_lock_);
MutexLock lock(&sink_lock_);
sinks_.remove(sink);
}
void RemoteAudioSource::OnData(const AudioSinkInterface::Data& audio) {
// Called on the externally-owned audio callback thread, via/from webrtc.
rtc::CritScope lock(&sink_lock_);
MutexLock lock(&sink_lock_);
for (auto* sink : sinks_) {
// When peerconnection acts as an audio source, it should not provide
// absolute capture timestamp.

View File

@ -18,8 +18,8 @@
#include "api/call/audio_sink.h"
#include "api/notifier.h"
#include "pc/channel.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/message_handler.h"
#include "rtc_base/synchronization/mutex.h"
namespace rtc {
struct Message;
@ -69,7 +69,7 @@ class RemoteAudioSource : public Notifier<AudioSourceInterface>,
rtc::Thread* const main_thread_;
rtc::Thread* const worker_thread_;
std::list<AudioObserver*> audio_observers_;
rtc::CriticalSection sink_lock_;
Mutex sink_lock_;
std::list<AudioTrackSinkInterface*> sinks_;
SourceState state_;
};

View File

@ -43,6 +43,7 @@
#include "rtc_base/gunit.h"
#include "rtc_base/logging.h"
#include "rtc_base/strings/json.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/time_utils.h"
using ::testing::AtLeast;
@ -3000,7 +3001,7 @@ class FakeRTCStatsCollector : public RTCStatsCollector,
void OnStatsDelivered(
const rtc::scoped_refptr<const RTCStatsReport>& report) override {
EXPECT_TRUE(signaling_thread_->IsCurrent());
rtc::CritScope cs(&lock_);
MutexLock lock(&lock_);
delivered_report_ = report;
}
@ -3011,7 +3012,7 @@ class FakeRTCStatsCollector : public RTCStatsCollector,
bool HasVerifiedResults() {
EXPECT_TRUE(signaling_thread_->IsCurrent());
rtc::CritScope cs(&lock_);
MutexLock lock(&lock_);
if (!delivered_report_)
return false;
EXPECT_EQ(produced_on_signaling_thread_, 1);
@ -3038,7 +3039,7 @@ class FakeRTCStatsCollector : public RTCStatsCollector,
RTCStatsReport* partial_report) override {
EXPECT_TRUE(signaling_thread_->IsCurrent());
{
rtc::CritScope cs(&lock_);
MutexLock lock(&lock_);
EXPECT_FALSE(delivered_report_);
++produced_on_signaling_thread_;
}
@ -3054,7 +3055,7 @@ class FakeRTCStatsCollector : public RTCStatsCollector,
RTCStatsReport* partial_report) override {
EXPECT_TRUE(network_thread_->IsCurrent());
{
rtc::CritScope cs(&lock_);
MutexLock lock(&lock_);
EXPECT_FALSE(delivered_report_);
++produced_on_network_thread_;
}
@ -3068,7 +3069,7 @@ class FakeRTCStatsCollector : public RTCStatsCollector,
rtc::Thread* const worker_thread_;
rtc::Thread* const network_thread_;
rtc::CriticalSection lock_;
Mutex lock_;
rtc::scoped_refptr<const RTCStatsReport> delivered_report_;
int produced_on_signaling_thread_ = 0;
int produced_on_network_thread_ = 0;

View File

@ -381,7 +381,7 @@ void RtpSenderBase::SetEncoderToPacketizerFrameTransformer(
LocalAudioSinkAdapter::LocalAudioSinkAdapter() : sink_(nullptr) {}
LocalAudioSinkAdapter::~LocalAudioSinkAdapter() {
rtc::CritScope lock(&lock_);
MutexLock lock(&lock_);
if (sink_)
sink_->OnClose();
}
@ -393,7 +393,7 @@ void LocalAudioSinkAdapter::OnData(
size_t number_of_channels,
size_t number_of_frames,
absl::optional<int64_t> absolute_capture_timestamp_ms) {
rtc::CritScope lock(&lock_);
MutexLock lock(&lock_);
if (sink_) {
sink_->OnData(audio_data, bits_per_sample, sample_rate, number_of_channels,
number_of_frames, absolute_capture_timestamp_ms);
@ -401,7 +401,7 @@ void LocalAudioSinkAdapter::OnData(
}
void LocalAudioSinkAdapter::SetSink(cricket::AudioSource::Sink* sink) {
rtc::CritScope lock(&lock_);
MutexLock lock(&lock_);
RTC_DCHECK(!sink || !sink_);
sink_ = sink;
}

View File

@ -24,7 +24,7 @@
#include "media/base/audio_source.h"
#include "media/base/media_channel.h"
#include "pc/dtmf_sender.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/synchronization/mutex.h"
namespace webrtc {
@ -237,7 +237,7 @@ class LocalAudioSinkAdapter : public AudioTrackSinkInterface,
cricket::AudioSource::Sink* sink_;
// Critical section protecting |sink_|.
rtc::CriticalSection lock_;
Mutex lock_;
};
class AudioRtpSender : public DtmfProviderInterface, public RtpSenderBase {

View File

@ -39,7 +39,7 @@ SctpTransport::~SctpTransport() {
}
SctpTransportInformation SctpTransport::Information() const {
rtc::CritScope scope(&lock_);
MutexLock lock(&lock_);
return info_;
}
@ -66,7 +66,7 @@ void SctpTransport::Clear() {
RTC_DCHECK_RUN_ON(owner_thread_);
RTC_DCHECK(internal());
{
rtc::CritScope scope(&lock_);
MutexLock lock(&lock_);
// Note that we delete internal_sctp_transport_, but
// only drop the reference to dtls_transport_.
dtls_transport_ = nullptr;
@ -80,7 +80,7 @@ void SctpTransport::SetDtlsTransport(
RTC_DCHECK_RUN_ON(owner_thread_);
SctpTransportState next_state;
{
rtc::CritScope scope(&lock_);
MutexLock lock(&lock_);
next_state = info_.state();
dtls_transport_ = transport;
if (internal_sctp_transport_) {
@ -103,7 +103,7 @@ void SctpTransport::Start(int local_port,
int remote_port,
int max_message_size) {
{
rtc::CritScope scope(&lock_);
MutexLock lock(&lock_);
// Record max message size on calling thread.
info_ = SctpTransportInformation(info_.state(), info_.dtls_transport(),
max_message_size, info_.MaxChannels());
@ -125,7 +125,7 @@ void SctpTransport::UpdateInformation(SctpTransportState state) {
bool must_send_update;
SctpTransportInformation info_copy(SctpTransportState::kNew);
{
rtc::CritScope scope(&lock_);
MutexLock lock(&lock_);
must_send_update = (state != info_.state());
// TODO(https://bugs.webrtc.org/10358): Update max channels from internal
// SCTP transport when available.
@ -149,7 +149,7 @@ void SctpTransport::UpdateInformation(SctpTransportState state) {
void SctpTransport::OnAssociationChangeCommunicationUp() {
RTC_DCHECK_RUN_ON(owner_thread_);
{
rtc::CritScope scope(&lock_);
MutexLock lock(&lock_);
RTC_DCHECK(internal_sctp_transport_);
if (internal_sctp_transport_->max_outbound_streams() &&
internal_sctp_transport_->max_inbound_streams()) {

View File

@ -17,6 +17,7 @@
#include "api/sctp_transport_interface.h"
#include "media/sctp/sctp_transport.h"
#include "pc/dtls_transport.h"
#include "rtc_base/synchronization/mutex.h"
namespace webrtc {
@ -47,12 +48,12 @@ class SctpTransport : public SctpTransportInterface,
// internal() to be functions on the webrtc::SctpTransport interface,
// and make the internal() function private.
cricket::SctpTransportInternal* internal() {
rtc::CritScope scope(&lock_);
MutexLock lock(&lock_);
return internal_sctp_transport_.get();
}
const cricket::SctpTransportInternal* internal() const {
rtc::CritScope scope(&lock_);
MutexLock lock(&lock_);
return internal_sctp_transport_.get();
}
@ -71,7 +72,7 @@ class SctpTransport : public SctpTransportInterface,
// Note - owner_thread never changes, but can't be const if we do
// Invoke() on it.
rtc::Thread* owner_thread_;
rtc::CriticalSection lock_;
mutable Mutex lock_;
// Variables accessible off-thread, guarded by lock_
SctpTransportInformation info_ RTC_GUARDED_BY(lock_);
std::unique_ptr<cricket::SctpTransportInternal> internal_sctp_transport_

View File

@ -67,7 +67,7 @@ rtc::scoped_refptr<FakeAudioCaptureModule> FakeAudioCaptureModule::Create() {
}
int FakeAudioCaptureModule::frames_received() const {
rtc::CritScope cs(&crit_);
webrtc::MutexLock lock(&mutex_);
return frames_received_;
}
@ -79,7 +79,7 @@ int32_t FakeAudioCaptureModule::ActiveAudioLayer(
int32_t FakeAudioCaptureModule::RegisterAudioCallback(
webrtc::AudioTransport* audio_callback) {
rtc::CritScope cs(&crit_);
webrtc::MutexLock lock(&mutex_);
audio_callback_ = audio_callback;
return 0;
}
@ -183,7 +183,7 @@ int32_t FakeAudioCaptureModule::StartPlayout() {
return -1;
}
{
rtc::CritScope cs(&crit_);
webrtc::MutexLock lock(&mutex_);
playing_ = true;
}
bool start = true;
@ -194,7 +194,7 @@ int32_t FakeAudioCaptureModule::StartPlayout() {
int32_t FakeAudioCaptureModule::StopPlayout() {
bool start = false;
{
rtc::CritScope cs(&crit_);
webrtc::MutexLock lock(&mutex_);
playing_ = false;
start = ShouldStartProcessing();
}
@ -203,7 +203,7 @@ int32_t FakeAudioCaptureModule::StopPlayout() {
}
bool FakeAudioCaptureModule::Playing() const {
rtc::CritScope cs(&crit_);
webrtc::MutexLock lock(&mutex_);
return playing_;
}
@ -212,7 +212,7 @@ int32_t FakeAudioCaptureModule::StartRecording() {
return -1;
}
{
rtc::CritScope cs(&crit_);
webrtc::MutexLock lock(&mutex_);
recording_ = true;
}
bool start = true;
@ -223,7 +223,7 @@ int32_t FakeAudioCaptureModule::StartRecording() {
int32_t FakeAudioCaptureModule::StopRecording() {
bool start = false;
{
rtc::CritScope cs(&crit_);
webrtc::MutexLock lock(&mutex_);
recording_ = false;
start = ShouldStartProcessing();
}
@ -232,7 +232,7 @@ int32_t FakeAudioCaptureModule::StopRecording() {
}
bool FakeAudioCaptureModule::Recording() const {
rtc::CritScope cs(&crit_);
webrtc::MutexLock lock(&mutex_);
return recording_;
}
@ -290,13 +290,13 @@ int32_t FakeAudioCaptureModule::MicrophoneVolumeIsAvailable(
}
int32_t FakeAudioCaptureModule::SetMicrophoneVolume(uint32_t volume) {
rtc::CritScope cs(&crit_);
webrtc::MutexLock lock(&mutex_);
current_mic_level_ = volume;
return 0;
}
int32_t FakeAudioCaptureModule::MicrophoneVolume(uint32_t* volume) const {
rtc::CritScope cs(&crit_);
webrtc::MutexLock lock(&mutex_);
*volume = current_mic_level_;
return 0;
}
@ -452,7 +452,7 @@ void FakeAudioCaptureModule::UpdateProcessing(bool start) {
process_thread_.reset(nullptr);
process_thread_checker_.Detach();
}
rtc::CritScope lock(&crit_);
webrtc::MutexLock lock(&mutex_);
started_ = false;
}
}
@ -460,7 +460,7 @@ void FakeAudioCaptureModule::UpdateProcessing(bool start) {
void FakeAudioCaptureModule::StartProcessP() {
RTC_DCHECK_RUN_ON(&process_thread_checker_);
{
rtc::CritScope lock(&crit_);
webrtc::MutexLock lock(&mutex_);
if (started_) {
// Already started.
return;
@ -472,7 +472,7 @@ void FakeAudioCaptureModule::StartProcessP() {
void FakeAudioCaptureModule::ProcessFrameP() {
RTC_DCHECK_RUN_ON(&process_thread_checker_);
{
rtc::CritScope cs(&crit_);
webrtc::MutexLock lock(&mutex_);
if (!started_) {
next_frame_time_ = rtc::TimeMillis();
started_ = true;

View File

@ -24,8 +24,8 @@
#include "api/scoped_refptr.h"
#include "modules/audio_device/include/audio_device.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/message_handler.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/synchronization/sequence_checker.h"
namespace rtc {
@ -48,13 +48,13 @@ class FakeAudioCaptureModule : public webrtc::AudioDeviceModule,
// Returns the number of frames that have been successfully pulled by the
// instance. Note that correctly detecting success can only be done if the
// pulled frame was generated/pushed from a FakeAudioCaptureModule.
int frames_received() const RTC_LOCKS_EXCLUDED(crit_);
int frames_received() const RTC_LOCKS_EXCLUDED(mutex_);
int32_t ActiveAudioLayer(AudioLayer* audio_layer) const override;
// Note: Calling this method from a callback may result in deadlock.
int32_t RegisterAudioCallback(webrtc::AudioTransport* audio_callback) override
RTC_LOCKS_EXCLUDED(crit_);
RTC_LOCKS_EXCLUDED(mutex_);
int32_t Init() override;
int32_t Terminate() override;
@ -81,12 +81,12 @@ class FakeAudioCaptureModule : public webrtc::AudioDeviceModule,
int32_t InitRecording() override;
bool RecordingIsInitialized() const override;
int32_t StartPlayout() RTC_LOCKS_EXCLUDED(crit_) override;
int32_t StopPlayout() RTC_LOCKS_EXCLUDED(crit_) override;
bool Playing() const RTC_LOCKS_EXCLUDED(crit_) override;
int32_t StartRecording() RTC_LOCKS_EXCLUDED(crit_) override;
int32_t StopRecording() RTC_LOCKS_EXCLUDED(crit_) override;
bool Recording() const RTC_LOCKS_EXCLUDED(crit_) override;
int32_t StartPlayout() RTC_LOCKS_EXCLUDED(mutex_) override;
int32_t StopPlayout() RTC_LOCKS_EXCLUDED(mutex_) override;
bool Playing() const RTC_LOCKS_EXCLUDED(mutex_) override;
int32_t StartRecording() RTC_LOCKS_EXCLUDED(mutex_) override;
int32_t StopRecording() RTC_LOCKS_EXCLUDED(mutex_) override;
bool Recording() const RTC_LOCKS_EXCLUDED(mutex_) override;
int32_t InitSpeaker() override;
bool SpeakerIsInitialized() const override;
@ -101,9 +101,9 @@ class FakeAudioCaptureModule : public webrtc::AudioDeviceModule,
int32_t MicrophoneVolumeIsAvailable(bool* available) override;
int32_t SetMicrophoneVolume(uint32_t volume)
RTC_LOCKS_EXCLUDED(crit_) override;
RTC_LOCKS_EXCLUDED(mutex_) override;
int32_t MicrophoneVolume(uint32_t* volume) const
RTC_LOCKS_EXCLUDED(crit_) override;
RTC_LOCKS_EXCLUDED(mutex_) override;
int32_t MaxMicrophoneVolume(uint32_t* max_volume) const override;
int32_t MinMicrophoneVolume(uint32_t* min_volume) const override;
@ -173,28 +173,28 @@ class FakeAudioCaptureModule : public webrtc::AudioDeviceModule,
// Returns true/false depending on if recording or playback has been
// enabled/started.
bool ShouldStartProcessing() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
bool ShouldStartProcessing() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
// Starts or stops the pushing and pulling of audio frames.
void UpdateProcessing(bool start) RTC_LOCKS_EXCLUDED(crit_);
void UpdateProcessing(bool start) RTC_LOCKS_EXCLUDED(mutex_);
// Starts the periodic calling of ProcessFrame() in a thread safe way.
void StartProcessP();
// Periodcally called function that ensures that frames are pulled and pushed
// periodically if enabled/started.
void ProcessFrameP() RTC_LOCKS_EXCLUDED(crit_);
void ProcessFrameP() RTC_LOCKS_EXCLUDED(mutex_);
// Pulls frames from the registered webrtc::AudioTransport.
void ReceiveFrameP() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
void ReceiveFrameP() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
// Pushes frames to the registered webrtc::AudioTransport.
void SendFrameP() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
void SendFrameP() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
// Callback for playout and recording.
webrtc::AudioTransport* audio_callback_ RTC_GUARDED_BY(crit_);
webrtc::AudioTransport* audio_callback_ RTC_GUARDED_BY(mutex_);
bool recording_ RTC_GUARDED_BY(
crit_); // True when audio is being pushed from the instance.
mutex_); // True when audio is being pushed from the instance.
bool playing_ RTC_GUARDED_BY(
crit_); // True when audio is being pulled by the instance.
mutex_); // True when audio is being pulled by the instance.
bool play_is_initialized_; // True when the instance is ready to pull audio.
bool rec_is_initialized_; // True when the instance is ready to push audio.
@ -202,12 +202,12 @@ class FakeAudioCaptureModule : public webrtc::AudioDeviceModule,
// Input to and output from RecordedDataIsAvailable(..) makes it possible to
// modify the current mic level. The implementation does not care about the
// mic level so it just feeds back what it receives.
uint32_t current_mic_level_ RTC_GUARDED_BY(crit_);
uint32_t current_mic_level_ RTC_GUARDED_BY(mutex_);
// next_frame_time_ is updated in a non-drifting manner to indicate the next
// wall clock time the next frame should be generated and received. started_
// ensures that next_frame_time_ can be initialized properly on first call.
bool started_ RTC_GUARDED_BY(crit_);
bool started_ RTC_GUARDED_BY(mutex_);
int64_t next_frame_time_ RTC_GUARDED_BY(process_thread_checker_);
std::unique_ptr<rtc::Thread> process_thread_;
@ -224,7 +224,7 @@ class FakeAudioCaptureModule : public webrtc::AudioDeviceModule,
// Protects variables that are accessed from process_thread_ and
// the main thread.
rtc::CriticalSection crit_;
mutable webrtc::Mutex mutex_;
webrtc::SequenceChecker process_thread_checker_;
};

View File

@ -15,8 +15,8 @@
#include <algorithm>
#include "api/scoped_refptr.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/gunit.h"
#include "rtc_base/synchronization/mutex.h"
#include "test/gtest.h"
class FakeAdmTest : public ::testing::Test, public webrtc::AudioTransport {
@ -45,7 +45,7 @@ class FakeAdmTest : public ::testing::Test, public webrtc::AudioTransport {
const uint32_t currentMicLevel,
const bool keyPressed,
uint32_t& newMicLevel) override {
rtc::CritScope cs(&crit_);
webrtc::MutexLock lock(&mutex_);
rec_buffer_bytes_ = nSamples * nBytesPerSample;
if ((rec_buffer_bytes_ == 0) ||
(rec_buffer_bytes_ >
@ -77,7 +77,7 @@ class FakeAdmTest : public ::testing::Test, public webrtc::AudioTransport {
size_t& nSamplesOut,
int64_t* elapsed_time_ms,
int64_t* ntp_time_ms) override {
rtc::CritScope cs(&crit_);
webrtc::MutexLock lock(&mutex_);
++pull_iterations_;
const size_t audio_buffer_size = nSamples * nBytesPerSample;
const size_t bytes_out =
@ -91,11 +91,11 @@ class FakeAdmTest : public ::testing::Test, public webrtc::AudioTransport {
}
int push_iterations() const {
rtc::CritScope cs(&crit_);
webrtc::MutexLock lock(&mutex_);
return push_iterations_;
}
int pull_iterations() const {
rtc::CritScope cs(&crit_);
webrtc::MutexLock lock(&mutex_);
return pull_iterations_;
}
@ -115,7 +115,7 @@ class FakeAdmTest : public ::testing::Test, public webrtc::AudioTransport {
return min_buffer_size;
}
rtc::CriticalSection crit_;
mutable webrtc::Mutex mutex_;
int push_iterations_;
int pull_iterations_;

View File

@ -16,7 +16,7 @@
#include "api/video/video_source_interface.h"
#include "media/base/fake_frame_source.h"
#include "media/base/video_broadcaster.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/task_queue_for_test.h"
#include "rtc_base/task_utils/repeating_task.h"
@ -61,7 +61,7 @@ class FakePeriodicVideoSource final
}
rtc::VideoSinkWants wants() const {
rtc::CritScope cs(&crit_);
MutexLock lock(&mutex_);
return wants_;
}
@ -74,7 +74,7 @@ class FakePeriodicVideoSource final
const rtc::VideoSinkWants& wants) override {
RTC_DCHECK(thread_checker_.IsCurrent());
{
rtc::CritScope cs(&crit_);
MutexLock lock(&mutex_);
wants_ = wants;
}
broadcaster_.AddOrUpdateSink(sink, wants);
@ -90,8 +90,8 @@ class FakePeriodicVideoSource final
rtc::VideoBroadcaster broadcaster_;
cricket::FakeFrameSource frame_source_;
rtc::CriticalSection crit_;
rtc::VideoSinkWants wants_ RTC_GUARDED_BY(&crit_);
mutable Mutex mutex_;
rtc::VideoSinkWants wants_ RTC_GUARDED_BY(&mutex_);
std::unique_ptr<TaskQueueForTest> task_queue_;
};

View File

@ -31,7 +31,7 @@ rtc::VideoSinkInterface<VideoFrame>* VideoRtpTrackSource::sink() {
void VideoRtpTrackSource::BroadcastRecordableEncodedFrame(
const RecordableEncodedFrame& frame) const {
rtc::CritScope cs(&mu_);
MutexLock lock(&mu_);
for (rtc::VideoSinkInterface<RecordableEncodedFrame>* sink : encoded_sinks_) {
sink->OnFrame(frame);
}
@ -54,7 +54,7 @@ void VideoRtpTrackSource::AddEncodedSink(
RTC_DCHECK(sink);
size_t size = 0;
{
rtc::CritScope cs(&mu_);
MutexLock lock(&mu_);
RTC_DCHECK(std::find(encoded_sinks_.begin(), encoded_sinks_.end(), sink) ==
encoded_sinks_.end());
encoded_sinks_.push_back(sink);
@ -70,7 +70,7 @@ void VideoRtpTrackSource::RemoveEncodedSink(
RTC_DCHECK_RUN_ON(&worker_sequence_checker_);
size_t size = 0;
{
rtc::CritScope cs(&mu_);
MutexLock lock(&mu_);
auto it = std::find(encoded_sinks_.begin(), encoded_sinks_.end(), sink);
if (it != encoded_sinks_.end()) {
encoded_sinks_.erase(it);

View File

@ -16,7 +16,7 @@
#include "media/base/video_broadcaster.h"
#include "pc/video_track_source.h"
#include "rtc_base/callback.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/synchronization/mutex.h"
namespace webrtc {
@ -72,7 +72,7 @@ class VideoRtpTrackSource : public VideoTrackSource {
// It might be better if the decoder can handle multiple sinks and consider
// the VideoSinkWants.
rtc::VideoBroadcaster broadcaster_;
rtc::CriticalSection mu_;
mutable Mutex mu_;
std::vector<rtc::VideoSinkInterface<RecordableEncodedFrame>*> encoded_sinks_
RTC_GUARDED_BY(mu_);
Callback* callback_ RTC_GUARDED_BY(worker_sequence_checker_);