Deprecating ThreadChecker specific interface.

All changes outside thread_checker.h are by:
s/CalledOnValidThread/IsCurrent/
s/DetachFromThread/Detach/

Bug: webrtc:9883
Change-Id: Idbb1086bff0817db58e770116acf4c9d60fae8b3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/131023
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27494}
This commit is contained in:
Sebastian Jansson 2019-04-08 15:20:44 +02:00 committed by Commit Bot
parent e5b94160b5
commit c01367db40
78 changed files with 617 additions and 615 deletions

View File

@ -781,28 +781,28 @@ const StatsReport::Value* StatsReport::FindValue(StatsValueName name) const {
StatsCollection::StatsCollection() {} StatsCollection::StatsCollection() {}
StatsCollection::~StatsCollection() { StatsCollection::~StatsCollection() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
for (auto* r : list_) for (auto* r : list_)
delete r; delete r;
} }
StatsCollection::const_iterator StatsCollection::begin() const { StatsCollection::const_iterator StatsCollection::begin() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return list_.begin(); return list_.begin();
} }
StatsCollection::const_iterator StatsCollection::end() const { StatsCollection::const_iterator StatsCollection::end() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return list_.end(); return list_.end();
} }
size_t StatsCollection::size() const { size_t StatsCollection::size() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return list_.size(); return list_.size();
} }
StatsReport* StatsCollection::InsertNew(const StatsReport::Id& id) { StatsReport* StatsCollection::InsertNew(const StatsReport::Id& id) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(Find(id) == nullptr); RTC_DCHECK(Find(id) == nullptr);
StatsReport* report = new StatsReport(id); StatsReport* report = new StatsReport(id);
list_.push_back(report); list_.push_back(report);
@ -810,13 +810,13 @@ StatsReport* StatsCollection::InsertNew(const StatsReport::Id& id) {
} }
StatsReport* StatsCollection::FindOrAddNew(const StatsReport::Id& id) { StatsReport* StatsCollection::FindOrAddNew(const StatsReport::Id& id) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
StatsReport* ret = Find(id); StatsReport* ret = Find(id);
return ret ? ret : InsertNew(id); return ret ? ret : InsertNew(id);
} }
StatsReport* StatsCollection::ReplaceOrAddNew(const StatsReport::Id& id) { StatsReport* StatsCollection::ReplaceOrAddNew(const StatsReport::Id& id) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(id.get()); RTC_DCHECK(id.get());
Container::iterator it = absl::c_find_if( Container::iterator it = absl::c_find_if(
list_, list_,
@ -833,7 +833,7 @@ StatsReport* StatsCollection::ReplaceOrAddNew(const StatsReport::Id& id) {
// Looks for a report with the given |id|. If one is not found, null // Looks for a report with the given |id|. If one is not found, null
// will be returned. // will be returned.
StatsReport* StatsCollection::Find(const StatsReport::Id& id) { StatsReport* StatsCollection::Find(const StatsReport::Id& id) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
Container::iterator it = absl::c_find_if( Container::iterator it = absl::c_find_if(
list_, list_,
[&id](const StatsReport* r) -> bool { return r->id()->Equals(id); }); [&id](const StatsReport* r) -> bool { return r->id()->Equals(id); });

View File

@ -29,7 +29,7 @@ std::unique_ptr<TestDependencyFactory> TestDependencyFactory::instance_ =
nullptr; nullptr;
const TestDependencyFactory& TestDependencyFactory::GetInstance() { const TestDependencyFactory& TestDependencyFactory::GetInstance() {
RTC_DCHECK(GetThreadChecker()->CalledOnValidThread()); RTC_DCHECK(GetThreadChecker()->IsCurrent());
if (instance_ == nullptr) { if (instance_ == nullptr) {
instance_ = absl::make_unique<TestDependencyFactory>(); instance_ = absl::make_unique<TestDependencyFactory>();
} }
@ -38,14 +38,14 @@ const TestDependencyFactory& TestDependencyFactory::GetInstance() {
void TestDependencyFactory::SetInstance( void TestDependencyFactory::SetInstance(
std::unique_ptr<TestDependencyFactory> instance) { std::unique_ptr<TestDependencyFactory> instance) {
RTC_DCHECK(GetThreadChecker()->CalledOnValidThread()); RTC_DCHECK(GetThreadChecker()->IsCurrent());
RTC_CHECK(instance_ == nullptr); RTC_CHECK(instance_ == nullptr);
instance_ = std::move(instance); instance_ = std::move(instance);
} }
std::unique_ptr<VideoQualityTestFixtureInterface::InjectionComponents> std::unique_ptr<VideoQualityTestFixtureInterface::InjectionComponents>
TestDependencyFactory::CreateComponents() const { TestDependencyFactory::CreateComponents() const {
RTC_DCHECK(GetThreadChecker()->CalledOnValidThread()); RTC_DCHECK(GetThreadChecker()->IsCurrent());
return nullptr; return nullptr;
} }

View File

@ -120,7 +120,7 @@ AudioReceiveStream::AudioReceiveStream(
RTC_DCHECK(audio_state_); RTC_DCHECK(audio_state_);
RTC_DCHECK(channel_receive_); RTC_DCHECK(channel_receive_);
module_process_thread_checker_.DetachFromThread(); module_process_thread_checker_.Detach();
if (!config.media_transport) { if (!config.media_transport) {
RTC_DCHECK(receiver_controller); RTC_DCHECK(receiver_controller);
@ -147,7 +147,7 @@ AudioReceiveStream::~AudioReceiveStream() {
void AudioReceiveStream::Reconfigure( void AudioReceiveStream::Reconfigure(
const webrtc::AudioReceiveStream::Config& config) { const webrtc::AudioReceiveStream::Config& config) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
ConfigureStream(this, config, false); ConfigureStream(this, config, false);
} }
@ -317,7 +317,7 @@ void AudioReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) {
// TODO(solenberg): Tests call this function on a network thread, libjingle // TODO(solenberg): Tests call this function on a network thread, libjingle
// calls on the worker thread. We should move towards always using a network // calls on the worker thread. We should move towards always using a network
// thread. Then this check can be enabled. // thread. Then this check can be enabled.
// RTC_DCHECK(!thread_checker_.CalledOnValidThread()); // RTC_DCHECK(!thread_checker_.IsCurrent());
channel_receive_->ReceivedRTCPPacket(packet, length); channel_receive_->ReceivedRTCPPacket(packet, length);
} }
@ -325,7 +325,7 @@ void AudioReceiveStream::OnRtpPacket(const RtpPacketReceived& packet) {
// TODO(solenberg): Tests call this function on a network thread, libjingle // TODO(solenberg): Tests call this function on a network thread, libjingle
// calls on the worker thread. We should move towards always using a network // calls on the worker thread. We should move towards always using a network
// thread. Then this check can be enabled. // thread. Then this check can be enabled.
// RTC_DCHECK(!thread_checker_.CalledOnValidThread()); // RTC_DCHECK(!thread_checker_.IsCurrent());
channel_receive_->OnRtpPacket(packet); channel_receive_->OnRtpPacket(packet);
} }

View File

@ -166,7 +166,7 @@ AudioSendStream::AudioSendStream(
ConfigureStream(this, config, true); ConfigureStream(this, config, true);
pacer_thread_checker_.DetachFromThread(); pacer_thread_checker_.Detach();
if (rtp_transport_) { if (rtp_transport_) {
// Signal congestion controller this object is ready for OnPacket* // Signal congestion controller this object is ready for OnPacket*
// callbacks. // callbacks.
@ -175,7 +175,7 @@ AudioSendStream::AudioSendStream(
} }
AudioSendStream::~AudioSendStream() { AudioSendStream::~AudioSendStream() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_LOG(LS_INFO) << "~AudioSendStream: " << config_.rtp.ssrc; RTC_LOG(LS_INFO) << "~AudioSendStream: " << config_.rtp.ssrc;
RTC_DCHECK(!sending_); RTC_DCHECK(!sending_);
if (rtp_transport_) { if (rtp_transport_) {
@ -190,13 +190,13 @@ AudioSendStream::~AudioSendStream() {
} }
const webrtc::AudioSendStream::Config& AudioSendStream::GetConfig() const { const webrtc::AudioSendStream::Config& AudioSendStream::GetConfig() const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
return config_; return config_;
} }
void AudioSendStream::Reconfigure( void AudioSendStream::Reconfigure(
const webrtc::AudioSendStream::Config& new_config) { const webrtc::AudioSendStream::Config& new_config) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
ConfigureStream(this, new_config, false); ConfigureStream(this, new_config, false);
} }
@ -345,7 +345,7 @@ void AudioSendStream::Start() {
} }
void AudioSendStream::Stop() { void AudioSendStream::Stop() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
if (!sending_) { if (!sending_) {
return; return;
} }
@ -365,14 +365,14 @@ bool AudioSendStream::SendTelephoneEvent(int payload_type,
int payload_frequency, int payload_frequency,
int event, int event,
int duration_ms) { int duration_ms) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
channel_send_->SetSendTelephoneEventPayloadType(payload_type, channel_send_->SetSendTelephoneEventPayloadType(payload_type,
payload_frequency); payload_frequency);
return channel_send_->SendTelephoneEventOutband(event, duration_ms); return channel_send_->SendTelephoneEventOutband(event, duration_ms);
} }
void AudioSendStream::SetMuted(bool muted) { void AudioSendStream::SetMuted(bool muted) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
channel_send_->SetInputMute(muted); channel_send_->SetInputMute(muted);
} }
@ -382,7 +382,7 @@ webrtc::AudioSendStream::Stats AudioSendStream::GetStats() const {
webrtc::AudioSendStream::Stats AudioSendStream::GetStats( webrtc::AudioSendStream::Stats AudioSendStream::GetStats(
bool has_remote_tracks) const { bool has_remote_tracks) const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
webrtc::AudioSendStream::Stats stats; webrtc::AudioSendStream::Stats stats;
stats.local_ssrc = config_.rtp.ssrc; stats.local_ssrc = config_.rtp.ssrc;
stats.target_bitrate_bps = channel_send_->GetBitrate(); stats.target_bitrate_bps = channel_send_->GetBitrate();
@ -432,14 +432,14 @@ webrtc::AudioSendStream::Stats AudioSendStream::GetStats(
} }
void AudioSendStream::SignalNetworkState(NetworkState state) { void AudioSendStream::SignalNetworkState(NetworkState state) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
} }
void AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { void AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) {
// TODO(solenberg): Tests call this function on a network thread, libjingle // TODO(solenberg): Tests call this function on a network thread, libjingle
// calls on the worker thread. We should move towards always using a network // calls on the worker thread. We should move towards always using a network
// thread. Then this check can be enabled. // thread. Then this check can be enabled.
// RTC_DCHECK(!worker_thread_checker_.CalledOnValidThread()); // RTC_DCHECK(!worker_thread_checker_.IsCurrent());
channel_send_->ReceivedRTCPPacket(packet, length); channel_send_->ReceivedRTCPPacket(packet, length);
} }
@ -465,7 +465,7 @@ uint32_t AudioSendStream::OnBitrateUpdated(BitrateAllocationUpdate update) {
} }
void AudioSendStream::OnPacketAdded(uint32_t ssrc, uint16_t seq_num) { void AudioSendStream::OnPacketAdded(uint32_t ssrc, uint16_t seq_num) {
RTC_DCHECK(pacer_thread_checker_.CalledOnValidThread()); RTC_DCHECK(pacer_thread_checker_.IsCurrent());
// Only packets that belong to this stream are of interest. // Only packets that belong to this stream are of interest.
if (ssrc == config_.rtp.ssrc) { if (ssrc == config_.rtp.ssrc) {
rtc::CritScope lock(&packet_loss_tracker_cs_); rtc::CritScope lock(&packet_loss_tracker_cs_);
@ -478,7 +478,7 @@ void AudioSendStream::OnPacketAdded(uint32_t ssrc, uint16_t seq_num) {
void AudioSendStream::OnPacketFeedbackVector( void AudioSendStream::OnPacketFeedbackVector(
const std::vector<PacketFeedback>& packet_feedback_vector) { const std::vector<PacketFeedback>& packet_feedback_vector) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
absl::optional<float> plr; absl::optional<float> plr;
absl::optional<float> rplr; absl::optional<float> rplr;
{ {
@ -500,7 +500,7 @@ void AudioSendStream::OnPacketFeedbackVector(
void AudioSendStream::SetTransportOverhead( void AudioSendStream::SetTransportOverhead(
int transport_overhead_per_packet_bytes) { int transport_overhead_per_packet_bytes) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
rtc::CritScope cs(&overhead_per_packet_lock_); rtc::CritScope cs(&overhead_per_packet_lock_);
transport_overhead_per_packet_bytes_ = transport_overhead_per_packet_bytes; transport_overhead_per_packet_bytes_ = transport_overhead_per_packet_bytes;
UpdateOverheadForEncoder(); UpdateOverheadForEncoder();
@ -563,7 +563,7 @@ const internal::AudioState* AudioSendStream::audio_state() const {
void AudioSendStream::StoreEncoderProperties(int sample_rate_hz, void AudioSendStream::StoreEncoderProperties(int sample_rate_hz,
size_t num_channels) { size_t num_channels) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
encoder_sample_rate_hz_ = sample_rate_hz; encoder_sample_rate_hz_ = sample_rate_hz;
encoder_num_channels_ = num_channels; encoder_num_channels_ = num_channels;
if (sending_) { if (sending_) {
@ -806,7 +806,7 @@ void AudioSendStream::ConfigureBitrateObserver() {
} }
void AudioSendStream::RemoveBitrateObserver() { void AudioSendStream::RemoveBitrateObserver() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
rtc::Event thread_sync_event; rtc::Event thread_sync_event;
worker_queue_->PostTask([this, &thread_sync_event] { worker_queue_->PostTask([this, &thread_sync_event] {
RTC_DCHECK_RUN_ON(worker_queue_); RTC_DCHECK_RUN_ON(worker_queue_);

View File

@ -28,13 +28,13 @@ namespace internal {
AudioState::AudioState(const AudioState::Config& config) AudioState::AudioState(const AudioState::Config& config)
: config_(config), : config_(config),
audio_transport_(config_.audio_mixer, config_.audio_processing.get()) { audio_transport_(config_.audio_mixer, config_.audio_processing.get()) {
process_thread_checker_.DetachFromThread(); process_thread_checker_.Detach();
RTC_DCHECK(config_.audio_mixer); RTC_DCHECK(config_.audio_mixer);
RTC_DCHECK(config_.audio_device_module); RTC_DCHECK(config_.audio_device_module);
} }
AudioState::~AudioState() { AudioState::~AudioState() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(receiving_streams_.empty()); RTC_DCHECK(receiving_streams_.empty());
RTC_DCHECK(sending_streams_.empty()); RTC_DCHECK(sending_streams_.empty());
} }
@ -49,12 +49,12 @@ AudioTransport* AudioState::audio_transport() {
} }
bool AudioState::typing_noise_detected() const { bool AudioState::typing_noise_detected() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return audio_transport_.typing_noise_detected(); return audio_transport_.typing_noise_detected();
} }
void AudioState::AddReceivingStream(webrtc::AudioReceiveStream* stream) { void AudioState::AddReceivingStream(webrtc::AudioReceiveStream* stream) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK_EQ(0, receiving_streams_.count(stream)); RTC_DCHECK_EQ(0, receiving_streams_.count(stream));
receiving_streams_.insert(stream); receiving_streams_.insert(stream);
if (!config_.audio_mixer->AddSource( if (!config_.audio_mixer->AddSource(
@ -76,7 +76,7 @@ void AudioState::AddReceivingStream(webrtc::AudioReceiveStream* stream) {
} }
void AudioState::RemoveReceivingStream(webrtc::AudioReceiveStream* stream) { void AudioState::RemoveReceivingStream(webrtc::AudioReceiveStream* stream) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
auto count = receiving_streams_.erase(stream); auto count = receiving_streams_.erase(stream);
RTC_DCHECK_EQ(1, count); RTC_DCHECK_EQ(1, count);
config_.audio_mixer->RemoveSource( config_.audio_mixer->RemoveSource(
@ -89,7 +89,7 @@ void AudioState::RemoveReceivingStream(webrtc::AudioReceiveStream* stream) {
void AudioState::AddSendingStream(webrtc::AudioSendStream* stream, void AudioState::AddSendingStream(webrtc::AudioSendStream* stream,
int sample_rate_hz, int sample_rate_hz,
size_t num_channels) { size_t num_channels) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
auto& properties = sending_streams_[stream]; auto& properties = sending_streams_[stream];
properties.sample_rate_hz = sample_rate_hz; properties.sample_rate_hz = sample_rate_hz;
properties.num_channels = num_channels; properties.num_channels = num_channels;
@ -109,7 +109,7 @@ void AudioState::AddSendingStream(webrtc::AudioSendStream* stream,
} }
void AudioState::RemoveSendingStream(webrtc::AudioSendStream* stream) { void AudioState::RemoveSendingStream(webrtc::AudioSendStream* stream) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
auto count = sending_streams_.erase(stream); auto count = sending_streams_.erase(stream);
RTC_DCHECK_EQ(1, count); RTC_DCHECK_EQ(1, count);
UpdateAudioTransportWithSendingStreams(); UpdateAudioTransportWithSendingStreams();
@ -120,7 +120,7 @@ void AudioState::RemoveSendingStream(webrtc::AudioSendStream* stream) {
void AudioState::SetPlayout(bool enabled) { void AudioState::SetPlayout(bool enabled) {
RTC_LOG(INFO) << "SetPlayout(" << enabled << ")"; RTC_LOG(INFO) << "SetPlayout(" << enabled << ")";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (playout_enabled_ != enabled) { if (playout_enabled_ != enabled) {
playout_enabled_ = enabled; playout_enabled_ = enabled;
if (enabled) { if (enabled) {
@ -138,7 +138,7 @@ void AudioState::SetPlayout(bool enabled) {
void AudioState::SetRecording(bool enabled) { void AudioState::SetRecording(bool enabled) {
RTC_LOG(INFO) << "SetRecording(" << enabled << ")"; RTC_LOG(INFO) << "SetRecording(" << enabled << ")";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (recording_enabled_ != enabled) { if (recording_enabled_ != enabled) {
recording_enabled_ = enabled; recording_enabled_ = enabled;
if (enabled) { if (enabled) {
@ -152,7 +152,7 @@ void AudioState::SetRecording(bool enabled) {
} }
AudioState::Stats AudioState::GetAudioInputStats() const { AudioState::Stats AudioState::GetAudioInputStats() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
const voe::AudioLevel& audio_level = audio_transport_.audio_level(); const voe::AudioLevel& audio_level = audio_transport_.audio_level();
Stats result; Stats result;
result.audio_level = audio_level.LevelFullRange(); result.audio_level = audio_level.LevelFullRange();
@ -164,12 +164,12 @@ AudioState::Stats AudioState::GetAudioInputStats() const {
} }
void AudioState::SetStereoChannelSwapping(bool enable) { void AudioState::SetStereoChannelSwapping(bool enable) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
audio_transport_.SetStereoChannelSwapping(enable); audio_transport_.SetStereoChannelSwapping(enable);
} }
void AudioState::UpdateAudioTransportWithSendingStreams() { void AudioState::UpdateAudioTransportWithSendingStreams() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
std::vector<webrtc::AudioSendStream*> sending_streams; std::vector<webrtc::AudioSendStream*> sending_streams;
int max_sample_rate_hz = 8000; int max_sample_rate_hz = 8000;
size_t max_num_channels = 1; size_t max_num_channels = 1;

View File

@ -462,7 +462,7 @@ ChannelReceive::ChannelReceive(
frame_decryptor_(frame_decryptor), frame_decryptor_(frame_decryptor),
crypto_options_(crypto_options) { crypto_options_(crypto_options) {
// TODO(nisse): Use _moduleProcessThreadPtr instead? // TODO(nisse): Use _moduleProcessThreadPtr instead?
module_process_thread_checker_.DetachFromThread(); module_process_thread_checker_.Detach();
RTC_DCHECK(module_process_thread); RTC_DCHECK(module_process_thread);
RTC_DCHECK(audio_device_module); RTC_DCHECK(audio_device_module);
@ -509,7 +509,7 @@ ChannelReceive::ChannelReceive(
} }
ChannelReceive::~ChannelReceive() { ChannelReceive::~ChannelReceive() {
RTC_DCHECK(construction_thread_.CalledOnValidThread()); RTC_DCHECK(construction_thread_.IsCurrent());
if (media_transport_) { if (media_transport_) {
media_transport_->SetReceiveAudioSink(nullptr); media_transport_->SetReceiveAudioSink(nullptr);
@ -525,19 +525,19 @@ ChannelReceive::~ChannelReceive() {
} }
void ChannelReceive::SetSink(AudioSinkInterface* sink) { void ChannelReceive::SetSink(AudioSinkInterface* sink) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
rtc::CritScope cs(&_callbackCritSect); rtc::CritScope cs(&_callbackCritSect);
audio_sink_ = sink; audio_sink_ = sink;
} }
void ChannelReceive::StartPlayout() { void ChannelReceive::StartPlayout() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
rtc::CritScope lock(&playing_lock_); rtc::CritScope lock(&playing_lock_);
playing_ = true; playing_ = true;
} }
void ChannelReceive::StopPlayout() { void ChannelReceive::StopPlayout() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
rtc::CritScope lock(&playing_lock_); rtc::CritScope lock(&playing_lock_);
playing_ = false; playing_ = false;
_outputAudioLevel.Clear(); _outputAudioLevel.Clear();
@ -545,12 +545,12 @@ void ChannelReceive::StopPlayout() {
absl::optional<std::pair<int, SdpAudioFormat>> absl::optional<std::pair<int, SdpAudioFormat>>
ChannelReceive::GetReceiveCodec() const { ChannelReceive::GetReceiveCodec() const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
return audio_coding_->ReceiveCodec(); return audio_coding_->ReceiveCodec();
} }
std::vector<webrtc::RtpSource> ChannelReceive::GetSources() const { std::vector<webrtc::RtpSource> ChannelReceive::GetSources() const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
int64_t now_ms = rtc::TimeMillis(); int64_t now_ms = rtc::TimeMillis();
std::vector<RtpSource> sources; std::vector<RtpSource> sources;
{ {
@ -568,7 +568,7 @@ std::vector<webrtc::RtpSource> ChannelReceive::GetSources() const {
void ChannelReceive::SetReceiveCodecs( void ChannelReceive::SetReceiveCodecs(
const std::map<int, SdpAudioFormat>& codecs) { const std::map<int, SdpAudioFormat>& codecs) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
for (const auto& kv : codecs) { for (const auto& kv : codecs) {
RTC_DCHECK_GE(kv.second.clockrate_hz, 1000); RTC_DCHECK_GE(kv.second.clockrate_hz, 1000);
payload_type_frequencies_[kv.first] = kv.second.clockrate_hz; payload_type_frequencies_[kv.first] = kv.second.clockrate_hz;
@ -693,34 +693,34 @@ void ChannelReceive::ReceivedRTCPPacket(const uint8_t* data, size_t length) {
} }
int ChannelReceive::GetSpeechOutputLevelFullRange() const { int ChannelReceive::GetSpeechOutputLevelFullRange() const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
return _outputAudioLevel.LevelFullRange(); return _outputAudioLevel.LevelFullRange();
} }
double ChannelReceive::GetTotalOutputEnergy() const { double ChannelReceive::GetTotalOutputEnergy() const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
return _outputAudioLevel.TotalEnergy(); return _outputAudioLevel.TotalEnergy();
} }
double ChannelReceive::GetTotalOutputDuration() const { double ChannelReceive::GetTotalOutputDuration() const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
return _outputAudioLevel.TotalDuration(); return _outputAudioLevel.TotalDuration();
} }
void ChannelReceive::SetChannelOutputVolumeScaling(float scaling) { void ChannelReceive::SetChannelOutputVolumeScaling(float scaling) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
rtc::CritScope cs(&volume_settings_critsect_); rtc::CritScope cs(&volume_settings_critsect_);
_outputGain = scaling; _outputGain = scaling;
} }
void ChannelReceive::SetLocalSSRC(uint32_t ssrc) { void ChannelReceive::SetLocalSSRC(uint32_t ssrc) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
_rtpRtcpModule->SetSSRC(ssrc); _rtpRtcpModule->SetSSRC(ssrc);
} }
void ChannelReceive::RegisterReceiverCongestionControlObjects( void ChannelReceive::RegisterReceiverCongestionControlObjects(
PacketRouter* packet_router) { PacketRouter* packet_router) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(packet_router); RTC_DCHECK(packet_router);
RTC_DCHECK(!packet_router_); RTC_DCHECK(!packet_router_);
constexpr bool remb_candidate = false; constexpr bool remb_candidate = false;
@ -729,14 +729,14 @@ void ChannelReceive::RegisterReceiverCongestionControlObjects(
} }
void ChannelReceive::ResetReceiverCongestionControlObjects() { void ChannelReceive::ResetReceiverCongestionControlObjects() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(packet_router_); RTC_DCHECK(packet_router_);
packet_router_->RemoveReceiveRtpModule(_rtpRtcpModule.get()); packet_router_->RemoveReceiveRtpModule(_rtpRtcpModule.get());
packet_router_ = nullptr; packet_router_ = nullptr;
} }
CallReceiveStatistics ChannelReceive::GetRTCPStatistics() const { CallReceiveStatistics ChannelReceive::GetRTCPStatistics() const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
// --- RtcpStatistics // --- RtcpStatistics
CallReceiveStatistics stats; CallReceiveStatistics stats;
@ -779,7 +779,7 @@ CallReceiveStatistics ChannelReceive::GetRTCPStatistics() const {
} }
void ChannelReceive::SetNACKStatus(bool enable, int max_packets) { void ChannelReceive::SetNACKStatus(bool enable, int max_packets) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
// None of these functions can fail. // None of these functions can fail.
if (enable) { if (enable) {
rtp_receive_statistics_->SetMaxReorderingThreshold(max_packets); rtp_receive_statistics_->SetMaxReorderingThreshold(max_packets);
@ -799,13 +799,13 @@ int ChannelReceive::ResendPackets(const uint16_t* sequence_numbers,
void ChannelReceive::SetAssociatedSendChannel( void ChannelReceive::SetAssociatedSendChannel(
const ChannelSendInterface* channel) { const ChannelSendInterface* channel) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
rtc::CritScope lock(&assoc_send_channel_lock_); rtc::CritScope lock(&assoc_send_channel_lock_);
associated_send_channel_ = channel; associated_send_channel_ = channel;
} }
NetworkStatistics ChannelReceive::GetNetworkStatistics() const { NetworkStatistics ChannelReceive::GetNetworkStatistics() const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
NetworkStatistics stats; NetworkStatistics stats;
int error = audio_coding_->GetNetworkStatistics(&stats); int error = audio_coding_->GetNetworkStatistics(&stats);
RTC_DCHECK_EQ(0, error); RTC_DCHECK_EQ(0, error);
@ -813,21 +813,21 @@ NetworkStatistics ChannelReceive::GetNetworkStatistics() const {
} }
AudioDecodingCallStats ChannelReceive::GetDecodingCallStatistics() const { AudioDecodingCallStats ChannelReceive::GetDecodingCallStatistics() const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
AudioDecodingCallStats stats; AudioDecodingCallStats stats;
audio_coding_->GetDecodingCallStatistics(&stats); audio_coding_->GetDecodingCallStatistics(&stats);
return stats; return stats;
} }
uint32_t ChannelReceive::GetDelayEstimate() const { uint32_t ChannelReceive::GetDelayEstimate() const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() || RTC_DCHECK(worker_thread_checker_.IsCurrent() ||
module_process_thread_checker_.CalledOnValidThread()); module_process_thread_checker_.IsCurrent());
rtc::CritScope lock(&video_sync_lock_); rtc::CritScope lock(&video_sync_lock_);
return audio_coding_->FilteredCurrentDelayMs() + playout_delay_ms_; return audio_coding_->FilteredCurrentDelayMs() + playout_delay_ms_;
} }
void ChannelReceive::SetMinimumPlayoutDelay(int delay_ms) { void ChannelReceive::SetMinimumPlayoutDelay(int delay_ms) {
RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread()); RTC_DCHECK(module_process_thread_checker_.IsCurrent());
// Limit to range accepted by both VoE and ACM, so we're at least getting as // Limit to range accepted by both VoE and ACM, so we're at least getting as
// close as possible, instead of failing. // close as possible, instead of failing.
delay_ms = rtc::SafeClamp(delay_ms, kVoiceEngineMinMinPlayoutDelayMs, delay_ms = rtc::SafeClamp(delay_ms, kVoiceEngineMinMinPlayoutDelayMs,
@ -855,7 +855,7 @@ int ChannelReceive::GetBaseMinimumPlayoutDelayMs() const {
} }
absl::optional<Syncable::Info> ChannelReceive::GetSyncInfo() const { absl::optional<Syncable::Info> ChannelReceive::GetSyncInfo() const {
RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread()); RTC_DCHECK(module_process_thread_checker_.IsCurrent());
Syncable::Info info; Syncable::Info info;
if (_rtpRtcpModule->RemoteNTP(&info.capture_time_ntp_secs, if (_rtpRtcpModule->RemoteNTP(&info.capture_time_ntp_secs,
&info.capture_time_ntp_frac, nullptr, nullptr, &info.capture_time_ntp_frac, nullptr, nullptr,

View File

@ -302,13 +302,13 @@ const int kTelephoneEventAttenuationdB = 10;
class TransportFeedbackProxy : public TransportFeedbackObserver { class TransportFeedbackProxy : public TransportFeedbackObserver {
public: public:
TransportFeedbackProxy() : feedback_observer_(nullptr) { TransportFeedbackProxy() : feedback_observer_(nullptr) {
pacer_thread_.DetachFromThread(); pacer_thread_.Detach();
network_thread_.DetachFromThread(); network_thread_.Detach();
} }
void SetTransportFeedbackObserver( void SetTransportFeedbackObserver(
TransportFeedbackObserver* feedback_observer) { TransportFeedbackObserver* feedback_observer) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
rtc::CritScope lock(&crit_); rtc::CritScope lock(&crit_);
feedback_observer_ = feedback_observer; feedback_observer_ = feedback_observer;
} }
@ -318,14 +318,14 @@ class TransportFeedbackProxy : public TransportFeedbackObserver {
uint16_t sequence_number, uint16_t sequence_number,
size_t length, size_t length,
const PacedPacketInfo& pacing_info) override { const PacedPacketInfo& pacing_info) override {
RTC_DCHECK(pacer_thread_.CalledOnValidThread()); RTC_DCHECK(pacer_thread_.IsCurrent());
rtc::CritScope lock(&crit_); rtc::CritScope lock(&crit_);
if (feedback_observer_) if (feedback_observer_)
feedback_observer_->AddPacket(ssrc, sequence_number, length, pacing_info); feedback_observer_->AddPacket(ssrc, sequence_number, length, pacing_info);
} }
void OnTransportFeedback(const rtcp::TransportFeedback& feedback) override { void OnTransportFeedback(const rtcp::TransportFeedback& feedback) override {
RTC_DCHECK(network_thread_.CalledOnValidThread()); RTC_DCHECK(network_thread_.IsCurrent());
rtc::CritScope lock(&crit_); rtc::CritScope lock(&crit_);
if (feedback_observer_) if (feedback_observer_)
feedback_observer_->OnTransportFeedback(feedback); feedback_observer_->OnTransportFeedback(feedback);
@ -342,19 +342,19 @@ class TransportFeedbackProxy : public TransportFeedbackObserver {
class TransportSequenceNumberProxy : public TransportSequenceNumberAllocator { class TransportSequenceNumberProxy : public TransportSequenceNumberAllocator {
public: public:
TransportSequenceNumberProxy() : seq_num_allocator_(nullptr) { TransportSequenceNumberProxy() : seq_num_allocator_(nullptr) {
pacer_thread_.DetachFromThread(); pacer_thread_.Detach();
} }
void SetSequenceNumberAllocator( void SetSequenceNumberAllocator(
TransportSequenceNumberAllocator* seq_num_allocator) { TransportSequenceNumberAllocator* seq_num_allocator) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
rtc::CritScope lock(&crit_); rtc::CritScope lock(&crit_);
seq_num_allocator_ = seq_num_allocator; seq_num_allocator_ = seq_num_allocator;
} }
// Implements TransportSequenceNumberAllocator. // Implements TransportSequenceNumberAllocator.
uint16_t AllocateSequenceNumber() override { uint16_t AllocateSequenceNumber() override {
RTC_DCHECK(pacer_thread_.CalledOnValidThread()); RTC_DCHECK(pacer_thread_.IsCurrent());
rtc::CritScope lock(&crit_); rtc::CritScope lock(&crit_);
if (!seq_num_allocator_) if (!seq_num_allocator_)
return 0; return 0;
@ -373,7 +373,7 @@ class RtpPacketSenderProxy : public RtpPacketSender {
RtpPacketSenderProxy() : rtp_packet_sender_(nullptr) {} RtpPacketSenderProxy() : rtp_packet_sender_(nullptr) {}
void SetPacketSender(RtpPacketSender* rtp_packet_sender) { void SetPacketSender(RtpPacketSender* rtp_packet_sender) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
rtc::CritScope lock(&crit_); rtc::CritScope lock(&crit_);
rtp_packet_sender_ = rtp_packet_sender; rtp_packet_sender_ = rtp_packet_sender;
} }
@ -660,7 +660,7 @@ ChannelSend::ChannelSend(Clock* clock,
"AudioEncoder", "AudioEncoder",
TaskQueueFactory::Priority::NORMAL)) { TaskQueueFactory::Priority::NORMAL)) {
RTC_DCHECK(module_process_thread); RTC_DCHECK(module_process_thread);
module_process_thread_checker_.DetachFromThread(); module_process_thread_checker_.Detach();
audio_coding_.reset(AudioCodingModule::Create(AudioCodingModule::Config())); audio_coding_.reset(AudioCodingModule::Create(AudioCodingModule::Config()));
@ -723,7 +723,7 @@ ChannelSend::ChannelSend(Clock* clock,
} }
ChannelSend::~ChannelSend() { ChannelSend::~ChannelSend() {
RTC_DCHECK(construction_thread_.CalledOnValidThread()); RTC_DCHECK(construction_thread_.IsCurrent());
if (media_transport_) { if (media_transport_) {
media_transport_->RemoveTargetTransferRateObserver(this); media_transport_->RemoveTargetTransferRateObserver(this);
@ -823,8 +823,8 @@ void ChannelSend::OnBitrateAllocation(BitrateAllocationUpdate update) {
// or on a TaskQueue via VideoSendStreamImpl::OnEncoderConfigurationChanged. // or on a TaskQueue via VideoSendStreamImpl::OnEncoderConfigurationChanged.
// TODO(solenberg): Figure out a good way to check this or enforce calling // TODO(solenberg): Figure out a good way to check this or enforce calling
// rules. // rules.
// RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() || // RTC_DCHECK(worker_thread_checker_.IsCurrent() ||
// module_process_thread_checker_.CalledOnValidThread()); // module_process_thread_checker_.IsCurrent());
rtc::CritScope lock(&bitrate_crit_section_); rtc::CritScope lock(&bitrate_crit_section_);
CallEncoder([&](AudioEncoder* encoder) { CallEncoder([&](AudioEncoder* encoder) {
@ -1152,7 +1152,7 @@ ANAStats ChannelSend::GetANAStatistics() const {
} }
RtpRtcp* ChannelSend::GetRtpRtcp() const { RtpRtcp* ChannelSend::GetRtpRtcp() const {
RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread()); RTC_DCHECK(module_process_thread_checker_.IsCurrent());
return _rtpRtcpModule.get(); return _rtpRtcpModule.get();
} }

View File

@ -38,12 +38,12 @@ NullAudioPoller::NullAudioPoller(AudioTransport* audio_transport)
} }
NullAudioPoller::~NullAudioPoller() { NullAudioPoller::~NullAudioPoller() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
rtc::Thread::Current()->Clear(this); rtc::Thread::Current()->Clear(this);
} }
void NullAudioPoller::OnMessage(rtc::Message* msg) { void NullAudioPoller::OnMessage(rtc::Message* msg) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// Buffer to hold the audio samples. // Buffer to hold the audio samples.
int16_t buffer[kNumSamples * kNumChannels]; int16_t buffer[kNumSamples * kNumChannels];

View File

@ -254,7 +254,7 @@ RtpVideoSender::RtpVideoSender(
frame_counts_(rtp_config.ssrcs.size()), frame_counts_(rtp_config.ssrcs.size()),
frame_count_observer_(observers.frame_count_observer) { frame_count_observer_(observers.frame_count_observer) {
RTC_DCHECK_EQ(rtp_config.ssrcs.size(), rtp_streams_.size()); RTC_DCHECK_EQ(rtp_config.ssrcs.size(), rtp_streams_.size());
module_process_thread_checker_.DetachFromThread(); module_process_thread_checker_.Detach();
// SSRCs are assumed to be sorted in the same order as |rtp_modules|. // SSRCs are assumed to be sorted in the same order as |rtp_modules|.
for (uint32_t ssrc : rtp_config.ssrcs) { for (uint32_t ssrc : rtp_config.ssrcs) {
// Restore state if it previously existed. // Restore state if it previously existed.

View File

@ -31,7 +31,7 @@ IncomingVideoStream::IncomingVideoStream(
TaskQueueFactory::Priority::HIGH)) {} TaskQueueFactory::Priority::HIGH)) {}
IncomingVideoStream::~IncomingVideoStream() { IncomingVideoStream::~IncomingVideoStream() {
RTC_DCHECK(main_thread_checker_.CalledOnValidThread()); RTC_DCHECK(main_thread_checker_.IsCurrent());
} }
void IncomingVideoStream::OnFrame(const VideoFrame& video_frame) { void IncomingVideoStream::OnFrame(const VideoFrame& video_frame) {

View File

@ -78,7 +78,7 @@ class SetLocalSessionDescriptionObserver
AndroidCallClient::AndroidCallClient() AndroidCallClient::AndroidCallClient()
: call_started_(false), pc_observer_(absl::make_unique<PCObserver>(this)) { : call_started_(false), pc_observer_(absl::make_unique<PCObserver>(this)) {
thread_checker_.DetachFromThread(); thread_checker_.Detach();
CreatePeerConnectionFactory(); CreatePeerConnectionFactory();
} }

View File

@ -60,7 +60,7 @@ class SetLocalSessionDescriptionObserver : public webrtc::SetSessionDescriptionO
ObjCCallClient::ObjCCallClient() ObjCCallClient::ObjCCallClient()
: call_started_(false), pc_observer_(absl::make_unique<PCObserver>(this)) { : call_started_(false), pc_observer_(absl::make_unique<PCObserver>(this)) {
thread_checker_.DetachFromThread(); thread_checker_.Detach();
CreatePeerConnectionFactory(); CreatePeerConnectionFactory();
} }

View File

@ -536,7 +536,7 @@ WebRtcVideoChannel::WebRtcVideoChannel(
"WebRTC-Video-BufferPacketsWithUnknownSsrc") "WebRTC-Video-BufferPacketsWithUnknownSsrc")
? new UnhandledPacketsBuffer() ? new UnhandledPacketsBuffer()
: nullptr) { : nullptr) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc;
sending_ = false; sending_ = false;

View File

@ -191,8 +191,8 @@ WebRtcVoiceEngine::WebRtcVoiceEngine(
audio_mixer_(audio_mixer), audio_mixer_(audio_mixer),
apm_(audio_processing) { apm_(audio_processing) {
// This may be called from any thread, so detach thread checkers. // This may be called from any thread, so detach thread checkers.
worker_thread_checker_.DetachFromThread(); worker_thread_checker_.Detach();
signal_thread_checker_.DetachFromThread(); signal_thread_checker_.Detach();
RTC_LOG(LS_INFO) << "WebRtcVoiceEngine::WebRtcVoiceEngine"; RTC_LOG(LS_INFO) << "WebRtcVoiceEngine::WebRtcVoiceEngine";
RTC_DCHECK(decoder_factory); RTC_DCHECK(decoder_factory);
RTC_DCHECK(encoder_factory); RTC_DCHECK(encoder_factory);
@ -201,7 +201,7 @@ WebRtcVoiceEngine::WebRtcVoiceEngine(
} }
WebRtcVoiceEngine::~WebRtcVoiceEngine() { WebRtcVoiceEngine::~WebRtcVoiceEngine() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_LOG(LS_INFO) << "WebRtcVoiceEngine::~WebRtcVoiceEngine"; RTC_LOG(LS_INFO) << "WebRtcVoiceEngine::~WebRtcVoiceEngine";
if (initialized_) { if (initialized_) {
StopAecDump(); StopAecDump();
@ -215,7 +215,7 @@ WebRtcVoiceEngine::~WebRtcVoiceEngine() {
} }
void WebRtcVoiceEngine::Init() { void WebRtcVoiceEngine::Init() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_LOG(LS_INFO) << "WebRtcVoiceEngine::Init"; RTC_LOG(LS_INFO) << "WebRtcVoiceEngine::Init";
// TaskQueue expects to be created/destroyed on the same thread. // TaskQueue expects to be created/destroyed on the same thread.
@ -290,7 +290,7 @@ void WebRtcVoiceEngine::Init() {
rtc::scoped_refptr<webrtc::AudioState> WebRtcVoiceEngine::GetAudioState() rtc::scoped_refptr<webrtc::AudioState> WebRtcVoiceEngine::GetAudioState()
const { const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
return audio_state_; return audio_state_;
} }
@ -299,13 +299,13 @@ VoiceMediaChannel* WebRtcVoiceEngine::CreateMediaChannel(
const MediaConfig& config, const MediaConfig& config,
const AudioOptions& options, const AudioOptions& options,
const webrtc::CryptoOptions& crypto_options) { const webrtc::CryptoOptions& crypto_options) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
return new WebRtcVoiceMediaChannel(this, config, options, crypto_options, return new WebRtcVoiceMediaChannel(this, config, options, crypto_options,
call); call);
} }
bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_LOG(LS_INFO) << "WebRtcVoiceEngine::ApplyOptions: " RTC_LOG(LS_INFO) << "WebRtcVoiceEngine::ApplyOptions: "
<< options_in.ToString(); << options_in.ToString();
AudioOptions options = options_in; // The options are modified below. AudioOptions options = options_in; // The options are modified below.
@ -541,17 +541,17 @@ bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) {
} }
const std::vector<AudioCodec>& WebRtcVoiceEngine::send_codecs() const { const std::vector<AudioCodec>& WebRtcVoiceEngine::send_codecs() const {
RTC_DCHECK(signal_thread_checker_.CalledOnValidThread()); RTC_DCHECK(signal_thread_checker_.IsCurrent());
return send_codecs_; return send_codecs_;
} }
const std::vector<AudioCodec>& WebRtcVoiceEngine::recv_codecs() const { const std::vector<AudioCodec>& WebRtcVoiceEngine::recv_codecs() const {
RTC_DCHECK(signal_thread_checker_.CalledOnValidThread()); RTC_DCHECK(signal_thread_checker_.IsCurrent());
return recv_codecs_; return recv_codecs_;
} }
RtpCapabilities WebRtcVoiceEngine::GetCapabilities() const { RtpCapabilities WebRtcVoiceEngine::GetCapabilities() const {
RTC_DCHECK(signal_thread_checker_.CalledOnValidThread()); RTC_DCHECK(signal_thread_checker_.IsCurrent());
RtpCapabilities capabilities; RtpCapabilities capabilities;
int id = 1; int id = 1;
capabilities.header_extensions.push_back( capabilities.header_extensions.push_back(
@ -562,13 +562,13 @@ RtpCapabilities WebRtcVoiceEngine::GetCapabilities() const {
} }
void WebRtcVoiceEngine::RegisterChannel(WebRtcVoiceMediaChannel* channel) { void WebRtcVoiceEngine::RegisterChannel(WebRtcVoiceMediaChannel* channel) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(channel); RTC_DCHECK(channel);
channels_.push_back(channel); channels_.push_back(channel);
} }
void WebRtcVoiceEngine::UnregisterChannel(WebRtcVoiceMediaChannel* channel) { void WebRtcVoiceEngine::UnregisterChannel(WebRtcVoiceMediaChannel* channel) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
auto it = absl::c_find(channels_, channel); auto it = absl::c_find(channels_, channel);
RTC_DCHECK(it != channels_.end()); RTC_DCHECK(it != channels_.end());
channels_.erase(it); channels_.erase(it);
@ -576,7 +576,7 @@ void WebRtcVoiceEngine::UnregisterChannel(WebRtcVoiceMediaChannel* channel) {
bool WebRtcVoiceEngine::StartAecDump(rtc::PlatformFile file, bool WebRtcVoiceEngine::StartAecDump(rtc::PlatformFile file,
int64_t max_size_bytes) { int64_t max_size_bytes) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
auto aec_dump = webrtc::AecDumpFactory::Create( auto aec_dump = webrtc::AecDumpFactory::Create(
file, max_size_bytes, low_priority_worker_queue_.get()); file, max_size_bytes, low_priority_worker_queue_.get());
if (!aec_dump) { if (!aec_dump) {
@ -587,7 +587,7 @@ bool WebRtcVoiceEngine::StartAecDump(rtc::PlatformFile file,
} }
void WebRtcVoiceEngine::StartAecDump(const std::string& filename) { void WebRtcVoiceEngine::StartAecDump(const std::string& filename) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
auto aec_dump = webrtc::AecDumpFactory::Create( auto aec_dump = webrtc::AecDumpFactory::Create(
filename, -1, low_priority_worker_queue_.get()); filename, -1, low_priority_worker_queue_.get());
@ -597,24 +597,24 @@ void WebRtcVoiceEngine::StartAecDump(const std::string& filename) {
} }
void WebRtcVoiceEngine::StopAecDump() { void WebRtcVoiceEngine::StopAecDump() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
apm()->DetachAecDump(); apm()->DetachAecDump();
} }
webrtc::AudioDeviceModule* WebRtcVoiceEngine::adm() { webrtc::AudioDeviceModule* WebRtcVoiceEngine::adm() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(adm_); RTC_DCHECK(adm_);
return adm_.get(); return adm_.get();
} }
webrtc::AudioProcessing* WebRtcVoiceEngine::apm() const { webrtc::AudioProcessing* WebRtcVoiceEngine::apm() const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(apm_); RTC_DCHECK(apm_);
return apm_.get(); return apm_.get();
} }
webrtc::AudioState* WebRtcVoiceEngine::audio_state() { webrtc::AudioState* WebRtcVoiceEngine::audio_state() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(audio_state_); RTC_DCHECK(audio_state_);
return audio_state_.get(); return audio_state_.get();
} }
@ -746,7 +746,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
} }
~WebRtcAudioSendStream() override { ~WebRtcAudioSendStream() override {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
ClearSource(); ClearSource();
call_->DestroyAudioSendStream(stream_); call_->DestroyAudioSendStream(stream_);
} }
@ -758,7 +758,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
} }
void SetRtpExtensions(const std::vector<webrtc::RtpExtension>& extensions) { void SetRtpExtensions(const std::vector<webrtc::RtpExtension>& extensions) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
config_.rtp.extensions = extensions; config_.rtp.extensions = extensions;
rtp_parameters_.header_extensions = extensions; rtp_parameters_.header_extensions = extensions;
ReconfigureAudioSendStream(); ReconfigureAudioSendStream();
@ -770,7 +770,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
} }
void SetMid(const std::string& mid) { void SetMid(const std::string& mid) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
if (config_.rtp.mid == mid) { if (config_.rtp.mid == mid) {
return; return;
} }
@ -780,14 +780,14 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
void SetFrameEncryptor( void SetFrameEncryptor(
rtc::scoped_refptr<webrtc::FrameEncryptorInterface> frame_encryptor) { rtc::scoped_refptr<webrtc::FrameEncryptorInterface> frame_encryptor) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
config_.frame_encryptor = frame_encryptor; config_.frame_encryptor = frame_encryptor;
ReconfigureAudioSendStream(); ReconfigureAudioSendStream();
} }
void SetAudioNetworkAdaptorConfig( void SetAudioNetworkAdaptorConfig(
const absl::optional<std::string>& audio_network_adaptor_config) { const absl::optional<std::string>& audio_network_adaptor_config) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
if (config_.audio_network_adaptor_config == audio_network_adaptor_config) { if (config_.audio_network_adaptor_config == audio_network_adaptor_config) {
return; return;
} }
@ -797,7 +797,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
} }
bool SetMaxSendBitrate(int bps) { bool SetMaxSendBitrate(int bps) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(config_.send_codec_spec); RTC_DCHECK(config_.send_codec_spec);
RTC_DCHECK(audio_codec_spec_); RTC_DCHECK(audio_codec_spec_);
auto send_rate = ComputeSendBitrate( auto send_rate = ComputeSendBitrate(
@ -820,32 +820,32 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
int payload_freq, int payload_freq,
int event, int event,
int duration_ms) { int duration_ms) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(stream_); RTC_DCHECK(stream_);
return stream_->SendTelephoneEvent(payload_type, payload_freq, event, return stream_->SendTelephoneEvent(payload_type, payload_freq, event,
duration_ms); duration_ms);
} }
void SetSend(bool send) { void SetSend(bool send) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
send_ = send; send_ = send;
UpdateSendState(); UpdateSendState();
} }
void SetMuted(bool muted) { void SetMuted(bool muted) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(stream_); RTC_DCHECK(stream_);
stream_->SetMuted(muted); stream_->SetMuted(muted);
muted_ = muted; muted_ = muted;
} }
bool muted() const { bool muted() const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
return muted_; return muted_;
} }
webrtc::AudioSendStream::Stats GetStats(bool has_remote_tracks) const { webrtc::AudioSendStream::Stats GetStats(bool has_remote_tracks) const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(stream_); RTC_DCHECK(stream_);
return stream_->GetStats(has_remote_tracks); return stream_->GetStats(has_remote_tracks);
} }
@ -855,7 +855,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
// This method is called on the libjingle worker thread. // This method is called on the libjingle worker thread.
// TODO(xians): Make sure Start() is called only once. // TODO(xians): Make sure Start() is called only once.
void SetSource(AudioSource* source) { void SetSource(AudioSource* source) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(source); RTC_DCHECK(source);
if (source_) { if (source_) {
RTC_DCHECK(source_ == source); RTC_DCHECK(source_ == source);
@ -870,7 +870,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
// callback will be received after this method. // callback will be received after this method.
// This method is called on the libjingle worker thread. // This method is called on the libjingle worker thread.
void ClearSource() { void ClearSource() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
if (source_) { if (source_) {
source_->SetSink(nullptr); source_->SetSink(nullptr);
source_ = nullptr; source_ = nullptr;
@ -899,7 +899,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
// Callback from the |source_| when it is going away. In case Start() has // Callback from the |source_| when it is going away. In case Start() has
// never been called, this callback won't be triggered. // never been called, this callback won't be triggered.
void OnClose() override { void OnClose() override {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
// Set |source_| to nullptr to make sure no more callback will get into // Set |source_| to nullptr to make sure no more callback will get into
// the source. // the source.
source_ = nullptr; source_ = nullptr;
@ -961,7 +961,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
private: private:
void UpdateSendState() { void UpdateSendState() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(stream_); RTC_DCHECK(stream_);
RTC_DCHECK_EQ(1UL, rtp_parameters_.encodings.size()); RTC_DCHECK_EQ(1UL, rtp_parameters_.encodings.size());
if (send_ && source_ != nullptr && rtp_parameters_.encodings[0].active) { if (send_ && source_ != nullptr && rtp_parameters_.encodings[0].active) {
@ -972,7 +972,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
} }
void UpdateAllowedBitrateRange() { void UpdateAllowedBitrateRange() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
const bool is_opus = const bool is_opus =
config_.send_codec_spec && config_.send_codec_spec &&
absl::EqualsIgnoreCase(config_.send_codec_spec->format.name, absl::EqualsIgnoreCase(config_.send_codec_spec->format.name,
@ -986,7 +986,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
void UpdateSendCodecSpec( void UpdateSendCodecSpec(
const webrtc::AudioSendStream::Config::SendCodecSpec& send_codec_spec) { const webrtc::AudioSendStream::Config::SendCodecSpec& send_codec_spec) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
config_.send_codec_spec = send_codec_spec; config_.send_codec_spec = send_codec_spec;
auto info = auto info =
config_.encoder_factory->QueryAudioEncoder(send_codec_spec.format); config_.encoder_factory->QueryAudioEncoder(send_codec_spec.format);
@ -1010,7 +1010,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
} }
void ReconfigureAudioSendStream() { void ReconfigureAudioSendStream() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(stream_); RTC_DCHECK(stream_);
stream_->Reconfigure(config_); stream_->Reconfigure(config_);
} }
@ -1084,26 +1084,26 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
} }
~WebRtcAudioReceiveStream() { ~WebRtcAudioReceiveStream() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
call_->DestroyAudioReceiveStream(stream_); call_->DestroyAudioReceiveStream(stream_);
} }
void SetFrameDecryptor( void SetFrameDecryptor(
rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor) { rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
config_.frame_decryptor = frame_decryptor; config_.frame_decryptor = frame_decryptor;
RecreateAudioReceiveStream(); RecreateAudioReceiveStream();
} }
void SetLocalSsrc(uint32_t local_ssrc) { void SetLocalSsrc(uint32_t local_ssrc) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
config_.rtp.local_ssrc = local_ssrc; config_.rtp.local_ssrc = local_ssrc;
ReconfigureAudioReceiveStream(); ReconfigureAudioReceiveStream();
} }
void SetUseTransportCcAndRecreateStream(bool use_transport_cc, void SetUseTransportCcAndRecreateStream(bool use_transport_cc,
bool use_nack) { bool use_nack) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
config_.rtp.transport_cc = use_transport_cc; config_.rtp.transport_cc = use_transport_cc;
config_.rtp.nack.rtp_history_ms = use_nack ? kNackRtpHistoryMs : 0; config_.rtp.nack.rtp_history_ms = use_nack ? kNackRtpHistoryMs : 0;
ReconfigureAudioReceiveStream(); ReconfigureAudioReceiveStream();
@ -1111,21 +1111,21 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
void SetRtpExtensionsAndRecreateStream( void SetRtpExtensionsAndRecreateStream(
const std::vector<webrtc::RtpExtension>& extensions) { const std::vector<webrtc::RtpExtension>& extensions) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
config_.rtp.extensions = extensions; config_.rtp.extensions = extensions;
RecreateAudioReceiveStream(); RecreateAudioReceiveStream();
} }
// Set a new payload type -> decoder map. // Set a new payload type -> decoder map.
void SetDecoderMap(const std::map<int, webrtc::SdpAudioFormat>& decoder_map) { void SetDecoderMap(const std::map<int, webrtc::SdpAudioFormat>& decoder_map) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
config_.decoder_map = decoder_map; config_.decoder_map = decoder_map;
ReconfigureAudioReceiveStream(); ReconfigureAudioReceiveStream();
} }
void MaybeRecreateAudioReceiveStream( void MaybeRecreateAudioReceiveStream(
const std::vector<std::string>& stream_ids) { const std::vector<std::string>& stream_ids) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
std::string sync_group; std::string sync_group;
if (!stream_ids.empty()) { if (!stream_ids.empty()) {
sync_group = stream_ids[0]; sync_group = stream_ids[0];
@ -1140,13 +1140,13 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
} }
webrtc::AudioReceiveStream::Stats GetStats() const { webrtc::AudioReceiveStream::Stats GetStats() const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(stream_); RTC_DCHECK(stream_);
return stream_->GetStats(); return stream_->GetStats();
} }
void SetRawAudioSink(std::unique_ptr<webrtc::AudioSinkInterface> sink) { void SetRawAudioSink(std::unique_ptr<webrtc::AudioSinkInterface> sink) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
// Need to update the stream's sink first; once raw_audio_sink_ is // Need to update the stream's sink first; once raw_audio_sink_ is
// reassigned, whatever was in there before is destroyed. // reassigned, whatever was in there before is destroyed.
stream_->SetSink(sink.get()); stream_->SetSink(sink.get());
@ -1154,13 +1154,13 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
} }
void SetOutputVolume(double volume) { void SetOutputVolume(double volume) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
output_volume_ = volume; output_volume_ = volume;
stream_->SetGain(volume); stream_->SetGain(volume);
} }
void SetPlayout(bool playout) { void SetPlayout(bool playout) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(stream_); RTC_DCHECK(stream_);
if (playout) { if (playout) {
stream_->Start(); stream_->Start();
@ -1171,7 +1171,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
} }
bool SetBaseMinimumPlayoutDelayMs(int delay_ms) { bool SetBaseMinimumPlayoutDelayMs(int delay_ms) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(stream_); RTC_DCHECK(stream_);
if (stream_->SetBaseMinimumPlayoutDelayMs(delay_ms)) { if (stream_->SetBaseMinimumPlayoutDelayMs(delay_ms)) {
// Memorize only valid delay because during stream recreation it will be // Memorize only valid delay because during stream recreation it will be
@ -1188,13 +1188,13 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
} }
int GetBaseMinimumPlayoutDelayMs() const { int GetBaseMinimumPlayoutDelayMs() const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(stream_); RTC_DCHECK(stream_);
return stream_->GetBaseMinimumPlayoutDelayMs(); return stream_->GetBaseMinimumPlayoutDelayMs();
} }
std::vector<webrtc::RtpSource> GetSources() { std::vector<webrtc::RtpSource> GetSources() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(stream_); RTC_DCHECK(stream_);
return stream_->GetSources(); return stream_->GetSources();
} }
@ -1210,7 +1210,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
private: private:
void RecreateAudioReceiveStream() { void RecreateAudioReceiveStream() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
if (stream_) { if (stream_) {
call_->DestroyAudioReceiveStream(stream_); call_->DestroyAudioReceiveStream(stream_);
} }
@ -1222,7 +1222,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
} }
void ReconfigureAudioReceiveStream() { void ReconfigureAudioReceiveStream() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(stream_); RTC_DCHECK(stream_);
stream_->Reconfigure(config_); stream_->Reconfigure(config_);
} }
@ -1258,7 +1258,7 @@ WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel(
} }
WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel() { WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel"; RTC_LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel";
// TODO(solenberg): Should be able to delete the streams directly, without // TODO(solenberg): Should be able to delete the streams directly, without
// going through RemoveNnStream(), once stream objects handle // going through RemoveNnStream(), once stream objects handle
@ -1275,7 +1275,7 @@ WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel() {
bool WebRtcVoiceMediaChannel::SetSendParameters( bool WebRtcVoiceMediaChannel::SetSendParameters(
const AudioSendParameters& params) { const AudioSendParameters& params) {
TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::SetSendParameters"); TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::SetSendParameters");
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetSendParameters: " RTC_LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetSendParameters: "
<< params.ToString(); << params.ToString();
// TODO(pthatcher): Refactor this to be more clean now that we have // TODO(pthatcher): Refactor this to be more clean now that we have
@ -1320,7 +1320,7 @@ bool WebRtcVoiceMediaChannel::SetSendParameters(
bool WebRtcVoiceMediaChannel::SetRecvParameters( bool WebRtcVoiceMediaChannel::SetRecvParameters(
const AudioRecvParameters& params) { const AudioRecvParameters& params) {
TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::SetRecvParameters"); TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::SetRecvParameters");
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetRecvParameters: " RTC_LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetRecvParameters: "
<< params.ToString(); << params.ToString();
// TODO(pthatcher): Refactor this to be more clean now that we have // TODO(pthatcher): Refactor this to be more clean now that we have
@ -1346,7 +1346,7 @@ bool WebRtcVoiceMediaChannel::SetRecvParameters(
webrtc::RtpParameters WebRtcVoiceMediaChannel::GetRtpSendParameters( webrtc::RtpParameters WebRtcVoiceMediaChannel::GetRtpSendParameters(
uint32_t ssrc) const { uint32_t ssrc) const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
auto it = send_streams_.find(ssrc); auto it = send_streams_.find(ssrc);
if (it == send_streams_.end()) { if (it == send_streams_.end()) {
RTC_LOG(LS_WARNING) << "Attempting to get RTP send parameters for stream " RTC_LOG(LS_WARNING) << "Attempting to get RTP send parameters for stream "
@ -1366,7 +1366,7 @@ webrtc::RtpParameters WebRtcVoiceMediaChannel::GetRtpSendParameters(
webrtc::RTCError WebRtcVoiceMediaChannel::SetRtpSendParameters( webrtc::RTCError WebRtcVoiceMediaChannel::SetRtpSendParameters(
uint32_t ssrc, uint32_t ssrc,
const webrtc::RtpParameters& parameters) { const webrtc::RtpParameters& parameters) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
auto it = send_streams_.find(ssrc); auto it = send_streams_.find(ssrc);
if (it == send_streams_.end()) { if (it == send_streams_.end()) {
RTC_LOG(LS_WARNING) << "Attempting to set RTP send parameters for stream " RTC_LOG(LS_WARNING) << "Attempting to set RTP send parameters for stream "
@ -1419,7 +1419,7 @@ webrtc::RTCError WebRtcVoiceMediaChannel::SetRtpSendParameters(
webrtc::RtpParameters WebRtcVoiceMediaChannel::GetRtpReceiveParameters( webrtc::RtpParameters WebRtcVoiceMediaChannel::GetRtpReceiveParameters(
uint32_t ssrc) const { uint32_t ssrc) const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
webrtc::RtpParameters rtp_params; webrtc::RtpParameters rtp_params;
// SSRC of 0 represents the default receive stream. // SSRC of 0 represents the default receive stream.
if (ssrc == 0) { if (ssrc == 0) {
@ -1451,7 +1451,7 @@ webrtc::RtpParameters WebRtcVoiceMediaChannel::GetRtpReceiveParameters(
bool WebRtcVoiceMediaChannel::SetRtpReceiveParameters( bool WebRtcVoiceMediaChannel::SetRtpReceiveParameters(
uint32_t ssrc, uint32_t ssrc,
const webrtc::RtpParameters& parameters) { const webrtc::RtpParameters& parameters) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
// SSRC of 0 represents the default receive stream. // SSRC of 0 represents the default receive stream.
if (ssrc == 0) { if (ssrc == 0) {
if (!default_sink_) { if (!default_sink_) {
@ -1481,7 +1481,7 @@ bool WebRtcVoiceMediaChannel::SetRtpReceiveParameters(
} }
bool WebRtcVoiceMediaChannel::SetOptions(const AudioOptions& options) { bool WebRtcVoiceMediaChannel::SetOptions(const AudioOptions& options) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_LOG(LS_INFO) << "Setting voice channel options: " << options.ToString(); RTC_LOG(LS_INFO) << "Setting voice channel options: " << options.ToString();
// We retain all of the existing options, and apply the given ones // We retain all of the existing options, and apply the given ones
@ -1507,7 +1507,7 @@ bool WebRtcVoiceMediaChannel::SetOptions(const AudioOptions& options) {
bool WebRtcVoiceMediaChannel::SetRecvCodecs( bool WebRtcVoiceMediaChannel::SetRecvCodecs(
const std::vector<AudioCodec>& codecs) { const std::vector<AudioCodec>& codecs) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
// Set the payload types to be used for incoming media. // Set the payload types to be used for incoming media.
RTC_LOG(LS_INFO) << "Setting receive voice codecs."; RTC_LOG(LS_INFO) << "Setting receive voice codecs.";
@ -1586,7 +1586,7 @@ bool WebRtcVoiceMediaChannel::SetRecvCodecs(
// and receive streams may be reconfigured based on the new settings. // and receive streams may be reconfigured based on the new settings.
bool WebRtcVoiceMediaChannel::SetSendCodecs( bool WebRtcVoiceMediaChannel::SetSendCodecs(
const std::vector<AudioCodec>& codecs) { const std::vector<AudioCodec>& codecs) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
dtmf_payload_type_ = absl::nullopt; dtmf_payload_type_ = absl::nullopt;
dtmf_payload_freq_ = -1; dtmf_payload_freq_ = -1;
@ -1720,7 +1720,7 @@ void WebRtcVoiceMediaChannel::SetPlayout(bool playout) {
void WebRtcVoiceMediaChannel::ChangePlayout(bool playout) { void WebRtcVoiceMediaChannel::ChangePlayout(bool playout) {
TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::ChangePlayout"); TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::ChangePlayout");
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
if (playout_ == playout) { if (playout_ == playout) {
return; return;
} }
@ -1763,7 +1763,7 @@ bool WebRtcVoiceMediaChannel::SetAudioSend(uint32_t ssrc,
bool enable, bool enable,
const AudioOptions* options, const AudioOptions* options,
AudioSource* source) { AudioSource* source) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
// TODO(solenberg): The state change should be fully rolled back if any one of // TODO(solenberg): The state change should be fully rolled back if any one of
// these calls fail. // these calls fail.
if (!SetLocalSource(ssrc, source)) { if (!SetLocalSource(ssrc, source)) {
@ -1780,7 +1780,7 @@ bool WebRtcVoiceMediaChannel::SetAudioSend(uint32_t ssrc,
bool WebRtcVoiceMediaChannel::AddSendStream(const StreamParams& sp) { bool WebRtcVoiceMediaChannel::AddSendStream(const StreamParams& sp) {
TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::AddSendStream"); TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::AddSendStream");
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_LOG(LS_INFO) << "AddSendStream: " << sp.ToString(); RTC_LOG(LS_INFO) << "AddSendStream: " << sp.ToString();
uint32_t ssrc = sp.first_ssrc(); uint32_t ssrc = sp.first_ssrc();
@ -1819,7 +1819,7 @@ bool WebRtcVoiceMediaChannel::AddSendStream(const StreamParams& sp) {
bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) { bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) {
TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveSendStream"); TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveSendStream");
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_LOG(LS_INFO) << "RemoveSendStream: " << ssrc; RTC_LOG(LS_INFO) << "RemoveSendStream: " << ssrc;
auto it = send_streams_.find(ssrc); auto it = send_streams_.find(ssrc);
@ -1845,7 +1845,7 @@ bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) {
bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) { bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) {
TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::AddRecvStream"); TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::AddRecvStream");
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_LOG(LS_INFO) << "AddRecvStream: " << sp.ToString(); RTC_LOG(LS_INFO) << "AddRecvStream: " << sp.ToString();
if (!sp.has_ssrcs()) { if (!sp.has_ssrcs()) {
@ -1896,7 +1896,7 @@ bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) {
bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) { bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) {
TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveRecvStream"); TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveRecvStream");
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_LOG(LS_INFO) << "RemoveRecvStream: " << ssrc; RTC_LOG(LS_INFO) << "RemoveRecvStream: " << ssrc;
if (ssrc == 0) { if (ssrc == 0) {
@ -1945,7 +1945,7 @@ bool WebRtcVoiceMediaChannel::SetLocalSource(uint32_t ssrc,
} }
bool WebRtcVoiceMediaChannel::SetOutputVolume(uint32_t ssrc, double volume) { bool WebRtcVoiceMediaChannel::SetOutputVolume(uint32_t ssrc, double volume) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
std::vector<uint32_t> ssrcs(1, ssrc); std::vector<uint32_t> ssrcs(1, ssrc);
// SSRC of 0 represents the default receive stream. // SSRC of 0 represents the default receive stream.
if (ssrc == 0) { if (ssrc == 0) {
@ -1967,7 +1967,7 @@ bool WebRtcVoiceMediaChannel::SetOutputVolume(uint32_t ssrc, double volume) {
bool WebRtcVoiceMediaChannel::SetBaseMinimumPlayoutDelayMs(uint32_t ssrc, bool WebRtcVoiceMediaChannel::SetBaseMinimumPlayoutDelayMs(uint32_t ssrc,
int delay_ms) { int delay_ms) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
std::vector<uint32_t> ssrcs(1, ssrc); std::vector<uint32_t> ssrcs(1, ssrc);
// SSRC of 0 represents the default receive stream. // SSRC of 0 represents the default receive stream.
if (ssrc == 0) { if (ssrc == 0) {
@ -2010,7 +2010,7 @@ bool WebRtcVoiceMediaChannel::CanInsertDtmf() {
void WebRtcVoiceMediaChannel::SetFrameDecryptor( void WebRtcVoiceMediaChannel::SetFrameDecryptor(
uint32_t ssrc, uint32_t ssrc,
rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor) { rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
auto matching_stream = recv_streams_.find(ssrc); auto matching_stream = recv_streams_.find(ssrc);
if (matching_stream != recv_streams_.end()) { if (matching_stream != recv_streams_.end()) {
matching_stream->second->SetFrameDecryptor(frame_decryptor); matching_stream->second->SetFrameDecryptor(frame_decryptor);
@ -2024,7 +2024,7 @@ void WebRtcVoiceMediaChannel::SetFrameDecryptor(
void WebRtcVoiceMediaChannel::SetFrameEncryptor( void WebRtcVoiceMediaChannel::SetFrameEncryptor(
uint32_t ssrc, uint32_t ssrc,
rtc::scoped_refptr<webrtc::FrameEncryptorInterface> frame_encryptor) { rtc::scoped_refptr<webrtc::FrameEncryptorInterface> frame_encryptor) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
auto matching_stream = send_streams_.find(ssrc); auto matching_stream = send_streams_.find(ssrc);
if (matching_stream != send_streams_.end()) { if (matching_stream != send_streams_.end()) {
matching_stream->second->SetFrameEncryptor(frame_encryptor); matching_stream->second->SetFrameEncryptor(frame_encryptor);
@ -2034,7 +2034,7 @@ void WebRtcVoiceMediaChannel::SetFrameEncryptor(
bool WebRtcVoiceMediaChannel::InsertDtmf(uint32_t ssrc, bool WebRtcVoiceMediaChannel::InsertDtmf(uint32_t ssrc,
int event, int event,
int duration) { int duration) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_LOG(LS_INFO) << "WebRtcVoiceMediaChannel::InsertDtmf"; RTC_LOG(LS_INFO) << "WebRtcVoiceMediaChannel::InsertDtmf";
if (!CanInsertDtmf()) { if (!CanInsertDtmf()) {
return false; return false;
@ -2057,7 +2057,7 @@ bool WebRtcVoiceMediaChannel::InsertDtmf(uint32_t ssrc,
void WebRtcVoiceMediaChannel::OnPacketReceived(rtc::CopyOnWriteBuffer packet, void WebRtcVoiceMediaChannel::OnPacketReceived(rtc::CopyOnWriteBuffer packet,
int64_t packet_time_us) { int64_t packet_time_us) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
webrtc::PacketReceiver::DeliveryStatus delivery_result = webrtc::PacketReceiver::DeliveryStatus delivery_result =
call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, packet, call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, packet,
@ -2120,7 +2120,7 @@ void WebRtcVoiceMediaChannel::OnPacketReceived(rtc::CopyOnWriteBuffer packet,
void WebRtcVoiceMediaChannel::OnRtcpReceived(rtc::CopyOnWriteBuffer packet, void WebRtcVoiceMediaChannel::OnRtcpReceived(rtc::CopyOnWriteBuffer packet,
int64_t packet_time_us) { int64_t packet_time_us) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
// Forward packet to Call as well. // Forward packet to Call as well.
call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, packet, call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, packet,
@ -2130,14 +2130,14 @@ void WebRtcVoiceMediaChannel::OnRtcpReceived(rtc::CopyOnWriteBuffer packet,
void WebRtcVoiceMediaChannel::OnNetworkRouteChanged( void WebRtcVoiceMediaChannel::OnNetworkRouteChanged(
const std::string& transport_name, const std::string& transport_name,
const rtc::NetworkRoute& network_route) { const rtc::NetworkRoute& network_route) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
call_->GetTransportControllerSend()->OnNetworkRouteChanged(transport_name, call_->GetTransportControllerSend()->OnNetworkRouteChanged(transport_name,
network_route); network_route);
call_->OnAudioTransportOverheadChanged(network_route.packet_overhead); call_->OnAudioTransportOverheadChanged(network_route.packet_overhead);
} }
bool WebRtcVoiceMediaChannel::MuteStream(uint32_t ssrc, bool muted) { bool WebRtcVoiceMediaChannel::MuteStream(uint32_t ssrc, bool muted) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
const auto it = send_streams_.find(ssrc); const auto it = send_streams_.find(ssrc);
if (it == send_streams_.end()) { if (it == send_streams_.end()) {
RTC_LOG(LS_WARNING) << "The specified ssrc " << ssrc << " is not in use."; RTC_LOG(LS_WARNING) << "The specified ssrc " << ssrc << " is not in use.";
@ -2172,7 +2172,7 @@ bool WebRtcVoiceMediaChannel::SetMaxSendBitrate(int bps) {
} }
void WebRtcVoiceMediaChannel::OnReadyToSend(bool ready) { void WebRtcVoiceMediaChannel::OnReadyToSend(bool ready) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_LOG(LS_VERBOSE) << "OnReadyToSend: " << (ready ? "Ready." : "Not ready."); RTC_LOG(LS_VERBOSE) << "OnReadyToSend: " << (ready ? "Ready." : "Not ready.");
call_->SignalChannelNetworkState( call_->SignalChannelNetworkState(
webrtc::MediaType::AUDIO, webrtc::MediaType::AUDIO,
@ -2181,7 +2181,7 @@ void WebRtcVoiceMediaChannel::OnReadyToSend(bool ready) {
bool WebRtcVoiceMediaChannel::GetStats(VoiceMediaInfo* info) { bool WebRtcVoiceMediaChannel::GetStats(VoiceMediaInfo* info) {
TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::GetStats"); TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::GetStats");
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_DCHECK(info); RTC_DCHECK(info);
// Get SSRC and stats for each sender. // Get SSRC and stats for each sender.
@ -2292,7 +2292,7 @@ bool WebRtcVoiceMediaChannel::GetStats(VoiceMediaInfo* info) {
void WebRtcVoiceMediaChannel::SetRawAudioSink( void WebRtcVoiceMediaChannel::SetRawAudioSink(
uint32_t ssrc, uint32_t ssrc,
std::unique_ptr<webrtc::AudioSinkInterface> sink) { std::unique_ptr<webrtc::AudioSinkInterface> sink) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
RTC_LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::SetRawAudioSink: ssrc:" RTC_LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::SetRawAudioSink: ssrc:"
<< ssrc << " " << (sink ? "(ptr)" : "NULL"); << ssrc << " " << (sink ? "(ptr)" : "NULL");
if (ssrc == 0) { if (ssrc == 0) {
@ -2325,7 +2325,7 @@ std::vector<webrtc::RtpSource> WebRtcVoiceMediaChannel::GetSources(
bool WebRtcVoiceMediaChannel::MaybeDeregisterUnsignaledRecvStream( bool WebRtcVoiceMediaChannel::MaybeDeregisterUnsignaledRecvStream(
uint32_t ssrc) { uint32_t ssrc) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
auto it = absl::c_find(unsignaled_recv_ssrcs_, ssrc); auto it = absl::c_find(unsignaled_recv_ssrcs_, ssrc);
if (it != unsignaled_recv_ssrcs_.end()) { if (it != unsignaled_recv_ssrcs_.end()) {
unsignaled_recv_ssrcs_.erase(it); unsignaled_recv_ssrcs_.erase(it);

View File

@ -27,7 +27,7 @@ AAudioPlayer::AAudioPlayer(AudioManager* audio_manager)
: main_thread_(rtc::Thread::Current()), : main_thread_(rtc::Thread::Current()),
aaudio_(audio_manager, AAUDIO_DIRECTION_OUTPUT, this) { aaudio_(audio_manager, AAUDIO_DIRECTION_OUTPUT, this) {
RTC_LOG(INFO) << "ctor"; RTC_LOG(INFO) << "ctor";
thread_checker_aaudio_.DetachFromThread(); thread_checker_aaudio_.Detach();
} }
AAudioPlayer::~AAudioPlayer() { AAudioPlayer::~AAudioPlayer() {
@ -101,7 +101,7 @@ int AAudioPlayer::StopPlayout() {
RTC_LOG(LS_ERROR) << "StopPlayout failed"; RTC_LOG(LS_ERROR) << "StopPlayout failed";
return -1; return -1;
} }
thread_checker_aaudio_.DetachFromThread(); thread_checker_aaudio_.Detach();
initialized_ = false; initialized_ = false;
playing_ = false; playing_ = false;
return 0; return 0;

View File

@ -29,19 +29,19 @@ AAudioRecorder::AAudioRecorder(AudioManager* audio_manager)
: main_thread_(rtc::Thread::Current()), : main_thread_(rtc::Thread::Current()),
aaudio_(audio_manager, AAUDIO_DIRECTION_INPUT, this) { aaudio_(audio_manager, AAUDIO_DIRECTION_INPUT, this) {
RTC_LOG(INFO) << "ctor"; RTC_LOG(INFO) << "ctor";
thread_checker_aaudio_.DetachFromThread(); thread_checker_aaudio_.Detach();
} }
AAudioRecorder::~AAudioRecorder() { AAudioRecorder::~AAudioRecorder() {
RTC_LOG(INFO) << "dtor"; RTC_LOG(INFO) << "dtor";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
Terminate(); Terminate();
RTC_LOG(INFO) << "detected owerflows: " << overflow_count_; RTC_LOG(INFO) << "detected owerflows: " << overflow_count_;
} }
int AAudioRecorder::Init() { int AAudioRecorder::Init() {
RTC_LOG(INFO) << "Init"; RTC_LOG(INFO) << "Init";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (aaudio_.audio_parameters().channels() == 2) { if (aaudio_.audio_parameters().channels() == 2) {
RTC_DLOG(LS_WARNING) << "Stereo mode is enabled"; RTC_DLOG(LS_WARNING) << "Stereo mode is enabled";
} }
@ -50,14 +50,14 @@ int AAudioRecorder::Init() {
int AAudioRecorder::Terminate() { int AAudioRecorder::Terminate() {
RTC_LOG(INFO) << "Terminate"; RTC_LOG(INFO) << "Terminate";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
StopRecording(); StopRecording();
return 0; return 0;
} }
int AAudioRecorder::InitRecording() { int AAudioRecorder::InitRecording() {
RTC_LOG(INFO) << "InitRecording"; RTC_LOG(INFO) << "InitRecording";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!initialized_); RTC_DCHECK(!initialized_);
RTC_DCHECK(!recording_); RTC_DCHECK(!recording_);
if (!aaudio_.Init()) { if (!aaudio_.Init()) {
@ -69,7 +69,7 @@ int AAudioRecorder::InitRecording() {
int AAudioRecorder::StartRecording() { int AAudioRecorder::StartRecording() {
RTC_LOG(INFO) << "StartRecording"; RTC_LOG(INFO) << "StartRecording";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(initialized_); RTC_DCHECK(initialized_);
RTC_DCHECK(!recording_); RTC_DCHECK(!recording_);
if (fine_audio_buffer_) { if (fine_audio_buffer_) {
@ -86,14 +86,14 @@ int AAudioRecorder::StartRecording() {
int AAudioRecorder::StopRecording() { int AAudioRecorder::StopRecording() {
RTC_LOG(INFO) << "StopRecording"; RTC_LOG(INFO) << "StopRecording";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!initialized_ || !recording_) { if (!initialized_ || !recording_) {
return 0; return 0;
} }
if (!aaudio_.Stop()) { if (!aaudio_.Stop()) {
return -1; return -1;
} }
thread_checker_aaudio_.DetachFromThread(); thread_checker_aaudio_.Detach();
initialized_ = false; initialized_ = false;
recording_ = false; recording_ = false;
return 0; return 0;
@ -101,7 +101,7 @@ int AAudioRecorder::StopRecording() {
void AAudioRecorder::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) { void AAudioRecorder::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
RTC_LOG(INFO) << "AttachAudioBuffer"; RTC_LOG(INFO) << "AttachAudioBuffer";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
audio_device_buffer_ = audioBuffer; audio_device_buffer_ = audioBuffer;
const AudioParameters audio_parameters = aaudio_.audio_parameters(); const AudioParameters audio_parameters = aaudio_.audio_parameters();
audio_device_buffer_->SetRecordingSampleRate(audio_parameters.sample_rate()); audio_device_buffer_->SetRecordingSampleRate(audio_parameters.sample_rate());
@ -133,7 +133,7 @@ int AAudioRecorder::EnableBuiltInNS(bool enable) {
void AAudioRecorder::OnErrorCallback(aaudio_result_t error) { void AAudioRecorder::OnErrorCallback(aaudio_result_t error) {
RTC_LOG(LS_ERROR) << "OnErrorCallback: " << AAudio_convertResultToText(error); RTC_LOG(LS_ERROR) << "OnErrorCallback: " << AAudio_convertResultToText(error);
// RTC_DCHECK(thread_checker_aaudio_.CalledOnValidThread()); // RTC_DCHECK(thread_checker_aaudio_.IsCurrent());
if (aaudio_.stream_state() == AAUDIO_STREAM_STATE_DISCONNECTED) { if (aaudio_.stream_state() == AAUDIO_STREAM_STATE_DISCONNECTED) {
// The stream is disconnected and any attempt to use it will return // The stream is disconnected and any attempt to use it will return
// AAUDIO_ERROR_DISCONNECTED.. // AAUDIO_ERROR_DISCONNECTED..
@ -153,7 +153,7 @@ aaudio_data_callback_result_t AAudioRecorder::OnDataCallback(
void* audio_data, void* audio_data,
int32_t num_frames) { int32_t num_frames) {
// TODO(henrika): figure out why we sometimes hit this one. // TODO(henrika): figure out why we sometimes hit this one.
// RTC_DCHECK(thread_checker_aaudio_.CalledOnValidThread()); // RTC_DCHECK(thread_checker_aaudio_.IsCurrent());
// RTC_LOG(INFO) << "OnDataCallback: " << num_frames; // RTC_LOG(INFO) << "OnDataCallback: " << num_frames;
// Drain the input buffer at first callback to ensure that it does not // Drain the input buffer at first callback to ensure that it does not
// contain any old data. Will also ensure that the lowest possible latency // contain any old data. Will also ensure that the lowest possible latency

View File

@ -139,19 +139,19 @@ AAudioWrapper::AAudioWrapper(AudioManager* audio_manager,
direction_ == AAUDIO_DIRECTION_OUTPUT direction_ == AAUDIO_DIRECTION_OUTPUT
? audio_parameters_ = audio_manager->GetPlayoutAudioParameters() ? audio_parameters_ = audio_manager->GetPlayoutAudioParameters()
: audio_parameters_ = audio_manager->GetRecordAudioParameters(); : audio_parameters_ = audio_manager->GetRecordAudioParameters();
aaudio_thread_checker_.DetachFromThread(); aaudio_thread_checker_.Detach();
RTC_LOG(INFO) << audio_parameters_.ToString(); RTC_LOG(INFO) << audio_parameters_.ToString();
} }
AAudioWrapper::~AAudioWrapper() { AAudioWrapper::~AAudioWrapper() {
RTC_LOG(INFO) << "dtor"; RTC_LOG(INFO) << "dtor";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!stream_); RTC_DCHECK(!stream_);
} }
bool AAudioWrapper::Init() { bool AAudioWrapper::Init() {
RTC_LOG(INFO) << "Init"; RTC_LOG(INFO) << "Init";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// Creates a stream builder which can be used to open an audio stream. // Creates a stream builder which can be used to open an audio stream.
ScopedStreamBuilder builder; ScopedStreamBuilder builder;
// Configures the stream builder using audio parameters given at construction. // Configures the stream builder using audio parameters given at construction.
@ -175,7 +175,7 @@ bool AAudioWrapper::Init() {
bool AAudioWrapper::Start() { bool AAudioWrapper::Start() {
RTC_LOG(INFO) << "Start"; RTC_LOG(INFO) << "Start";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// TODO(henrika): this state check might not be needed. // TODO(henrika): this state check might not be needed.
aaudio_stream_state_t current_state = AAudioStream_getState(stream_); aaudio_stream_state_t current_state = AAudioStream_getState(stream_);
if (current_state != AAUDIO_STREAM_STATE_OPEN) { if (current_state != AAUDIO_STREAM_STATE_OPEN) {
@ -191,11 +191,11 @@ bool AAudioWrapper::Start() {
bool AAudioWrapper::Stop() { bool AAudioWrapper::Stop() {
RTC_LOG(INFO) << "Stop: " << DirectionToString(direction()); RTC_LOG(INFO) << "Stop: " << DirectionToString(direction());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// Asynchronous request for the stream to stop. // Asynchronous request for the stream to stop.
RETURN_ON_ERROR(AAudioStream_requestStop(stream_), false); RETURN_ON_ERROR(AAudioStream_requestStop(stream_), false);
CloseStream(); CloseStream();
aaudio_thread_checker_.DetachFromThread(); aaudio_thread_checker_.Detach();
return true; return true;
} }
@ -242,7 +242,7 @@ double AAudioWrapper::EstimateLatencyMillis() const {
bool AAudioWrapper::IncreaseOutputBufferSize() { bool AAudioWrapper::IncreaseOutputBufferSize() {
RTC_LOG(INFO) << "IncreaseBufferSize"; RTC_LOG(INFO) << "IncreaseBufferSize";
RTC_DCHECK(stream_); RTC_DCHECK(stream_);
RTC_DCHECK(aaudio_thread_checker_.CalledOnValidThread()); RTC_DCHECK(aaudio_thread_checker_.IsCurrent());
RTC_DCHECK_EQ(direction(), AAUDIO_DIRECTION_OUTPUT); RTC_DCHECK_EQ(direction(), AAUDIO_DIRECTION_OUTPUT);
aaudio_result_t buffer_size = AAudioStream_getBufferSizeInFrames(stream_); aaudio_result_t buffer_size = AAudioStream_getBufferSizeInFrames(stream_);
// Try to increase size of buffer with one burst to reduce risk of underrun. // Try to increase size of buffer with one burst to reduce risk of underrun.
@ -270,7 +270,7 @@ bool AAudioWrapper::IncreaseOutputBufferSize() {
void AAudioWrapper::ClearInputStream(void* audio_data, int32_t num_frames) { void AAudioWrapper::ClearInputStream(void* audio_data, int32_t num_frames) {
RTC_LOG(INFO) << "ClearInputStream"; RTC_LOG(INFO) << "ClearInputStream";
RTC_DCHECK(stream_); RTC_DCHECK(stream_);
RTC_DCHECK(aaudio_thread_checker_.CalledOnValidThread()); RTC_DCHECK(aaudio_thread_checker_.IsCurrent());
RTC_DCHECK_EQ(direction(), AAUDIO_DIRECTION_INPUT); RTC_DCHECK_EQ(direction(), AAUDIO_DIRECTION_INPUT);
aaudio_result_t cleared_frames = 0; aaudio_result_t cleared_frames = 0;
do { do {
@ -359,7 +359,7 @@ int64_t AAudioWrapper::frames_read() const {
void AAudioWrapper::SetStreamConfiguration(AAudioStreamBuilder* builder) { void AAudioWrapper::SetStreamConfiguration(AAudioStreamBuilder* builder) {
RTC_LOG(INFO) << "SetStreamConfiguration"; RTC_LOG(INFO) << "SetStreamConfiguration";
RTC_DCHECK(builder); RTC_DCHECK(builder);
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// Request usage of default primary output/input device. // Request usage of default primary output/input device.
// TODO(henrika): verify that default device follows Java APIs. // TODO(henrika): verify that default device follows Java APIs.
// https://developer.android.com/reference/android/media/AudioDeviceInfo.html. // https://developer.android.com/reference/android/media/AudioDeviceInfo.html.

View File

@ -55,7 +55,7 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
InitStatus Init() override { InitStatus Init() override {
RTC_LOG(INFO) << __FUNCTION__; RTC_LOG(INFO) << __FUNCTION__;
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!initialized_); RTC_DCHECK(!initialized_);
if (!audio_manager_->Init()) { if (!audio_manager_->Init()) {
return InitStatus::OTHER_ERROR; return InitStatus::OTHER_ERROR;
@ -75,7 +75,7 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
int32_t Terminate() override { int32_t Terminate() override {
RTC_LOG(INFO) << __FUNCTION__; RTC_LOG(INFO) << __FUNCTION__;
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
int32_t err = input_.Terminate(); int32_t err = input_.Terminate();
err |= output_.Terminate(); err |= output_.Terminate();
err |= !audio_manager_->Close(); err |= !audio_manager_->Close();
@ -86,7 +86,7 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
bool Initialized() const override { bool Initialized() const override {
RTC_LOG(INFO) << __FUNCTION__; RTC_LOG(INFO) << __FUNCTION__;
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return initialized_; return initialized_;
} }

View File

@ -84,14 +84,14 @@ AudioManager::AudioManager()
AudioManager::~AudioManager() { AudioManager::~AudioManager() {
RTC_LOG(INFO) << "dtor"; RTC_LOG(INFO) << "dtor";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
Close(); Close();
} }
void AudioManager::SetActiveAudioLayer( void AudioManager::SetActiveAudioLayer(
AudioDeviceModule::AudioLayer audio_layer) { AudioDeviceModule::AudioLayer audio_layer) {
RTC_LOG(INFO) << "SetActiveAudioLayer: " << audio_layer; RTC_LOG(INFO) << "SetActiveAudioLayer: " << audio_layer;
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!initialized_); RTC_DCHECK(!initialized_);
// Store the currently utilized audio layer. // Store the currently utilized audio layer.
audio_layer_ = audio_layer; audio_layer_ = audio_layer;
@ -109,7 +109,7 @@ void AudioManager::SetActiveAudioLayer(
SLObjectItf AudioManager::GetOpenSLEngine() { SLObjectItf AudioManager::GetOpenSLEngine() {
RTC_LOG(INFO) << "GetOpenSLEngine"; RTC_LOG(INFO) << "GetOpenSLEngine";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// Only allow usage of OpenSL ES if such an audio layer has been specified. // Only allow usage of OpenSL ES if such an audio layer has been specified.
if (audio_layer_ != AudioDeviceModule::kAndroidOpenSLESAudio && if (audio_layer_ != AudioDeviceModule::kAndroidOpenSLESAudio &&
audio_layer_ != audio_layer_ !=
@ -150,7 +150,7 @@ SLObjectItf AudioManager::GetOpenSLEngine() {
bool AudioManager::Init() { bool AudioManager::Init() {
RTC_LOG(INFO) << "Init"; RTC_LOG(INFO) << "Init";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!initialized_); RTC_DCHECK(!initialized_);
RTC_DCHECK_NE(audio_layer_, AudioDeviceModule::kPlatformDefaultAudio); RTC_DCHECK_NE(audio_layer_, AudioDeviceModule::kPlatformDefaultAudio);
if (!j_audio_manager_->Init()) { if (!j_audio_manager_->Init()) {
@ -163,7 +163,7 @@ bool AudioManager::Init() {
bool AudioManager::Close() { bool AudioManager::Close() {
RTC_LOG(INFO) << "Close"; RTC_LOG(INFO) << "Close";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!initialized_) if (!initialized_)
return true; return true;
j_audio_manager_->Close(); j_audio_manager_->Close();
@ -172,27 +172,27 @@ bool AudioManager::Close() {
} }
bool AudioManager::IsCommunicationModeEnabled() const { bool AudioManager::IsCommunicationModeEnabled() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return j_audio_manager_->IsCommunicationModeEnabled(); return j_audio_manager_->IsCommunicationModeEnabled();
} }
bool AudioManager::IsAcousticEchoCancelerSupported() const { bool AudioManager::IsAcousticEchoCancelerSupported() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return hardware_aec_; return hardware_aec_;
} }
bool AudioManager::IsAutomaticGainControlSupported() const { bool AudioManager::IsAutomaticGainControlSupported() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return hardware_agc_; return hardware_agc_;
} }
bool AudioManager::IsNoiseSuppressorSupported() const { bool AudioManager::IsNoiseSuppressorSupported() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return hardware_ns_; return hardware_ns_;
} }
bool AudioManager::IsLowLatencyPlayoutSupported() const { bool AudioManager::IsLowLatencyPlayoutSupported() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// Some devices are blacklisted for usage of OpenSL ES even if they report // Some devices are blacklisted for usage of OpenSL ES even if they report
// that low-latency playout is supported. See b/21485703 for details. // that low-latency playout is supported. See b/21485703 for details.
return j_audio_manager_->IsDeviceBlacklistedForOpenSLESUsage() return j_audio_manager_->IsDeviceBlacklistedForOpenSLESUsage()
@ -201,12 +201,12 @@ bool AudioManager::IsLowLatencyPlayoutSupported() const {
} }
bool AudioManager::IsLowLatencyRecordSupported() const { bool AudioManager::IsLowLatencyRecordSupported() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return low_latency_record_; return low_latency_record_;
} }
bool AudioManager::IsProAudioSupported() const { bool AudioManager::IsProAudioSupported() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// TODO(henrika): return the state independently of if OpenSL ES is // TODO(henrika): return the state independently of if OpenSL ES is
// blacklisted or not for now. We could use the same approach as in // blacklisted or not for now. We could use the same approach as in
// IsLowLatencyPlayoutSupported() but I can't see the need for it yet. // IsLowLatencyPlayoutSupported() but I can't see the need for it yet.
@ -223,12 +223,12 @@ bool AudioManager::IsAAudioSupported() const {
} }
bool AudioManager::IsStereoPlayoutSupported() const { bool AudioManager::IsStereoPlayoutSupported() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return (playout_parameters_.channels() == 2); return (playout_parameters_.channels() == 2);
} }
bool AudioManager::IsStereoRecordSupported() const { bool AudioManager::IsStereoRecordSupported() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return (record_parameters_.channels() == 2); return (record_parameters_.channels() == 2);
} }
@ -287,7 +287,7 @@ void AudioManager::OnCacheAudioParameters(JNIEnv* env,
<< ", input_channels: " << static_cast<int>(input_channels) << ", input_channels: " << static_cast<int>(input_channels)
<< ", output_buffer_size: " << static_cast<int>(output_buffer_size) << ", output_buffer_size: " << static_cast<int>(output_buffer_size)
<< ", input_buffer_size: " << static_cast<int>(input_buffer_size); << ", input_buffer_size: " << static_cast<int>(input_buffer_size);
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
hardware_aec_ = hardware_aec; hardware_aec_ = hardware_aec;
hardware_agc_ = hardware_agc; hardware_agc_ = hardware_agc;
hardware_ns_ = hardware_ns; hardware_ns_ = hardware_ns;
@ -303,13 +303,13 @@ void AudioManager::OnCacheAudioParameters(JNIEnv* env,
const AudioParameters& AudioManager::GetPlayoutAudioParameters() { const AudioParameters& AudioManager::GetPlayoutAudioParameters() {
RTC_CHECK(playout_parameters_.is_valid()); RTC_CHECK(playout_parameters_.is_valid());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return playout_parameters_; return playout_parameters_;
} }
const AudioParameters& AudioManager::GetRecordAudioParameters() { const AudioParameters& AudioManager::GetRecordAudioParameters() {
RTC_CHECK(record_parameters_.is_valid()); RTC_CHECK(record_parameters_.is_valid());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return record_parameters_; return record_parameters_;
} }

View File

@ -158,7 +158,7 @@ class AudioManager {
jint input_buffer_size); jint input_buffer_size);
// Stores thread ID in the constructor. // Stores thread ID in the constructor.
// We can then use ThreadChecker::CalledOnValidThread() to ensure that // We can then use ThreadChecker::IsCurrent() to ensure that
// other methods are called from the same thread. // other methods are called from the same thread.
rtc::ThreadChecker thread_checker_; rtc::ThreadChecker thread_checker_;

View File

@ -111,31 +111,31 @@ AudioRecordJni::AudioRecordJni(AudioManager* audio_manager)
"<init>", "(J)V", PointerTojlong(this)))); "<init>", "(J)V", PointerTojlong(this))));
// Detach from this thread since we want to use the checker to verify calls // Detach from this thread since we want to use the checker to verify calls
// from the Java based audio thread. // from the Java based audio thread.
thread_checker_java_.DetachFromThread(); thread_checker_java_.Detach();
} }
AudioRecordJni::~AudioRecordJni() { AudioRecordJni::~AudioRecordJni() {
RTC_LOG(INFO) << "dtor"; RTC_LOG(INFO) << "dtor";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
Terminate(); Terminate();
} }
int32_t AudioRecordJni::Init() { int32_t AudioRecordJni::Init() {
RTC_LOG(INFO) << "Init"; RTC_LOG(INFO) << "Init";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return 0; return 0;
} }
int32_t AudioRecordJni::Terminate() { int32_t AudioRecordJni::Terminate() {
RTC_LOG(INFO) << "Terminate"; RTC_LOG(INFO) << "Terminate";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
StopRecording(); StopRecording();
return 0; return 0;
} }
int32_t AudioRecordJni::InitRecording() { int32_t AudioRecordJni::InitRecording() {
RTC_LOG(INFO) << "InitRecording"; RTC_LOG(INFO) << "InitRecording";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!initialized_); RTC_DCHECK(!initialized_);
RTC_DCHECK(!recording_); RTC_DCHECK(!recording_);
ScopedHistogramTimer timer("WebRTC.Audio.InitRecordingDurationMs"); ScopedHistogramTimer timer("WebRTC.Audio.InitRecordingDurationMs");
@ -158,7 +158,7 @@ int32_t AudioRecordJni::InitRecording() {
int32_t AudioRecordJni::StartRecording() { int32_t AudioRecordJni::StartRecording() {
RTC_LOG(INFO) << "StartRecording"; RTC_LOG(INFO) << "StartRecording";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!recording_); RTC_DCHECK(!recording_);
if (!initialized_) { if (!initialized_) {
RTC_DLOG(LS_WARNING) RTC_DLOG(LS_WARNING)
@ -176,7 +176,7 @@ int32_t AudioRecordJni::StartRecording() {
int32_t AudioRecordJni::StopRecording() { int32_t AudioRecordJni::StopRecording() {
RTC_LOG(INFO) << "StopRecording"; RTC_LOG(INFO) << "StopRecording";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!initialized_ || !recording_) { if (!initialized_ || !recording_) {
return 0; return 0;
} }
@ -187,7 +187,7 @@ int32_t AudioRecordJni::StopRecording() {
// If we don't detach here, we will hit a RTC_DCHECK in OnDataIsRecorded() // If we don't detach here, we will hit a RTC_DCHECK in OnDataIsRecorded()
// next time StartRecording() is called since it will create a new Java // next time StartRecording() is called since it will create a new Java
// thread. // thread.
thread_checker_java_.DetachFromThread(); thread_checker_java_.Detach();
initialized_ = false; initialized_ = false;
recording_ = false; recording_ = false;
direct_buffer_address_ = nullptr; direct_buffer_address_ = nullptr;
@ -196,7 +196,7 @@ int32_t AudioRecordJni::StopRecording() {
void AudioRecordJni::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) { void AudioRecordJni::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
RTC_LOG(INFO) << "AttachAudioBuffer"; RTC_LOG(INFO) << "AttachAudioBuffer";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
audio_device_buffer_ = audioBuffer; audio_device_buffer_ = audioBuffer;
const int sample_rate_hz = audio_parameters_.sample_rate(); const int sample_rate_hz = audio_parameters_.sample_rate();
RTC_LOG(INFO) << "SetRecordingSampleRate(" << sample_rate_hz << ")"; RTC_LOG(INFO) << "SetRecordingSampleRate(" << sample_rate_hz << ")";
@ -213,7 +213,7 @@ void AudioRecordJni::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
int32_t AudioRecordJni::EnableBuiltInAEC(bool enable) { int32_t AudioRecordJni::EnableBuiltInAEC(bool enable) {
RTC_LOG(INFO) << "EnableBuiltInAEC(" << enable << ")"; RTC_LOG(INFO) << "EnableBuiltInAEC(" << enable << ")";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return j_audio_record_->EnableBuiltInAEC(enable) ? 0 : -1; return j_audio_record_->EnableBuiltInAEC(enable) ? 0 : -1;
} }
@ -225,7 +225,7 @@ int32_t AudioRecordJni::EnableBuiltInAGC(bool enable) {
int32_t AudioRecordJni::EnableBuiltInNS(bool enable) { int32_t AudioRecordJni::EnableBuiltInNS(bool enable) {
RTC_LOG(INFO) << "EnableBuiltInNS(" << enable << ")"; RTC_LOG(INFO) << "EnableBuiltInNS(" << enable << ")";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return j_audio_record_->EnableBuiltInNS(enable) ? 0 : -1; return j_audio_record_->EnableBuiltInNS(enable) ? 0 : -1;
} }
@ -242,7 +242,7 @@ void JNICALL AudioRecordJni::CacheDirectBufferAddress(JNIEnv* env,
void AudioRecordJni::OnCacheDirectBufferAddress(JNIEnv* env, void AudioRecordJni::OnCacheDirectBufferAddress(JNIEnv* env,
jobject byte_buffer) { jobject byte_buffer) {
RTC_LOG(INFO) << "OnCacheDirectBufferAddress"; RTC_LOG(INFO) << "OnCacheDirectBufferAddress";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!direct_buffer_address_); RTC_DCHECK(!direct_buffer_address_);
direct_buffer_address_ = env->GetDirectBufferAddress(byte_buffer); direct_buffer_address_ = env->GetDirectBufferAddress(byte_buffer);
jlong capacity = env->GetDirectBufferCapacity(byte_buffer); jlong capacity = env->GetDirectBufferCapacity(byte_buffer);
@ -263,7 +263,7 @@ void JNICALL AudioRecordJni::DataIsRecorded(JNIEnv* env,
// This method is called on a high-priority thread from Java. The name of // This method is called on a high-priority thread from Java. The name of
// the thread is 'AudioRecordThread'. // the thread is 'AudioRecordThread'.
void AudioRecordJni::OnDataIsRecorded(int length) { void AudioRecordJni::OnDataIsRecorded(int length) {
RTC_DCHECK(thread_checker_java_.CalledOnValidThread()); RTC_DCHECK(thread_checker_java_.IsCurrent());
if (!audio_device_buffer_) { if (!audio_device_buffer_) {
RTC_LOG(LS_ERROR) << "AttachAudioBuffer has not been called"; RTC_LOG(LS_ERROR) << "AttachAudioBuffer has not been called";
return; return;

View File

@ -88,31 +88,31 @@ AudioTrackJni::AudioTrackJni(AudioManager* audio_manager)
"<init>", "(J)V", PointerTojlong(this)))); "<init>", "(J)V", PointerTojlong(this))));
// Detach from this thread since we want to use the checker to verify calls // Detach from this thread since we want to use the checker to verify calls
// from the Java based audio thread. // from the Java based audio thread.
thread_checker_java_.DetachFromThread(); thread_checker_java_.Detach();
} }
AudioTrackJni::~AudioTrackJni() { AudioTrackJni::~AudioTrackJni() {
RTC_LOG(INFO) << "dtor"; RTC_LOG(INFO) << "dtor";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
Terminate(); Terminate();
} }
int32_t AudioTrackJni::Init() { int32_t AudioTrackJni::Init() {
RTC_LOG(INFO) << "Init"; RTC_LOG(INFO) << "Init";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return 0; return 0;
} }
int32_t AudioTrackJni::Terminate() { int32_t AudioTrackJni::Terminate() {
RTC_LOG(INFO) << "Terminate"; RTC_LOG(INFO) << "Terminate";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
StopPlayout(); StopPlayout();
return 0; return 0;
} }
int32_t AudioTrackJni::InitPlayout() { int32_t AudioTrackJni::InitPlayout() {
RTC_LOG(INFO) << "InitPlayout"; RTC_LOG(INFO) << "InitPlayout";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!initialized_); RTC_DCHECK(!initialized_);
RTC_DCHECK(!playing_); RTC_DCHECK(!playing_);
if (!j_audio_track_->InitPlayout(audio_parameters_.sample_rate(), if (!j_audio_track_->InitPlayout(audio_parameters_.sample_rate(),
@ -126,7 +126,7 @@ int32_t AudioTrackJni::InitPlayout() {
int32_t AudioTrackJni::StartPlayout() { int32_t AudioTrackJni::StartPlayout() {
RTC_LOG(INFO) << "StartPlayout"; RTC_LOG(INFO) << "StartPlayout";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!playing_); RTC_DCHECK(!playing_);
if (!initialized_) { if (!initialized_) {
RTC_DLOG(LS_WARNING) RTC_DLOG(LS_WARNING)
@ -143,7 +143,7 @@ int32_t AudioTrackJni::StartPlayout() {
int32_t AudioTrackJni::StopPlayout() { int32_t AudioTrackJni::StopPlayout() {
RTC_LOG(INFO) << "StopPlayout"; RTC_LOG(INFO) << "StopPlayout";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!initialized_ || !playing_) { if (!initialized_ || !playing_) {
return 0; return 0;
} }
@ -154,7 +154,7 @@ int32_t AudioTrackJni::StopPlayout() {
// If we don't detach here, we will hit a RTC_DCHECK in OnDataIsRecorded() // If we don't detach here, we will hit a RTC_DCHECK in OnDataIsRecorded()
// next time StartRecording() is called since it will create a new Java // next time StartRecording() is called since it will create a new Java
// thread. // thread.
thread_checker_java_.DetachFromThread(); thread_checker_java_.Detach();
initialized_ = false; initialized_ = false;
playing_ = false; playing_ = false;
direct_buffer_address_ = nullptr; direct_buffer_address_ = nullptr;
@ -168,24 +168,24 @@ int AudioTrackJni::SpeakerVolumeIsAvailable(bool& available) {
int AudioTrackJni::SetSpeakerVolume(uint32_t volume) { int AudioTrackJni::SetSpeakerVolume(uint32_t volume) {
RTC_LOG(INFO) << "SetSpeakerVolume(" << volume << ")"; RTC_LOG(INFO) << "SetSpeakerVolume(" << volume << ")";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return j_audio_track_->SetStreamVolume(volume) ? 0 : -1; return j_audio_track_->SetStreamVolume(volume) ? 0 : -1;
} }
int AudioTrackJni::MaxSpeakerVolume(uint32_t& max_volume) const { int AudioTrackJni::MaxSpeakerVolume(uint32_t& max_volume) const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
max_volume = j_audio_track_->GetStreamMaxVolume(); max_volume = j_audio_track_->GetStreamMaxVolume();
return 0; return 0;
} }
int AudioTrackJni::MinSpeakerVolume(uint32_t& min_volume) const { int AudioTrackJni::MinSpeakerVolume(uint32_t& min_volume) const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
min_volume = 0; min_volume = 0;
return 0; return 0;
} }
int AudioTrackJni::SpeakerVolume(uint32_t& volume) const { int AudioTrackJni::SpeakerVolume(uint32_t& volume) const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
volume = j_audio_track_->GetStreamVolume(); volume = j_audio_track_->GetStreamVolume();
RTC_LOG(INFO) << "SpeakerVolume: " << volume; RTC_LOG(INFO) << "SpeakerVolume: " << volume;
return 0; return 0;
@ -194,7 +194,7 @@ int AudioTrackJni::SpeakerVolume(uint32_t& volume) const {
// TODO(henrika): possibly add stereo support. // TODO(henrika): possibly add stereo support.
void AudioTrackJni::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) { void AudioTrackJni::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
RTC_LOG(INFO) << "AttachAudioBuffer"; RTC_LOG(INFO) << "AttachAudioBuffer";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
audio_device_buffer_ = audioBuffer; audio_device_buffer_ = audioBuffer;
const int sample_rate_hz = audio_parameters_.sample_rate(); const int sample_rate_hz = audio_parameters_.sample_rate();
RTC_LOG(INFO) << "SetPlayoutSampleRate(" << sample_rate_hz << ")"; RTC_LOG(INFO) << "SetPlayoutSampleRate(" << sample_rate_hz << ")";
@ -217,7 +217,7 @@ void JNICALL AudioTrackJni::CacheDirectBufferAddress(JNIEnv* env,
void AudioTrackJni::OnCacheDirectBufferAddress(JNIEnv* env, void AudioTrackJni::OnCacheDirectBufferAddress(JNIEnv* env,
jobject byte_buffer) { jobject byte_buffer) {
RTC_LOG(INFO) << "OnCacheDirectBufferAddress"; RTC_LOG(INFO) << "OnCacheDirectBufferAddress";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!direct_buffer_address_); RTC_DCHECK(!direct_buffer_address_);
direct_buffer_address_ = env->GetDirectBufferAddress(byte_buffer); direct_buffer_address_ = env->GetDirectBufferAddress(byte_buffer);
jlong capacity = env->GetDirectBufferCapacity(byte_buffer); jlong capacity = env->GetDirectBufferCapacity(byte_buffer);
@ -241,7 +241,7 @@ void JNICALL AudioTrackJni::GetPlayoutData(JNIEnv* env,
// This method is called on a high-priority thread from Java. The name of // This method is called on a high-priority thread from Java. The name of
// the thread is 'AudioRecordTrack'. // the thread is 'AudioRecordTrack'.
void AudioTrackJni::OnGetPlayoutData(size_t length) { void AudioTrackJni::OnGetPlayoutData(size_t length) {
RTC_DCHECK(thread_checker_java_.CalledOnValidThread()); RTC_DCHECK(thread_checker_java_.IsCurrent());
const size_t bytes_per_frame = audio_parameters_.channels() * sizeof(int16_t); const size_t bytes_per_frame = audio_parameters_.channels() * sizeof(int16_t);
RTC_DCHECK_EQ(frames_per_buffer_, length / bytes_per_frame); RTC_DCHECK_EQ(frames_per_buffer_, length / bytes_per_frame);
if (!audio_device_buffer_) { if (!audio_device_buffer_) {

View File

@ -61,12 +61,12 @@ OpenSLESPlayer::OpenSLESPlayer(AudioManager* audio_manager)
audio_parameters_.bits_per_sample()); audio_parameters_.bits_per_sample());
// Detach from this thread since we want to use the checker to verify calls // Detach from this thread since we want to use the checker to verify calls
// from the internal audio thread. // from the internal audio thread.
thread_checker_opensles_.DetachFromThread(); thread_checker_opensles_.Detach();
} }
OpenSLESPlayer::~OpenSLESPlayer() { OpenSLESPlayer::~OpenSLESPlayer() {
ALOGD("dtor[tid=%d]", rtc::CurrentThreadId()); ALOGD("dtor[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
Terminate(); Terminate();
DestroyAudioPlayer(); DestroyAudioPlayer();
DestroyMix(); DestroyMix();
@ -80,7 +80,7 @@ OpenSLESPlayer::~OpenSLESPlayer() {
int OpenSLESPlayer::Init() { int OpenSLESPlayer::Init() {
ALOGD("Init[tid=%d]", rtc::CurrentThreadId()); ALOGD("Init[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (audio_parameters_.channels() == 2) { if (audio_parameters_.channels() == 2) {
ALOGW("Stereo mode is enabled"); ALOGW("Stereo mode is enabled");
} }
@ -89,14 +89,14 @@ int OpenSLESPlayer::Init() {
int OpenSLESPlayer::Terminate() { int OpenSLESPlayer::Terminate() {
ALOGD("Terminate[tid=%d]", rtc::CurrentThreadId()); ALOGD("Terminate[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
StopPlayout(); StopPlayout();
return 0; return 0;
} }
int OpenSLESPlayer::InitPlayout() { int OpenSLESPlayer::InitPlayout() {
ALOGD("InitPlayout[tid=%d]", rtc::CurrentThreadId()); ALOGD("InitPlayout[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!initialized_); RTC_DCHECK(!initialized_);
RTC_DCHECK(!playing_); RTC_DCHECK(!playing_);
if (!ObtainEngineInterface()) { if (!ObtainEngineInterface()) {
@ -111,7 +111,7 @@ int OpenSLESPlayer::InitPlayout() {
int OpenSLESPlayer::StartPlayout() { int OpenSLESPlayer::StartPlayout() {
ALOGD("StartPlayout[tid=%d]", rtc::CurrentThreadId()); ALOGD("StartPlayout[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(initialized_); RTC_DCHECK(initialized_);
RTC_DCHECK(!playing_); RTC_DCHECK(!playing_);
if (fine_audio_buffer_) { if (fine_audio_buffer_) {
@ -139,7 +139,7 @@ int OpenSLESPlayer::StartPlayout() {
int OpenSLESPlayer::StopPlayout() { int OpenSLESPlayer::StopPlayout() {
ALOGD("StopPlayout[tid=%d]", rtc::CurrentThreadId()); ALOGD("StopPlayout[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!initialized_ || !playing_) { if (!initialized_ || !playing_) {
return 0; return 0;
} }
@ -157,7 +157,7 @@ int OpenSLESPlayer::StopPlayout() {
// The number of lower latency audio players is limited, hence we create the // The number of lower latency audio players is limited, hence we create the
// audio player in Start() and destroy it in Stop(). // audio player in Start() and destroy it in Stop().
DestroyAudioPlayer(); DestroyAudioPlayer();
thread_checker_opensles_.DetachFromThread(); thread_checker_opensles_.Detach();
initialized_ = false; initialized_ = false;
playing_ = false; playing_ = false;
return 0; return 0;
@ -186,7 +186,7 @@ int OpenSLESPlayer::SpeakerVolume(uint32_t& volume) const {
void OpenSLESPlayer::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) { void OpenSLESPlayer::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
ALOGD("AttachAudioBuffer"); ALOGD("AttachAudioBuffer");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
audio_device_buffer_ = audioBuffer; audio_device_buffer_ = audioBuffer;
const int sample_rate_hz = audio_parameters_.sample_rate(); const int sample_rate_hz = audio_parameters_.sample_rate();
ALOGD("SetPlayoutSampleRate(%d)", sample_rate_hz); ALOGD("SetPlayoutSampleRate(%d)", sample_rate_hz);
@ -200,7 +200,7 @@ void OpenSLESPlayer::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
void OpenSLESPlayer::AllocateDataBuffers() { void OpenSLESPlayer::AllocateDataBuffers() {
ALOGD("AllocateDataBuffers"); ALOGD("AllocateDataBuffers");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!simple_buffer_queue_); RTC_DCHECK(!simple_buffer_queue_);
RTC_CHECK(audio_device_buffer_); RTC_CHECK(audio_device_buffer_);
// Create a modified audio buffer class which allows us to ask for any number // Create a modified audio buffer class which allows us to ask for any number
@ -225,7 +225,7 @@ void OpenSLESPlayer::AllocateDataBuffers() {
bool OpenSLESPlayer::ObtainEngineInterface() { bool OpenSLESPlayer::ObtainEngineInterface() {
ALOGD("ObtainEngineInterface"); ALOGD("ObtainEngineInterface");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (engine_) if (engine_)
return true; return true;
// Get access to (or create if not already existing) the global OpenSL Engine // Get access to (or create if not already existing) the global OpenSL Engine
@ -244,7 +244,7 @@ bool OpenSLESPlayer::ObtainEngineInterface() {
bool OpenSLESPlayer::CreateMix() { bool OpenSLESPlayer::CreateMix() {
ALOGD("CreateMix"); ALOGD("CreateMix");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(engine_); RTC_DCHECK(engine_);
if (output_mix_.Get()) if (output_mix_.Get())
return true; return true;
@ -260,7 +260,7 @@ bool OpenSLESPlayer::CreateMix() {
void OpenSLESPlayer::DestroyMix() { void OpenSLESPlayer::DestroyMix() {
ALOGD("DestroyMix"); ALOGD("DestroyMix");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!output_mix_.Get()) if (!output_mix_.Get())
return; return;
output_mix_.Reset(); output_mix_.Reset();
@ -268,7 +268,7 @@ void OpenSLESPlayer::DestroyMix() {
bool OpenSLESPlayer::CreateAudioPlayer() { bool OpenSLESPlayer::CreateAudioPlayer() {
ALOGD("CreateAudioPlayer"); ALOGD("CreateAudioPlayer");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(output_mix_.Get()); RTC_DCHECK(output_mix_.Get());
if (player_object_.Get()) if (player_object_.Get())
return true; return true;
@ -352,7 +352,7 @@ bool OpenSLESPlayer::CreateAudioPlayer() {
void OpenSLESPlayer::DestroyAudioPlayer() { void OpenSLESPlayer::DestroyAudioPlayer() {
ALOGD("DestroyAudioPlayer"); ALOGD("DestroyAudioPlayer");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!player_object_.Get()) if (!player_object_.Get())
return; return;
(*simple_buffer_queue_) (*simple_buffer_queue_)
@ -372,7 +372,7 @@ void OpenSLESPlayer::SimpleBufferQueueCallback(
} }
void OpenSLESPlayer::FillBufferQueue() { void OpenSLESPlayer::FillBufferQueue() {
RTC_DCHECK(thread_checker_opensles_.CalledOnValidThread()); RTC_DCHECK(thread_checker_opensles_.IsCurrent());
SLuint32 state = GetPlayState(); SLuint32 state = GetPlayState();
if (state != SL_PLAYSTATE_PLAYING) { if (state != SL_PLAYSTATE_PLAYING) {
ALOGW("Buffer callback in non-playing state!"); ALOGW("Buffer callback in non-playing state!");
@ -394,13 +394,13 @@ void OpenSLESPlayer::EnqueuePlayoutData(bool silence) {
SLint8* audio_ptr8 = SLint8* audio_ptr8 =
reinterpret_cast<SLint8*>(audio_buffers_[buffer_index_].get()); reinterpret_cast<SLint8*>(audio_buffers_[buffer_index_].get());
if (silence) { if (silence) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// Avoid acquiring real audio data from WebRTC and fill the buffer with // Avoid acquiring real audio data from WebRTC and fill the buffer with
// zeros instead. Used to prime the buffer with silence and to avoid asking // zeros instead. Used to prime the buffer with silence and to avoid asking
// for audio data from two different threads. // for audio data from two different threads.
memset(audio_ptr8, 0, audio_parameters_.GetBytesPerBuffer()); memset(audio_ptr8, 0, audio_parameters_.GetBytesPerBuffer());
} else { } else {
RTC_DCHECK(thread_checker_opensles_.CalledOnValidThread()); RTC_DCHECK(thread_checker_opensles_.IsCurrent());
// Read audio data from the WebRTC source using the FineAudioBuffer object // Read audio data from the WebRTC source using the FineAudioBuffer object
// to adjust for differences in buffer size between WebRTC (10ms) and native // to adjust for differences in buffer size between WebRTC (10ms) and native
// OpenSL ES. Use hardcoded delay estimate since OpenSL ES does not support // OpenSL ES. Use hardcoded delay estimate since OpenSL ES does not support

View File

@ -56,7 +56,7 @@ OpenSLESRecorder::OpenSLESRecorder(AudioManager* audio_manager)
ALOGD("ctor[tid=%d]", rtc::CurrentThreadId()); ALOGD("ctor[tid=%d]", rtc::CurrentThreadId());
// Detach from this thread since we want to use the checker to verify calls // Detach from this thread since we want to use the checker to verify calls
// from the internal audio thread. // from the internal audio thread.
thread_checker_opensles_.DetachFromThread(); thread_checker_opensles_.Detach();
// Use native audio output parameters provided by the audio manager and // Use native audio output parameters provided by the audio manager and
// define the PCM format structure. // define the PCM format structure.
pcm_format_ = CreatePCMConfiguration(audio_parameters_.channels(), pcm_format_ = CreatePCMConfiguration(audio_parameters_.channels(),
@ -66,7 +66,7 @@ OpenSLESRecorder::OpenSLESRecorder(AudioManager* audio_manager)
OpenSLESRecorder::~OpenSLESRecorder() { OpenSLESRecorder::~OpenSLESRecorder() {
ALOGD("dtor[tid=%d]", rtc::CurrentThreadId()); ALOGD("dtor[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
Terminate(); Terminate();
DestroyAudioRecorder(); DestroyAudioRecorder();
engine_ = nullptr; engine_ = nullptr;
@ -77,7 +77,7 @@ OpenSLESRecorder::~OpenSLESRecorder() {
int OpenSLESRecorder::Init() { int OpenSLESRecorder::Init() {
ALOGD("Init[tid=%d]", rtc::CurrentThreadId()); ALOGD("Init[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (audio_parameters_.channels() == 2) { if (audio_parameters_.channels() == 2) {
ALOGD("Stereo mode is enabled"); ALOGD("Stereo mode is enabled");
} }
@ -86,14 +86,14 @@ int OpenSLESRecorder::Init() {
int OpenSLESRecorder::Terminate() { int OpenSLESRecorder::Terminate() {
ALOGD("Terminate[tid=%d]", rtc::CurrentThreadId()); ALOGD("Terminate[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
StopRecording(); StopRecording();
return 0; return 0;
} }
int OpenSLESRecorder::InitRecording() { int OpenSLESRecorder::InitRecording() {
ALOGD("InitRecording[tid=%d]", rtc::CurrentThreadId()); ALOGD("InitRecording[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!initialized_); RTC_DCHECK(!initialized_);
RTC_DCHECK(!recording_); RTC_DCHECK(!recording_);
if (!ObtainEngineInterface()) { if (!ObtainEngineInterface()) {
@ -108,7 +108,7 @@ int OpenSLESRecorder::InitRecording() {
int OpenSLESRecorder::StartRecording() { int OpenSLESRecorder::StartRecording() {
ALOGD("StartRecording[tid=%d]", rtc::CurrentThreadId()); ALOGD("StartRecording[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(initialized_); RTC_DCHECK(initialized_);
RTC_DCHECK(!recording_); RTC_DCHECK(!recording_);
if (fine_audio_buffer_) { if (fine_audio_buffer_) {
@ -145,7 +145,7 @@ int OpenSLESRecorder::StartRecording() {
int OpenSLESRecorder::StopRecording() { int OpenSLESRecorder::StopRecording() {
ALOGD("StopRecording[tid=%d]", rtc::CurrentThreadId()); ALOGD("StopRecording[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!initialized_ || !recording_) { if (!initialized_ || !recording_) {
return 0; return 0;
} }
@ -158,7 +158,7 @@ int OpenSLESRecorder::StopRecording() {
if (LOG_ON_ERROR((*simple_buffer_queue_)->Clear(simple_buffer_queue_))) { if (LOG_ON_ERROR((*simple_buffer_queue_)->Clear(simple_buffer_queue_))) {
return -1; return -1;
} }
thread_checker_opensles_.DetachFromThread(); thread_checker_opensles_.Detach();
initialized_ = false; initialized_ = false;
recording_ = false; recording_ = false;
return 0; return 0;
@ -166,7 +166,7 @@ int OpenSLESRecorder::StopRecording() {
void OpenSLESRecorder::AttachAudioBuffer(AudioDeviceBuffer* audio_buffer) { void OpenSLESRecorder::AttachAudioBuffer(AudioDeviceBuffer* audio_buffer) {
ALOGD("AttachAudioBuffer"); ALOGD("AttachAudioBuffer");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_CHECK(audio_buffer); RTC_CHECK(audio_buffer);
audio_device_buffer_ = audio_buffer; audio_device_buffer_ = audio_buffer;
// Ensure that the audio device buffer is informed about the native sample // Ensure that the audio device buffer is informed about the native sample
@ -185,28 +185,28 @@ void OpenSLESRecorder::AttachAudioBuffer(AudioDeviceBuffer* audio_buffer) {
int OpenSLESRecorder::EnableBuiltInAEC(bool enable) { int OpenSLESRecorder::EnableBuiltInAEC(bool enable) {
ALOGD("EnableBuiltInAEC(%d)", enable); ALOGD("EnableBuiltInAEC(%d)", enable);
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
ALOGE("Not implemented"); ALOGE("Not implemented");
return 0; return 0;
} }
int OpenSLESRecorder::EnableBuiltInAGC(bool enable) { int OpenSLESRecorder::EnableBuiltInAGC(bool enable) {
ALOGD("EnableBuiltInAGC(%d)", enable); ALOGD("EnableBuiltInAGC(%d)", enable);
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
ALOGE("Not implemented"); ALOGE("Not implemented");
return 0; return 0;
} }
int OpenSLESRecorder::EnableBuiltInNS(bool enable) { int OpenSLESRecorder::EnableBuiltInNS(bool enable) {
ALOGD("EnableBuiltInNS(%d)", enable); ALOGD("EnableBuiltInNS(%d)", enable);
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
ALOGE("Not implemented"); ALOGE("Not implemented");
return 0; return 0;
} }
bool OpenSLESRecorder::ObtainEngineInterface() { bool OpenSLESRecorder::ObtainEngineInterface() {
ALOGD("ObtainEngineInterface"); ALOGD("ObtainEngineInterface");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (engine_) if (engine_)
return true; return true;
// Get access to (or create if not already existing) the global OpenSL Engine // Get access to (or create if not already existing) the global OpenSL Engine
@ -227,7 +227,7 @@ bool OpenSLESRecorder::ObtainEngineInterface() {
bool OpenSLESRecorder::CreateAudioRecorder() { bool OpenSLESRecorder::CreateAudioRecorder() {
ALOGD("CreateAudioRecorder"); ALOGD("CreateAudioRecorder");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (recorder_object_.Get()) if (recorder_object_.Get())
return true; return true;
RTC_DCHECK(!recorder_); RTC_DCHECK(!recorder_);
@ -308,7 +308,7 @@ bool OpenSLESRecorder::CreateAudioRecorder() {
void OpenSLESRecorder::DestroyAudioRecorder() { void OpenSLESRecorder::DestroyAudioRecorder() {
ALOGD("DestroyAudioRecorder"); ALOGD("DestroyAudioRecorder");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!recorder_object_.Get()) if (!recorder_object_.Get())
return; return;
(*simple_buffer_queue_) (*simple_buffer_queue_)
@ -327,7 +327,7 @@ void OpenSLESRecorder::SimpleBufferQueueCallback(
void OpenSLESRecorder::AllocateDataBuffers() { void OpenSLESRecorder::AllocateDataBuffers() {
ALOGD("AllocateDataBuffers"); ALOGD("AllocateDataBuffers");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!simple_buffer_queue_); RTC_DCHECK(!simple_buffer_queue_);
RTC_CHECK(audio_device_buffer_); RTC_CHECK(audio_device_buffer_);
// Create a modified audio buffer class which allows us to deliver any number // Create a modified audio buffer class which allows us to deliver any number
@ -352,7 +352,7 @@ void OpenSLESRecorder::AllocateDataBuffers() {
} }
void OpenSLESRecorder::ReadBufferQueue() { void OpenSLESRecorder::ReadBufferQueue() {
RTC_DCHECK(thread_checker_opensles_.CalledOnValidThread()); RTC_DCHECK(thread_checker_opensles_.IsCurrent());
SLuint32 state = GetRecordState(); SLuint32 state = GetRecordState();
if (state != SL_RECORDSTATE_RECORDING) { if (state != SL_RECORDSTATE_RECORDING) {
ALOGW("Buffer callback in non-recording state!"); ALOGW("Buffer callback in non-recording state!");

View File

@ -223,8 +223,8 @@ class LatencyAudioStream : public AudioStream {
LatencyAudioStream() { LatencyAudioStream() {
// Delay thread checkers from being initialized until first callback from // Delay thread checkers from being initialized until first callback from
// respective thread. // respective thread.
read_thread_checker_.DetachFromThread(); read_thread_checker_.Detach();
write_thread_checker_.DetachFromThread(); write_thread_checker_.Detach();
} }
// Insert periodic impulses in first two samples of |destination|. // Insert periodic impulses in first two samples of |destination|.

View File

@ -113,7 +113,7 @@ AudioDeviceIOS::AudioDeviceIOS()
num_playout_callbacks_(0), num_playout_callbacks_(0),
last_output_volume_change_time_(0) { last_output_volume_change_time_(0) {
LOGI() << "ctor" << ios::GetCurrentThreadDescription(); LOGI() << "ctor" << ios::GetCurrentThreadDescription();
io_thread_checker_.DetachFromThread(); io_thread_checker_.Detach();
thread_ = rtc::Thread::Current(); thread_ = rtc::Thread::Current();
audio_session_observer_ = [[RTCAudioSessionDelegateAdapter alloc] initWithObserver:this]; audio_session_observer_ = [[RTCAudioSessionDelegateAdapter alloc] initWithObserver:this];
} }
@ -121,14 +121,14 @@ AudioDeviceIOS::AudioDeviceIOS()
AudioDeviceIOS::~AudioDeviceIOS() { AudioDeviceIOS::~AudioDeviceIOS() {
LOGI() << "~dtor" << ios::GetCurrentThreadDescription(); LOGI() << "~dtor" << ios::GetCurrentThreadDescription();
audio_session_observer_ = nil; audio_session_observer_ = nil;
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
Terminate(); Terminate();
} }
void AudioDeviceIOS::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) { void AudioDeviceIOS::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
LOGI() << "AttachAudioBuffer"; LOGI() << "AttachAudioBuffer";
RTC_DCHECK(audioBuffer); RTC_DCHECK(audioBuffer);
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
audio_device_buffer_ = audioBuffer; audio_device_buffer_ = audioBuffer;
} }
@ -307,7 +307,7 @@ int32_t AudioDeviceIOS::PlayoutDelay(uint16_t& delayMS) const {
int AudioDeviceIOS::GetPlayoutAudioParameters(AudioParameters* params) const { int AudioDeviceIOS::GetPlayoutAudioParameters(AudioParameters* params) const {
LOGI() << "GetPlayoutAudioParameters"; LOGI() << "GetPlayoutAudioParameters";
RTC_DCHECK(playout_parameters_.is_valid()); RTC_DCHECK(playout_parameters_.is_valid());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
*params = playout_parameters_; *params = playout_parameters_;
return 0; return 0;
} }
@ -315,7 +315,7 @@ int AudioDeviceIOS::GetPlayoutAudioParameters(AudioParameters* params) const {
int AudioDeviceIOS::GetRecordAudioParameters(AudioParameters* params) const { int AudioDeviceIOS::GetRecordAudioParameters(AudioParameters* params) const {
LOGI() << "GetRecordAudioParameters"; LOGI() << "GetRecordAudioParameters";
RTC_DCHECK(record_parameters_.is_valid()); RTC_DCHECK(record_parameters_.is_valid());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
*params = record_parameters_; *params = record_parameters_;
return 0; return 0;
} }
@ -882,7 +882,7 @@ void AudioDeviceIOS::ShutdownPlayOrRecord() {
// Detach thread checker for the AURemoteIO::IOThread to ensure that the // Detach thread checker for the AURemoteIO::IOThread to ensure that the
// next session uses a fresh thread id. // next session uses a fresh thread id.
io_thread_checker_.DetachFromThread(); io_thread_checker_.Detach();
// Remove audio session notification observers. // Remove audio session notification observers.
RTCAudioSession* session = [RTCAudioSession sharedInstance]; RTCAudioSession* session = [RTCAudioSession sharedInstance];
@ -902,7 +902,7 @@ void AudioDeviceIOS::PrepareForNewStart() {
// restart. It will result in audio callbacks from a new native I/O thread // restart. It will result in audio callbacks from a new native I/O thread
// which means that we must detach thread checkers here to be prepared for an // which means that we must detach thread checkers here to be prepared for an
// upcoming new audio stream. // upcoming new audio stream.
io_thread_checker_.DetachFromThread(); io_thread_checker_.Detach();
} }
} // namespace webrtc } // namespace webrtc

View File

@ -89,7 +89,7 @@ AudioDeviceLinuxPulse::AudioDeviceLinuxPulse()
AudioDeviceLinuxPulse::~AudioDeviceLinuxPulse() { AudioDeviceLinuxPulse::~AudioDeviceLinuxPulse() {
RTC_LOG(LS_INFO) << __FUNCTION__ << " destroyed"; RTC_LOG(LS_INFO) << __FUNCTION__ << " destroyed";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
Terminate(); Terminate();
if (_recBuffer) { if (_recBuffer) {
@ -111,7 +111,7 @@ AudioDeviceLinuxPulse::~AudioDeviceLinuxPulse() {
} }
void AudioDeviceLinuxPulse::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) { void AudioDeviceLinuxPulse::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
_ptrAudioBuffer = audioBuffer; _ptrAudioBuffer = audioBuffer;
@ -135,7 +135,7 @@ int32_t AudioDeviceLinuxPulse::ActiveAudioLayer(
} }
AudioDeviceGeneric::InitStatus AudioDeviceLinuxPulse::Init() { AudioDeviceGeneric::InitStatus AudioDeviceLinuxPulse::Init() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (_initialized) { if (_initialized) {
return InitStatus::OK; return InitStatus::OK;
} }
@ -177,7 +177,7 @@ AudioDeviceGeneric::InitStatus AudioDeviceLinuxPulse::Init() {
} }
int32_t AudioDeviceLinuxPulse::Terminate() { int32_t AudioDeviceLinuxPulse::Terminate() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!_initialized) { if (!_initialized) {
return 0; return 0;
} }
@ -223,12 +223,12 @@ int32_t AudioDeviceLinuxPulse::Terminate() {
} }
bool AudioDeviceLinuxPulse::Initialized() const { bool AudioDeviceLinuxPulse::Initialized() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return (_initialized); return (_initialized);
} }
int32_t AudioDeviceLinuxPulse::InitSpeaker() { int32_t AudioDeviceLinuxPulse::InitSpeaker() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (_playing) { if (_playing) {
return -1; return -1;
@ -266,7 +266,7 @@ int32_t AudioDeviceLinuxPulse::InitSpeaker() {
} }
int32_t AudioDeviceLinuxPulse::InitMicrophone() { int32_t AudioDeviceLinuxPulse::InitMicrophone() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (_recording) { if (_recording) {
return -1; return -1;
} }
@ -303,17 +303,17 @@ int32_t AudioDeviceLinuxPulse::InitMicrophone() {
} }
bool AudioDeviceLinuxPulse::SpeakerIsInitialized() const { bool AudioDeviceLinuxPulse::SpeakerIsInitialized() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return (_mixerManager.SpeakerIsInitialized()); return (_mixerManager.SpeakerIsInitialized());
} }
bool AudioDeviceLinuxPulse::MicrophoneIsInitialized() const { bool AudioDeviceLinuxPulse::MicrophoneIsInitialized() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return (_mixerManager.MicrophoneIsInitialized()); return (_mixerManager.MicrophoneIsInitialized());
} }
int32_t AudioDeviceLinuxPulse::SpeakerVolumeIsAvailable(bool& available) { int32_t AudioDeviceLinuxPulse::SpeakerVolumeIsAvailable(bool& available) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
bool wasInitialized = _mixerManager.SpeakerIsInitialized(); bool wasInitialized = _mixerManager.SpeakerIsInitialized();
// Make an attempt to open up the // Make an attempt to open up the
@ -337,7 +337,7 @@ int32_t AudioDeviceLinuxPulse::SpeakerVolumeIsAvailable(bool& available) {
} }
int32_t AudioDeviceLinuxPulse::SetSpeakerVolume(uint32_t volume) { int32_t AudioDeviceLinuxPulse::SetSpeakerVolume(uint32_t volume) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!_playing) { if (!_playing) {
// Only update the volume if it's been set while we weren't playing. // Only update the volume if it's been set while we weren't playing.
update_speaker_volume_at_startup_ = true; update_speaker_volume_at_startup_ = true;
@ -346,7 +346,7 @@ int32_t AudioDeviceLinuxPulse::SetSpeakerVolume(uint32_t volume) {
} }
int32_t AudioDeviceLinuxPulse::SpeakerVolume(uint32_t& volume) const { int32_t AudioDeviceLinuxPulse::SpeakerVolume(uint32_t& volume) const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
uint32_t level(0); uint32_t level(0);
if (_mixerManager.SpeakerVolume(level) == -1) { if (_mixerManager.SpeakerVolume(level) == -1) {
@ -359,7 +359,7 @@ int32_t AudioDeviceLinuxPulse::SpeakerVolume(uint32_t& volume) const {
} }
int32_t AudioDeviceLinuxPulse::MaxSpeakerVolume(uint32_t& maxVolume) const { int32_t AudioDeviceLinuxPulse::MaxSpeakerVolume(uint32_t& maxVolume) const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
uint32_t maxVol(0); uint32_t maxVol(0);
if (_mixerManager.MaxSpeakerVolume(maxVol) == -1) { if (_mixerManager.MaxSpeakerVolume(maxVol) == -1) {
@ -372,7 +372,7 @@ int32_t AudioDeviceLinuxPulse::MaxSpeakerVolume(uint32_t& maxVolume) const {
} }
int32_t AudioDeviceLinuxPulse::MinSpeakerVolume(uint32_t& minVolume) const { int32_t AudioDeviceLinuxPulse::MinSpeakerVolume(uint32_t& minVolume) const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
uint32_t minVol(0); uint32_t minVol(0);
if (_mixerManager.MinSpeakerVolume(minVol) == -1) { if (_mixerManager.MinSpeakerVolume(minVol) == -1) {
@ -385,7 +385,7 @@ int32_t AudioDeviceLinuxPulse::MinSpeakerVolume(uint32_t& minVolume) const {
} }
int32_t AudioDeviceLinuxPulse::SpeakerMuteIsAvailable(bool& available) { int32_t AudioDeviceLinuxPulse::SpeakerMuteIsAvailable(bool& available) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
bool isAvailable(false); bool isAvailable(false);
bool wasInitialized = _mixerManager.SpeakerIsInitialized(); bool wasInitialized = _mixerManager.SpeakerIsInitialized();
@ -414,12 +414,12 @@ int32_t AudioDeviceLinuxPulse::SpeakerMuteIsAvailable(bool& available) {
} }
int32_t AudioDeviceLinuxPulse::SetSpeakerMute(bool enable) { int32_t AudioDeviceLinuxPulse::SetSpeakerMute(bool enable) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return (_mixerManager.SetSpeakerMute(enable)); return (_mixerManager.SetSpeakerMute(enable));
} }
int32_t AudioDeviceLinuxPulse::SpeakerMute(bool& enabled) const { int32_t AudioDeviceLinuxPulse::SpeakerMute(bool& enabled) const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
bool muted(0); bool muted(0);
if (_mixerManager.SpeakerMute(muted) == -1) { if (_mixerManager.SpeakerMute(muted) == -1) {
return -1; return -1;
@ -430,7 +430,7 @@ int32_t AudioDeviceLinuxPulse::SpeakerMute(bool& enabled) const {
} }
int32_t AudioDeviceLinuxPulse::MicrophoneMuteIsAvailable(bool& available) { int32_t AudioDeviceLinuxPulse::MicrophoneMuteIsAvailable(bool& available) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
bool isAvailable(false); bool isAvailable(false);
bool wasInitialized = _mixerManager.MicrophoneIsInitialized(); bool wasInitialized = _mixerManager.MicrophoneIsInitialized();
@ -460,12 +460,12 @@ int32_t AudioDeviceLinuxPulse::MicrophoneMuteIsAvailable(bool& available) {
} }
int32_t AudioDeviceLinuxPulse::SetMicrophoneMute(bool enable) { int32_t AudioDeviceLinuxPulse::SetMicrophoneMute(bool enable) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return (_mixerManager.SetMicrophoneMute(enable)); return (_mixerManager.SetMicrophoneMute(enable));
} }
int32_t AudioDeviceLinuxPulse::MicrophoneMute(bool& enabled) const { int32_t AudioDeviceLinuxPulse::MicrophoneMute(bool& enabled) const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
bool muted(0); bool muted(0);
if (_mixerManager.MicrophoneMute(muted) == -1) { if (_mixerManager.MicrophoneMute(muted) == -1) {
return -1; return -1;
@ -476,7 +476,7 @@ int32_t AudioDeviceLinuxPulse::MicrophoneMute(bool& enabled) const {
} }
int32_t AudioDeviceLinuxPulse::StereoRecordingIsAvailable(bool& available) { int32_t AudioDeviceLinuxPulse::StereoRecordingIsAvailable(bool& available) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (_recChannels == 2 && _recording) { if (_recChannels == 2 && _recording) {
available = true; available = true;
return 0; return 0;
@ -507,7 +507,7 @@ int32_t AudioDeviceLinuxPulse::StereoRecordingIsAvailable(bool& available) {
} }
int32_t AudioDeviceLinuxPulse::SetStereoRecording(bool enable) { int32_t AudioDeviceLinuxPulse::SetStereoRecording(bool enable) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (enable) if (enable)
_recChannels = 2; _recChannels = 2;
else else
@ -517,7 +517,7 @@ int32_t AudioDeviceLinuxPulse::SetStereoRecording(bool enable) {
} }
int32_t AudioDeviceLinuxPulse::StereoRecording(bool& enabled) const { int32_t AudioDeviceLinuxPulse::StereoRecording(bool& enabled) const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (_recChannels == 2) if (_recChannels == 2)
enabled = true; enabled = true;
else else
@ -527,7 +527,7 @@ int32_t AudioDeviceLinuxPulse::StereoRecording(bool& enabled) const {
} }
int32_t AudioDeviceLinuxPulse::StereoPlayoutIsAvailable(bool& available) { int32_t AudioDeviceLinuxPulse::StereoPlayoutIsAvailable(bool& available) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (_playChannels == 2 && _playing) { if (_playChannels == 2 && _playing) {
available = true; available = true;
return 0; return 0;
@ -557,7 +557,7 @@ int32_t AudioDeviceLinuxPulse::StereoPlayoutIsAvailable(bool& available) {
} }
int32_t AudioDeviceLinuxPulse::SetStereoPlayout(bool enable) { int32_t AudioDeviceLinuxPulse::SetStereoPlayout(bool enable) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (enable) if (enable)
_playChannels = 2; _playChannels = 2;
else else
@ -567,7 +567,7 @@ int32_t AudioDeviceLinuxPulse::SetStereoPlayout(bool enable) {
} }
int32_t AudioDeviceLinuxPulse::StereoPlayout(bool& enabled) const { int32_t AudioDeviceLinuxPulse::StereoPlayout(bool& enabled) const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (_playChannels == 2) if (_playChannels == 2)
enabled = true; enabled = true;
else else
@ -577,7 +577,7 @@ int32_t AudioDeviceLinuxPulse::StereoPlayout(bool& enabled) const {
} }
int32_t AudioDeviceLinuxPulse::MicrophoneVolumeIsAvailable(bool& available) { int32_t AudioDeviceLinuxPulse::MicrophoneVolumeIsAvailable(bool& available) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
bool wasInitialized = _mixerManager.MicrophoneIsInitialized(); bool wasInitialized = _mixerManager.MicrophoneIsInitialized();
// Make an attempt to open up the // Make an attempt to open up the
@ -660,7 +660,7 @@ int16_t AudioDeviceLinuxPulse::PlayoutDevices() {
} }
int32_t AudioDeviceLinuxPulse::SetPlayoutDevice(uint16_t index) { int32_t AudioDeviceLinuxPulse::SetPlayoutDevice(uint16_t index) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (_playIsInitialized) { if (_playIsInitialized) {
return -1; return -1;
} }
@ -691,7 +691,7 @@ int32_t AudioDeviceLinuxPulse::PlayoutDeviceName(
uint16_t index, uint16_t index,
char name[kAdmMaxDeviceNameSize], char name[kAdmMaxDeviceNameSize],
char guid[kAdmMaxGuidSize]) { char guid[kAdmMaxGuidSize]) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
const uint16_t nDevices = PlayoutDevices(); const uint16_t nDevices = PlayoutDevices();
if ((index > (nDevices - 1)) || (name == NULL)) { if ((index > (nDevices - 1)) || (name == NULL)) {
@ -729,7 +729,7 @@ int32_t AudioDeviceLinuxPulse::RecordingDeviceName(
uint16_t index, uint16_t index,
char name[kAdmMaxDeviceNameSize], char name[kAdmMaxDeviceNameSize],
char guid[kAdmMaxGuidSize]) { char guid[kAdmMaxGuidSize]) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
const uint16_t nDevices(RecordingDevices()); const uint16_t nDevices(RecordingDevices());
if ((index > (nDevices - 1)) || (name == NULL)) { if ((index > (nDevices - 1)) || (name == NULL)) {
@ -781,7 +781,7 @@ int16_t AudioDeviceLinuxPulse::RecordingDevices() {
} }
int32_t AudioDeviceLinuxPulse::SetRecordingDevice(uint16_t index) { int32_t AudioDeviceLinuxPulse::SetRecordingDevice(uint16_t index) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (_recIsInitialized) { if (_recIsInitialized) {
return -1; return -1;
} }
@ -809,7 +809,7 @@ int32_t AudioDeviceLinuxPulse::SetRecordingDevice(
} }
int32_t AudioDeviceLinuxPulse::PlayoutIsAvailable(bool& available) { int32_t AudioDeviceLinuxPulse::PlayoutIsAvailable(bool& available) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
available = false; available = false;
// Try to initialize the playout side // Try to initialize the playout side
@ -826,7 +826,7 @@ int32_t AudioDeviceLinuxPulse::PlayoutIsAvailable(bool& available) {
} }
int32_t AudioDeviceLinuxPulse::RecordingIsAvailable(bool& available) { int32_t AudioDeviceLinuxPulse::RecordingIsAvailable(bool& available) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
available = false; available = false;
// Try to initialize the playout side // Try to initialize the playout side
@ -843,7 +843,7 @@ int32_t AudioDeviceLinuxPulse::RecordingIsAvailable(bool& available) {
} }
int32_t AudioDeviceLinuxPulse::InitPlayout() { int32_t AudioDeviceLinuxPulse::InitPlayout() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (_playing) { if (_playing) {
return -1; return -1;
@ -947,7 +947,7 @@ int32_t AudioDeviceLinuxPulse::InitPlayout() {
} }
int32_t AudioDeviceLinuxPulse::InitRecording() { int32_t AudioDeviceLinuxPulse::InitRecording() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (_recording) { if (_recording) {
return -1; return -1;
@ -1043,7 +1043,7 @@ int32_t AudioDeviceLinuxPulse::InitRecording() {
} }
int32_t AudioDeviceLinuxPulse::StartRecording() { int32_t AudioDeviceLinuxPulse::StartRecording() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!_recIsInitialized) { if (!_recIsInitialized) {
return -1; return -1;
} }
@ -1082,7 +1082,7 @@ int32_t AudioDeviceLinuxPulse::StartRecording() {
} }
int32_t AudioDeviceLinuxPulse::StopRecording() { int32_t AudioDeviceLinuxPulse::StopRecording() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
rtc::CritScope lock(&_critSect); rtc::CritScope lock(&_critSect);
if (!_recIsInitialized) { if (!_recIsInitialized) {
@ -1136,22 +1136,22 @@ int32_t AudioDeviceLinuxPulse::StopRecording() {
} }
bool AudioDeviceLinuxPulse::RecordingIsInitialized() const { bool AudioDeviceLinuxPulse::RecordingIsInitialized() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return (_recIsInitialized); return (_recIsInitialized);
} }
bool AudioDeviceLinuxPulse::Recording() const { bool AudioDeviceLinuxPulse::Recording() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return (_recording); return (_recording);
} }
bool AudioDeviceLinuxPulse::PlayoutIsInitialized() const { bool AudioDeviceLinuxPulse::PlayoutIsInitialized() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return (_playIsInitialized); return (_playIsInitialized);
} }
int32_t AudioDeviceLinuxPulse::StartPlayout() { int32_t AudioDeviceLinuxPulse::StartPlayout() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!_playIsInitialized) { if (!_playIsInitialized) {
return -1; return -1;
@ -1197,7 +1197,7 @@ int32_t AudioDeviceLinuxPulse::StartPlayout() {
} }
int32_t AudioDeviceLinuxPulse::StopPlayout() { int32_t AudioDeviceLinuxPulse::StopPlayout() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
rtc::CritScope lock(&_critSect); rtc::CritScope lock(&_critSect);
if (!_playIsInitialized) { if (!_playIsInitialized) {
@ -1259,7 +1259,7 @@ int32_t AudioDeviceLinuxPulse::PlayoutDelay(uint16_t& delayMS) const {
} }
bool AudioDeviceLinuxPulse::Playing() const { bool AudioDeviceLinuxPulse::Playing() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return (_playing); return (_playing);
} }

View File

@ -283,9 +283,9 @@ class AudioDeviceLinuxPulse : public AudioDeviceGeneric {
uint8_t _playChannels; uint8_t _playChannels;
// Stores thread ID in constructor. // Stores thread ID in constructor.
// We can then use ThreadChecker::CalledOnValidThread() to ensure that // We can then use ThreadChecker::IsCurrent() to ensure that
// other methods are called from the same thread. // other methods are called from the same thread.
// Currently only does RTC_DCHECK(thread_checker_.CalledOnValidThread()). // Currently only does RTC_DCHECK(thread_checker_.IsCurrent()).
rtc::ThreadChecker thread_checker_; rtc::ThreadChecker thread_checker_;
bool _initialized; bool _initialized;

View File

@ -57,7 +57,7 @@ AudioMixerManagerLinuxPulse::AudioMixerManagerLinuxPulse()
} }
AudioMixerManagerLinuxPulse::~AudioMixerManagerLinuxPulse() { AudioMixerManagerLinuxPulse::~AudioMixerManagerLinuxPulse() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_LOG(LS_INFO) << __FUNCTION__ << " destroyed"; RTC_LOG(LS_INFO) << __FUNCTION__ << " destroyed";
Close(); Close();
@ -70,7 +70,7 @@ AudioMixerManagerLinuxPulse::~AudioMixerManagerLinuxPulse() {
int32_t AudioMixerManagerLinuxPulse::SetPulseAudioObjects( int32_t AudioMixerManagerLinuxPulse::SetPulseAudioObjects(
pa_threaded_mainloop* mainloop, pa_threaded_mainloop* mainloop,
pa_context* context) { pa_context* context) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_LOG(LS_VERBOSE) << __FUNCTION__; RTC_LOG(LS_VERBOSE) << __FUNCTION__;
if (!mainloop || !context) { if (!mainloop || !context) {
@ -88,7 +88,7 @@ int32_t AudioMixerManagerLinuxPulse::SetPulseAudioObjects(
} }
int32_t AudioMixerManagerLinuxPulse::Close() { int32_t AudioMixerManagerLinuxPulse::Close() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_LOG(LS_VERBOSE) << __FUNCTION__; RTC_LOG(LS_VERBOSE) << __FUNCTION__;
CloseSpeaker(); CloseSpeaker();
@ -102,7 +102,7 @@ int32_t AudioMixerManagerLinuxPulse::Close() {
} }
int32_t AudioMixerManagerLinuxPulse::CloseSpeaker() { int32_t AudioMixerManagerLinuxPulse::CloseSpeaker() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_LOG(LS_VERBOSE) << __FUNCTION__; RTC_LOG(LS_VERBOSE) << __FUNCTION__;
// Reset the index to -1 // Reset the index to -1
@ -113,7 +113,7 @@ int32_t AudioMixerManagerLinuxPulse::CloseSpeaker() {
} }
int32_t AudioMixerManagerLinuxPulse::CloseMicrophone() { int32_t AudioMixerManagerLinuxPulse::CloseMicrophone() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_LOG(LS_VERBOSE) << __FUNCTION__; RTC_LOG(LS_VERBOSE) << __FUNCTION__;
// Reset the index to -1 // Reset the index to -1
@ -124,7 +124,7 @@ int32_t AudioMixerManagerLinuxPulse::CloseMicrophone() {
} }
int32_t AudioMixerManagerLinuxPulse::SetPlayStream(pa_stream* playStream) { int32_t AudioMixerManagerLinuxPulse::SetPlayStream(pa_stream* playStream) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_LOG(LS_VERBOSE) RTC_LOG(LS_VERBOSE)
<< "AudioMixerManagerLinuxPulse::SetPlayStream(playStream)"; << "AudioMixerManagerLinuxPulse::SetPlayStream(playStream)";
@ -133,7 +133,7 @@ int32_t AudioMixerManagerLinuxPulse::SetPlayStream(pa_stream* playStream) {
} }
int32_t AudioMixerManagerLinuxPulse::SetRecStream(pa_stream* recStream) { int32_t AudioMixerManagerLinuxPulse::SetRecStream(pa_stream* recStream) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_LOG(LS_VERBOSE) << "AudioMixerManagerLinuxPulse::SetRecStream(recStream)"; RTC_LOG(LS_VERBOSE) << "AudioMixerManagerLinuxPulse::SetRecStream(recStream)";
_paRecStream = recStream; _paRecStream = recStream;
@ -141,7 +141,7 @@ int32_t AudioMixerManagerLinuxPulse::SetRecStream(pa_stream* recStream) {
} }
int32_t AudioMixerManagerLinuxPulse::OpenSpeaker(uint16_t deviceIndex) { int32_t AudioMixerManagerLinuxPulse::OpenSpeaker(uint16_t deviceIndex) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_LOG(LS_VERBOSE) << "AudioMixerManagerLinuxPulse::OpenSpeaker(deviceIndex=" RTC_LOG(LS_VERBOSE) << "AudioMixerManagerLinuxPulse::OpenSpeaker(deviceIndex="
<< deviceIndex << ")"; << deviceIndex << ")";
@ -162,7 +162,7 @@ int32_t AudioMixerManagerLinuxPulse::OpenSpeaker(uint16_t deviceIndex) {
} }
int32_t AudioMixerManagerLinuxPulse::OpenMicrophone(uint16_t deviceIndex) { int32_t AudioMixerManagerLinuxPulse::OpenMicrophone(uint16_t deviceIndex) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_LOG(LS_VERBOSE) RTC_LOG(LS_VERBOSE)
<< "AudioMixerManagerLinuxPulse::OpenMicrophone(deviceIndex=" << "AudioMixerManagerLinuxPulse::OpenMicrophone(deviceIndex="
<< deviceIndex << ")"; << deviceIndex << ")";
@ -184,21 +184,21 @@ int32_t AudioMixerManagerLinuxPulse::OpenMicrophone(uint16_t deviceIndex) {
} }
bool AudioMixerManagerLinuxPulse::SpeakerIsInitialized() const { bool AudioMixerManagerLinuxPulse::SpeakerIsInitialized() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_LOG(LS_INFO) << __FUNCTION__; RTC_LOG(LS_INFO) << __FUNCTION__;
return (_paOutputDeviceIndex != -1); return (_paOutputDeviceIndex != -1);
} }
bool AudioMixerManagerLinuxPulse::MicrophoneIsInitialized() const { bool AudioMixerManagerLinuxPulse::MicrophoneIsInitialized() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_LOG(LS_INFO) << __FUNCTION__; RTC_LOG(LS_INFO) << __FUNCTION__;
return (_paInputDeviceIndex != -1); return (_paInputDeviceIndex != -1);
} }
int32_t AudioMixerManagerLinuxPulse::SetSpeakerVolume(uint32_t volume) { int32_t AudioMixerManagerLinuxPulse::SetSpeakerVolume(uint32_t volume) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_LOG(LS_VERBOSE) << "AudioMixerManagerLinuxPulse::SetSpeakerVolume(volume=" RTC_LOG(LS_VERBOSE) << "AudioMixerManagerLinuxPulse::SetSpeakerVolume(volume="
<< volume << ")"; << volume << ")";
@ -303,7 +303,7 @@ int32_t AudioMixerManagerLinuxPulse::MinSpeakerVolume(
} }
int32_t AudioMixerManagerLinuxPulse::SpeakerVolumeIsAvailable(bool& available) { int32_t AudioMixerManagerLinuxPulse::SpeakerVolumeIsAvailable(bool& available) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (_paOutputDeviceIndex == -1) { if (_paOutputDeviceIndex == -1) {
RTC_LOG(LS_WARNING) << "output device index has not been set"; RTC_LOG(LS_WARNING) << "output device index has not been set";
return -1; return -1;
@ -316,7 +316,7 @@ int32_t AudioMixerManagerLinuxPulse::SpeakerVolumeIsAvailable(bool& available) {
} }
int32_t AudioMixerManagerLinuxPulse::SpeakerMuteIsAvailable(bool& available) { int32_t AudioMixerManagerLinuxPulse::SpeakerMuteIsAvailable(bool& available) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (_paOutputDeviceIndex == -1) { if (_paOutputDeviceIndex == -1) {
RTC_LOG(LS_WARNING) << "output device index has not been set"; RTC_LOG(LS_WARNING) << "output device index has not been set";
return -1; return -1;
@ -329,7 +329,7 @@ int32_t AudioMixerManagerLinuxPulse::SpeakerMuteIsAvailable(bool& available) {
} }
int32_t AudioMixerManagerLinuxPulse::SetSpeakerMute(bool enable) { int32_t AudioMixerManagerLinuxPulse::SetSpeakerMute(bool enable) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_LOG(LS_VERBOSE) << "AudioMixerManagerLinuxPulse::SetSpeakerMute(enable=" RTC_LOG(LS_VERBOSE) << "AudioMixerManagerLinuxPulse::SetSpeakerMute(enable="
<< enable << ")"; << enable << ")";
@ -393,7 +393,7 @@ int32_t AudioMixerManagerLinuxPulse::SpeakerMute(bool& enabled) const {
} }
int32_t AudioMixerManagerLinuxPulse::StereoPlayoutIsAvailable(bool& available) { int32_t AudioMixerManagerLinuxPulse::StereoPlayoutIsAvailable(bool& available) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (_paOutputDeviceIndex == -1) { if (_paOutputDeviceIndex == -1) {
RTC_LOG(LS_WARNING) << "output device index has not been set"; RTC_LOG(LS_WARNING) << "output device index has not been set";
return -1; return -1;
@ -423,7 +423,7 @@ int32_t AudioMixerManagerLinuxPulse::StereoPlayoutIsAvailable(bool& available) {
int32_t AudioMixerManagerLinuxPulse::StereoRecordingIsAvailable( int32_t AudioMixerManagerLinuxPulse::StereoRecordingIsAvailable(
bool& available) { bool& available) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (_paInputDeviceIndex == -1) { if (_paInputDeviceIndex == -1) {
RTC_LOG(LS_WARNING) << "input device index has not been set"; RTC_LOG(LS_WARNING) << "input device index has not been set";
return -1; return -1;
@ -461,7 +461,7 @@ int32_t AudioMixerManagerLinuxPulse::StereoRecordingIsAvailable(
int32_t AudioMixerManagerLinuxPulse::MicrophoneMuteIsAvailable( int32_t AudioMixerManagerLinuxPulse::MicrophoneMuteIsAvailable(
bool& available) { bool& available) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (_paInputDeviceIndex == -1) { if (_paInputDeviceIndex == -1) {
RTC_LOG(LS_WARNING) << "input device index has not been set"; RTC_LOG(LS_WARNING) << "input device index has not been set";
return -1; return -1;
@ -474,7 +474,7 @@ int32_t AudioMixerManagerLinuxPulse::MicrophoneMuteIsAvailable(
} }
int32_t AudioMixerManagerLinuxPulse::SetMicrophoneMute(bool enable) { int32_t AudioMixerManagerLinuxPulse::SetMicrophoneMute(bool enable) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_LOG(LS_VERBOSE) RTC_LOG(LS_VERBOSE)
<< "AudioMixerManagerLinuxPulse::SetMicrophoneMute(enable=" << enable << "AudioMixerManagerLinuxPulse::SetMicrophoneMute(enable=" << enable
<< ")"; << ")";
@ -520,7 +520,7 @@ int32_t AudioMixerManagerLinuxPulse::SetMicrophoneMute(bool enable) {
} }
int32_t AudioMixerManagerLinuxPulse::MicrophoneMute(bool& enabled) const { int32_t AudioMixerManagerLinuxPulse::MicrophoneMute(bool& enabled) const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (_paInputDeviceIndex == -1) { if (_paInputDeviceIndex == -1) {
RTC_LOG(LS_WARNING) << "input device index has not been set"; RTC_LOG(LS_WARNING) << "input device index has not been set";
return -1; return -1;
@ -552,7 +552,7 @@ int32_t AudioMixerManagerLinuxPulse::MicrophoneMute(bool& enabled) const {
int32_t AudioMixerManagerLinuxPulse::MicrophoneVolumeIsAvailable( int32_t AudioMixerManagerLinuxPulse::MicrophoneVolumeIsAvailable(
bool& available) { bool& available) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (_paInputDeviceIndex == -1) { if (_paInputDeviceIndex == -1) {
RTC_LOG(LS_WARNING) << "input device index has not been set"; RTC_LOG(LS_WARNING) << "input device index has not been set";
return -1; return -1;

View File

@ -103,9 +103,9 @@ class AudioMixerManagerLinuxPulse {
bool _paObjectsSet; bool _paObjectsSet;
// Stores thread ID in constructor. // Stores thread ID in constructor.
// We can then use ThreadChecker::CalledOnValidThread() to ensure that // We can then use ThreadChecker::IsCurrent() to ensure that
// other methods are called from the same thread. // other methods are called from the same thread.
// Currently only does RTC_DCHECK(thread_checker_.CalledOnValidThread()). // Currently only does RTC_DCHECK(thread_checker_.IsCurrent()).
rtc::ThreadChecker thread_checker_; rtc::ThreadChecker thread_checker_;
}; };

View File

@ -591,7 +591,7 @@ bool CoreAudioBase::Stop() {
// thread is not destroyed during restart attempts triggered by internal // thread is not destroyed during restart attempts triggered by internal
// error callbacks. // error callbacks.
if (!IsRestarting()) { if (!IsRestarting()) {
thread_checker_audio_.DetachFromThread(); thread_checker_audio_.Detach();
} }
// Release all allocated COM interfaces to allow for a restart without // Release all allocated COM interfaces to allow for a restart without

View File

@ -32,7 +32,7 @@ CoreAudioInput::CoreAudioInput()
[this](ErrorType err) { return OnErrorCallback(err); }) { [this](ErrorType err) { return OnErrorCallback(err); }) {
RTC_DLOG(INFO) << __FUNCTION__; RTC_DLOG(INFO) << __FUNCTION__;
RTC_DCHECK_RUN_ON(&thread_checker_); RTC_DCHECK_RUN_ON(&thread_checker_);
thread_checker_audio_.DetachFromThread(); thread_checker_audio_.Detach();
} }
CoreAudioInput::~CoreAudioInput() { CoreAudioInput::~CoreAudioInput() {

View File

@ -29,7 +29,7 @@ CoreAudioOutput::CoreAudioOutput()
[this](ErrorType err) { return OnErrorCallback(err); }) { [this](ErrorType err) { return OnErrorCallback(err); }) {
RTC_DLOG(INFO) << __FUNCTION__; RTC_DLOG(INFO) << __FUNCTION__;
RTC_DCHECK_RUN_ON(&thread_checker_); RTC_DCHECK_RUN_ON(&thread_checker_);
thread_checker_audio_.DetachFromThread(); thread_checker_audio_.Detach();
} }
CoreAudioOutput::~CoreAudioOutput() { CoreAudioOutput::~CoreAudioOutput() {

View File

@ -63,7 +63,7 @@ SharedMemoryFactoryProxy::~SharedMemoryFactoryProxy() = default;
std::unique_ptr<SharedMemory> SharedMemoryFactoryProxy::CreateSharedMemory( std::unique_ptr<SharedMemory> SharedMemoryFactoryProxy::CreateSharedMemory(
size_t size) { size_t size) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return factory_->CreateSharedMemory(size); return factory_->CreateSharedMemory(size);
} }

View File

@ -19,18 +19,18 @@ namespace webrtc {
DesktopFrameProvider::DesktopFrameProvider(bool allow_iosurface) DesktopFrameProvider::DesktopFrameProvider(bool allow_iosurface)
: allow_iosurface_(allow_iosurface) { : allow_iosurface_(allow_iosurface) {
thread_checker_.DetachFromThread(); thread_checker_.Detach();
} }
DesktopFrameProvider::~DesktopFrameProvider() { DesktopFrameProvider::~DesktopFrameProvider() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
Release(); Release();
} }
std::unique_ptr<DesktopFrame> DesktopFrameProvider::TakeLatestFrameForDisplay( std::unique_ptr<DesktopFrame> DesktopFrameProvider::TakeLatestFrameForDisplay(
CGDirectDisplayID display_id) { CGDirectDisplayID display_id) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!allow_iosurface_ || !io_surfaces_[display_id]) { if (!allow_iosurface_ || !io_surfaces_[display_id]) {
// Regenerate a snapshot. If iosurface is on it will be empty until the // Regenerate a snapshot. If iosurface is on it will be empty until the
@ -43,7 +43,7 @@ std::unique_ptr<DesktopFrame> DesktopFrameProvider::TakeLatestFrameForDisplay(
void DesktopFrameProvider::InvalidateIOSurface(CGDirectDisplayID display_id, void DesktopFrameProvider::InvalidateIOSurface(CGDirectDisplayID display_id,
rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface) { rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!allow_iosurface_) { if (!allow_iosurface_) {
return; return;
@ -58,7 +58,7 @@ void DesktopFrameProvider::InvalidateIOSurface(CGDirectDisplayID display_id,
} }
void DesktopFrameProvider::Release() { void DesktopFrameProvider::Release() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!allow_iosurface_) { if (!allow_iosurface_) {
return; return;

View File

@ -153,11 +153,11 @@ ScreenCapturerMac::ScreenCapturerMac(
desktop_config_monitor_(desktop_config_monitor), desktop_config_monitor_(desktop_config_monitor),
desktop_frame_provider_(allow_iosurface) { desktop_frame_provider_(allow_iosurface) {
RTC_LOG(LS_INFO) << "Allow IOSurface: " << allow_iosurface; RTC_LOG(LS_INFO) << "Allow IOSurface: " << allow_iosurface;
thread_checker_.DetachFromThread(); thread_checker_.Detach();
} }
ScreenCapturerMac::~ScreenCapturerMac() { ScreenCapturerMac::~ScreenCapturerMac() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
ReleaseBuffers(); ReleaseBuffers();
UnregisterRefreshAndMoveHandlers(); UnregisterRefreshAndMoveHandlers();
} }
@ -176,7 +176,7 @@ void ScreenCapturerMac::ReleaseBuffers() {
} }
void ScreenCapturerMac::Start(Callback* callback) { void ScreenCapturerMac::Start(Callback* callback) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!callback_); RTC_DCHECK(!callback_);
RTC_DCHECK(callback); RTC_DCHECK(callback);
TRACE_EVENT_INSTANT1( TRACE_EVENT_INSTANT1(
@ -193,7 +193,7 @@ void ScreenCapturerMac::Start(Callback* callback) {
} }
void ScreenCapturerMac::CaptureFrame() { void ScreenCapturerMac::CaptureFrame() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
TRACE_EVENT0("webrtc", "creenCapturerMac::CaptureFrame"); TRACE_EVENT0("webrtc", "creenCapturerMac::CaptureFrame");
int64_t capture_start_time_nanos = rtc::TimeNanos(); int64_t capture_start_time_nanos = rtc::TimeNanos();
@ -437,7 +437,7 @@ void ScreenCapturerMac::ScreenConfigurationChanged() {
} }
bool ScreenCapturerMac::RegisterRefreshAndMoveHandlers() { bool ScreenCapturerMac::RegisterRefreshAndMoveHandlers() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
desktop_config_ = desktop_config_monitor_->desktop_configuration(); desktop_config_ = desktop_config_monitor_->desktop_configuration();
for (const auto& config : desktop_config_.displays) { for (const auto& config : desktop_config_.displays) {
size_t pixel_width = config.pixel_bounds.width(); size_t pixel_width = config.pixel_bounds.width();
@ -450,7 +450,7 @@ bool ScreenCapturerMac::RegisterRefreshAndMoveHandlers() {
uint64_t display_time, uint64_t display_time,
IOSurfaceRef frame_surface, IOSurfaceRef frame_surface,
CGDisplayStreamUpdateRef updateRef) { CGDisplayStreamUpdateRef updateRef) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (status == kCGDisplayStreamFrameStatusStopped) return; if (status == kCGDisplayStreamFrameStatusStopped) return;
// Only pay attention to frame updates. // Only pay attention to frame updates.
@ -491,7 +491,7 @@ bool ScreenCapturerMac::RegisterRefreshAndMoveHandlers() {
} }
void ScreenCapturerMac::UnregisterRefreshAndMoveHandlers() { void ScreenCapturerMac::UnregisterRefreshAndMoveHandlers() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
for (CGDisplayStreamRef stream : display_streams_) { for (CGDisplayStreamRef stream : display_streams_) {
CFRunLoopSourceRef source = CGDisplayStreamGetRunLoopSource(stream); CFRunLoopSourceRef source = CGDisplayStreamGetRunLoopSource(stream);

View File

@ -83,7 +83,7 @@ JvmThreadConnector::JvmThreadConnector() : attached_(false) {
JvmThreadConnector::~JvmThreadConnector() { JvmThreadConnector::~JvmThreadConnector() {
RTC_LOG(INFO) << "JvmThreadConnector::dtor"; RTC_LOG(INFO) << "JvmThreadConnector::dtor";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (attached_) { if (attached_) {
RTC_LOG(INFO) << "Detaching thread from JVM"; RTC_LOG(INFO) << "Detaching thread from JVM";
jint res = JVM::GetInstance()->jvm()->DetachCurrentThread(); jint res = JVM::GetInstance()->jvm()->DetachCurrentThread();
@ -186,7 +186,7 @@ JNIEnvironment::JNIEnvironment(JNIEnv* jni) : jni_(jni) {
JNIEnvironment::~JNIEnvironment() { JNIEnvironment::~JNIEnvironment() {
RTC_LOG(INFO) << "JNIEnvironment::dtor"; RTC_LOG(INFO) << "JNIEnvironment::dtor";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
} }
std::unique_ptr<NativeRegistration> JNIEnvironment::RegisterNatives( std::unique_ptr<NativeRegistration> JNIEnvironment::RegisterNatives(
@ -194,7 +194,7 @@ std::unique_ptr<NativeRegistration> JNIEnvironment::RegisterNatives(
const JNINativeMethod* methods, const JNINativeMethod* methods,
int num_methods) { int num_methods) {
RTC_LOG(INFO) << "JNIEnvironment::RegisterNatives: " << name; RTC_LOG(INFO) << "JNIEnvironment::RegisterNatives: " << name;
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
jclass clazz = LookUpClass(name); jclass clazz = LookUpClass(name);
jni_->RegisterNatives(clazz, methods, num_methods); jni_->RegisterNatives(clazz, methods, num_methods);
CHECK_EXCEPTION(jni_) << "Error during RegisterNatives"; CHECK_EXCEPTION(jni_) << "Error during RegisterNatives";
@ -203,7 +203,7 @@ std::unique_ptr<NativeRegistration> JNIEnvironment::RegisterNatives(
} }
std::string JNIEnvironment::JavaToStdString(const jstring& j_string) { std::string JNIEnvironment::JavaToStdString(const jstring& j_string) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
const char* jchars = jni_->GetStringUTFChars(j_string, nullptr); const char* jchars = jni_->GetStringUTFChars(j_string, nullptr);
CHECK_EXCEPTION(jni_); CHECK_EXCEPTION(jni_);
const int size = jni_->GetStringUTFLength(j_string); const int size = jni_->GetStringUTFLength(j_string);
@ -254,7 +254,7 @@ JVM::JVM(JavaVM* jvm) : jvm_(jvm) {
JVM::~JVM() { JVM::~JVM() {
RTC_LOG(INFO) << "JVM::~JVM"; RTC_LOG(INFO) << "JVM::~JVM";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
FreeClassReferences(jni()); FreeClassReferences(jni());
} }
@ -277,7 +277,7 @@ std::unique_ptr<JNIEnvironment> JVM::environment() {
JavaClass JVM::GetClass(const char* name) { JavaClass JVM::GetClass(const char* name) {
RTC_LOG(INFO) << "JVM::GetClass: " << name; RTC_LOG(INFO) << "JVM::GetClass: " << name;
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return JavaClass(jni(), LookUpClass(name)); return JavaClass(jni(), LookUpClass(name));
} }

View File

@ -46,7 +46,7 @@ ProcessThreadImpl::ProcessThreadImpl(const char* thread_name)
: stop_(false), thread_name_(thread_name) {} : stop_(false), thread_name_(thread_name) {}
ProcessThreadImpl::~ProcessThreadImpl() { ProcessThreadImpl::~ProcessThreadImpl() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!thread_.get()); RTC_DCHECK(!thread_.get());
RTC_DCHECK(!stop_); RTC_DCHECK(!stop_);
@ -57,7 +57,7 @@ ProcessThreadImpl::~ProcessThreadImpl() {
} }
void ProcessThreadImpl::Start() { void ProcessThreadImpl::Start() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!thread_.get()); RTC_DCHECK(!thread_.get());
if (thread_.get()) if (thread_.get())
return; return;
@ -73,7 +73,7 @@ void ProcessThreadImpl::Start() {
} }
void ProcessThreadImpl::Stop() { void ProcessThreadImpl::Stop() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!thread_.get()) if (!thread_.get())
return; return;
@ -115,7 +115,7 @@ void ProcessThreadImpl::PostTask(std::unique_ptr<QueuedTask> task) {
void ProcessThreadImpl::RegisterModule(Module* module, void ProcessThreadImpl::RegisterModule(Module* module,
const rtc::Location& from) { const rtc::Location& from) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(module) << from.ToString(); RTC_DCHECK(module) << from.ToString();
#if RTC_DCHECK_IS_ON #if RTC_DCHECK_IS_ON
@ -148,7 +148,7 @@ void ProcessThreadImpl::RegisterModule(Module* module,
} }
void ProcessThreadImpl::DeRegisterModule(Module* module) { void ProcessThreadImpl::DeRegisterModule(Module* module) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(module); RTC_DCHECK(module);
{ {

View File

@ -380,7 +380,7 @@ class MediaTypesEnum : public IEnumMediaTypes {
} // namespace } // namespace
CaptureInputPin::CaptureInputPin(CaptureSinkFilter* filter) { CaptureInputPin::CaptureInputPin(CaptureSinkFilter* filter) {
capture_checker_.DetachFromThread(); capture_checker_.Detach();
// No reference held to avoid circular references. // No reference held to avoid circular references.
info_.pFilter = filter; info_.pFilter = filter;
info_.dir = PINDIR_INPUT; info_.dir = PINDIR_INPUT;
@ -404,7 +404,7 @@ void CaptureInputPin::OnFilterActivated() {
RTC_DCHECK_RUN_ON(&main_checker_); RTC_DCHECK_RUN_ON(&main_checker_);
runtime_error_ = false; runtime_error_ = false;
flushing_ = false; flushing_ = false;
capture_checker_.DetachFromThread(); capture_checker_.Detach();
capture_thread_id_ = 0; capture_thread_id_ = 0;
} }

View File

@ -37,7 +37,7 @@ VCMDecodedFrameCallback::~VCMDecodedFrameCallback() {}
void VCMDecodedFrameCallback::SetUserReceiveCallback( void VCMDecodedFrameCallback::SetUserReceiveCallback(
VCMReceiveCallback* receiveCallback) { VCMReceiveCallback* receiveCallback) {
RTC_DCHECK(construction_thread_.CalledOnValidThread()); RTC_DCHECK(construction_thread_.IsCurrent());
RTC_DCHECK((!_receiveCallback && receiveCallback) || RTC_DCHECK((!_receiveCallback && receiveCallback) ||
(_receiveCallback && !receiveCallback)); (_receiveCallback && !receiveCallback));
_receiveCallback = receiveCallback; _receiveCallback = receiveCallback;

View File

@ -71,7 +71,7 @@ class VideoCodingModuleImpl : public VideoCodingModule {
int32_t RegisterReceiveCallback( int32_t RegisterReceiveCallback(
VCMReceiveCallback* receiveCallback) override { VCMReceiveCallback* receiveCallback) override {
RTC_DCHECK(construction_thread_.CalledOnValidThread()); RTC_DCHECK(construction_thread_.IsCurrent());
return receiver_.RegisterReceiveCallback(receiveCallback); return receiver_.RegisterReceiveCallback(receiveCallback);
} }
@ -82,7 +82,7 @@ class VideoCodingModuleImpl : public VideoCodingModule {
int32_t RegisterPacketRequestCallback( int32_t RegisterPacketRequestCallback(
VCMPacketRequestCallback* callback) override { VCMPacketRequestCallback* callback) override {
RTC_DCHECK(construction_thread_.CalledOnValidThread()); RTC_DCHECK(construction_thread_.IsCurrent());
return receiver_.RegisterPacketRequestCallback(callback); return receiver_.RegisterPacketRequestCallback(callback);
} }

View File

@ -55,8 +55,8 @@ VideoReceiver::VideoReceiver(Clock* clock, VCMTiming* timing)
_receiveStatsTimer(1000, clock_), _receiveStatsTimer(1000, clock_),
_retransmissionTimer(10, clock_), _retransmissionTimer(10, clock_),
_keyRequestTimer(500, clock_) { _keyRequestTimer(500, clock_) {
decoder_thread_checker_.DetachFromThread(); decoder_thread_checker_.Detach();
module_thread_checker_.DetachFromThread(); module_thread_checker_.Detach();
} }
VideoReceiver::~VideoReceiver() { VideoReceiver::~VideoReceiver() {
@ -244,7 +244,7 @@ void VideoReceiver::DecoderThreadStopped() {
} }
#if RTC_DCHECK_IS_ON #if RTC_DCHECK_IS_ON
decoder_thread_is_running_ = false; decoder_thread_is_running_ = false;
decoder_thread_checker_.DetachFromThread(); decoder_thread_checker_.Detach();
#endif #endif
} }

View File

@ -121,11 +121,11 @@ PortAllocator::PortAllocator()
allow_tcp_listen_(true), allow_tcp_listen_(true),
candidate_filter_(CF_ALL) { candidate_filter_(CF_ALL) {
// The allocator will be attached to a thread in Initialize. // The allocator will be attached to a thread in Initialize.
thread_checker_.DetachFromThread(); thread_checker_.Detach();
} }
void PortAllocator::Initialize() { void PortAllocator::Initialize() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
initialized_ = true; initialized_ = true;
} }
@ -148,7 +148,7 @@ bool PortAllocator::SetConfiguration(
// A positive candidate pool size would lead to the creation of a pooled // A positive candidate pool size would lead to the creation of a pooled
// allocator session and starting getting ports, which we should only do on // allocator session and starting getting ports, which we should only do on
// the network thread. // the network thread.
RTC_DCHECK(candidate_pool_size == 0 || thread_checker_.CalledOnValidThread()); RTC_DCHECK(candidate_pool_size == 0 || thread_checker_.IsCurrent());
bool ice_servers_changed = bool ice_servers_changed =
(stun_servers != stun_servers_ || turn_servers != turn_servers_); (stun_servers != stun_servers_ || turn_servers != turn_servers_);
stun_servers_ = stun_servers; stun_servers_ = stun_servers;

View File

@ -579,11 +579,11 @@ class RTC_EXPORT PortAllocator : public sigslot::has_slots<> {
// The following thread checks are only done in DCHECK for the consistency // The following thread checks are only done in DCHECK for the consistency
// with the exsiting thread checks. // with the exsiting thread checks.
void CheckRunOnValidThreadIfInitialized() const { void CheckRunOnValidThreadIfInitialized() const {
RTC_DCHECK(!initialized_ || thread_checker_.CalledOnValidThread()); RTC_DCHECK(!initialized_ || thread_checker_.IsCurrent());
} }
void CheckRunOnValidThreadAndInitialized() const { void CheckRunOnValidThreadAndInitialized() const {
RTC_DCHECK(initialized_ && thread_checker_.CalledOnValidThread()); RTC_DCHECK(initialized_ && thread_checker_.IsCurrent());
} }
bool initialized_ = false; bool initialized_ = false;

View File

@ -65,25 +65,25 @@ class TestTurnServer : public TurnAuthInterface {
server_.set_auth_hook(this); server_.set_auth_hook(this);
} }
~TestTurnServer() { RTC_DCHECK(thread_checker_.CalledOnValidThread()); } ~TestTurnServer() { RTC_DCHECK(thread_checker_.IsCurrent()); }
void set_enable_otu_nonce(bool enable) { void set_enable_otu_nonce(bool enable) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
server_.set_enable_otu_nonce(enable); server_.set_enable_otu_nonce(enable);
} }
TurnServer* server() { TurnServer* server() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return &server_; return &server_;
} }
void set_redirect_hook(TurnRedirectInterface* redirect_hook) { void set_redirect_hook(TurnRedirectInterface* redirect_hook) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
server_.set_redirect_hook(redirect_hook); server_.set_redirect_hook(redirect_hook);
} }
void set_enable_permission_checks(bool enable) { void set_enable_permission_checks(bool enable) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
server_.set_enable_permission_checks(enable); server_.set_enable_permission_checks(enable);
} }
@ -91,7 +91,7 @@ class TestTurnServer : public TurnAuthInterface {
ProtocolType proto, ProtocolType proto,
bool ignore_bad_cert = true, bool ignore_bad_cert = true,
const std::string& common_name = "test turn server") { const std::string& common_name = "test turn server") {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (proto == cricket::PROTO_UDP) { if (proto == cricket::PROTO_UDP) {
server_.AddInternalSocket( server_.AddInternalSocket(
rtc::AsyncUDPSocket::Create(thread_->socketserver(), int_addr), rtc::AsyncUDPSocket::Create(thread_->socketserver(), int_addr),
@ -124,7 +124,7 @@ class TestTurnServer : public TurnAuthInterface {
// Finds the first allocation in the server allocation map with a source // Finds the first allocation in the server allocation map with a source
// ip and port matching the socket address provided. // ip and port matching the socket address provided.
TurnServerAllocation* FindAllocation(const rtc::SocketAddress& src) { TurnServerAllocation* FindAllocation(const rtc::SocketAddress& src) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
const TurnServer::AllocationMap& map = server_.allocations(); const TurnServer::AllocationMap& map = server_.allocations();
for (TurnServer::AllocationMap::const_iterator it = map.begin(); for (TurnServer::AllocationMap::const_iterator it = map.begin();
it != map.end(); ++it) { it != map.end(); ++it) {
@ -141,7 +141,7 @@ class TestTurnServer : public TurnAuthInterface {
virtual bool GetKey(const std::string& username, virtual bool GetKey(const std::string& username,
const std::string& realm, const std::string& realm,
std::string* key) { std::string* key) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return ComputeStunCredentialHash(username, realm, username, key); return ComputeStunCredentialHash(username, realm, username, key);
} }

View File

@ -130,7 +130,7 @@ TurnServer::TurnServer(rtc::Thread* thread)
} }
TurnServer::~TurnServer() { TurnServer::~TurnServer() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
for (InternalSocketMap::iterator it = server_sockets_.begin(); for (InternalSocketMap::iterator it = server_sockets_.begin();
it != server_sockets_.end(); ++it) { it != server_sockets_.end(); ++it) {
rtc::AsyncPacketSocket* socket = it->first; rtc::AsyncPacketSocket* socket = it->first;
@ -146,7 +146,7 @@ TurnServer::~TurnServer() {
void TurnServer::AddInternalSocket(rtc::AsyncPacketSocket* socket, void TurnServer::AddInternalSocket(rtc::AsyncPacketSocket* socket,
ProtocolType proto) { ProtocolType proto) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(server_sockets_.end() == server_sockets_.find(socket)); RTC_DCHECK(server_sockets_.end() == server_sockets_.find(socket));
server_sockets_[socket] = proto; server_sockets_[socket] = proto;
socket->SignalReadPacket.connect(this, &TurnServer::OnInternalPacket); socket->SignalReadPacket.connect(this, &TurnServer::OnInternalPacket);
@ -154,7 +154,7 @@ void TurnServer::AddInternalSocket(rtc::AsyncPacketSocket* socket,
void TurnServer::AddInternalServerSocket(rtc::AsyncSocket* socket, void TurnServer::AddInternalServerSocket(rtc::AsyncSocket* socket,
ProtocolType proto) { ProtocolType proto) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(server_listen_sockets_.end() == RTC_DCHECK(server_listen_sockets_.end() ==
server_listen_sockets_.find(socket)); server_listen_sockets_.find(socket));
server_listen_sockets_[socket] = proto; server_listen_sockets_[socket] = proto;
@ -164,20 +164,20 @@ void TurnServer::AddInternalServerSocket(rtc::AsyncSocket* socket,
void TurnServer::SetExternalSocketFactory( void TurnServer::SetExternalSocketFactory(
rtc::PacketSocketFactory* factory, rtc::PacketSocketFactory* factory,
const rtc::SocketAddress& external_addr) { const rtc::SocketAddress& external_addr) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
external_socket_factory_.reset(factory); external_socket_factory_.reset(factory);
external_addr_ = external_addr; external_addr_ = external_addr;
} }
void TurnServer::OnNewInternalConnection(rtc::AsyncSocket* socket) { void TurnServer::OnNewInternalConnection(rtc::AsyncSocket* socket) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(server_listen_sockets_.find(socket) != RTC_DCHECK(server_listen_sockets_.find(socket) !=
server_listen_sockets_.end()); server_listen_sockets_.end());
AcceptConnection(socket); AcceptConnection(socket);
} }
void TurnServer::AcceptConnection(rtc::AsyncSocket* server_socket) { void TurnServer::AcceptConnection(rtc::AsyncSocket* server_socket) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// Check if someone is trying to connect to us. // Check if someone is trying to connect to us.
rtc::SocketAddress accept_addr; rtc::SocketAddress accept_addr;
rtc::AsyncSocket* accepted_socket = server_socket->Accept(&accept_addr); rtc::AsyncSocket* accepted_socket = server_socket->Accept(&accept_addr);
@ -194,7 +194,7 @@ void TurnServer::AcceptConnection(rtc::AsyncSocket* server_socket) {
void TurnServer::OnInternalSocketClose(rtc::AsyncPacketSocket* socket, void TurnServer::OnInternalSocketClose(rtc::AsyncPacketSocket* socket,
int err) { int err) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
DestroyInternalSocket(socket); DestroyInternalSocket(socket);
} }
@ -203,7 +203,7 @@ void TurnServer::OnInternalPacket(rtc::AsyncPacketSocket* socket,
size_t size, size_t size,
const rtc::SocketAddress& addr, const rtc::SocketAddress& addr,
const int64_t& /* packet_time_us */) { const int64_t& /* packet_time_us */) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// Fail if the packet is too small to even contain a channel header. // Fail if the packet is too small to even contain a channel header.
if (size < TURN_CHANNEL_HEADER_SIZE) { if (size < TURN_CHANNEL_HEADER_SIZE) {
return; return;
@ -229,7 +229,7 @@ void TurnServer::OnInternalPacket(rtc::AsyncPacketSocket* socket,
void TurnServer::HandleStunMessage(TurnServerConnection* conn, const char* data, void TurnServer::HandleStunMessage(TurnServerConnection* conn, const char* data,
size_t size) { size_t size) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
TurnMessage msg; TurnMessage msg;
rtc::ByteBufferReader buf(data, size); rtc::ByteBufferReader buf(data, size);
if (!msg.Read(&buf) || (buf.Length() > 0)) { if (!msg.Read(&buf) || (buf.Length() > 0)) {
@ -296,7 +296,7 @@ void TurnServer::HandleStunMessage(TurnServerConnection* conn, const char* data,
} }
bool TurnServer::GetKey(const StunMessage* msg, std::string* key) { bool TurnServer::GetKey(const StunMessage* msg, std::string* key) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
const StunByteStringAttribute* username_attr = const StunByteStringAttribute* username_attr =
msg->GetByteString(STUN_ATTR_USERNAME); msg->GetByteString(STUN_ATTR_USERNAME);
if (!username_attr) { if (!username_attr) {
@ -311,7 +311,7 @@ bool TurnServer::CheckAuthorization(TurnServerConnection* conn,
const StunMessage* msg, const StunMessage* msg,
const char* data, size_t size, const char* data, size_t size,
const std::string& key) { const std::string& key) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// RFC 5389, 10.2.2. // RFC 5389, 10.2.2.
RTC_DCHECK(IsStunRequestType(msg->type())); RTC_DCHECK(IsStunRequestType(msg->type()));
const StunByteStringAttribute* mi_attr = const StunByteStringAttribute* mi_attr =
@ -370,7 +370,7 @@ bool TurnServer::CheckAuthorization(TurnServerConnection* conn,
void TurnServer::HandleBindingRequest(TurnServerConnection* conn, void TurnServer::HandleBindingRequest(TurnServerConnection* conn,
const StunMessage* req) { const StunMessage* req) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
StunMessage response; StunMessage response;
InitResponse(req, &response); InitResponse(req, &response);
@ -385,7 +385,7 @@ void TurnServer::HandleBindingRequest(TurnServerConnection* conn,
void TurnServer::HandleAllocateRequest(TurnServerConnection* conn, void TurnServer::HandleAllocateRequest(TurnServerConnection* conn,
const TurnMessage* msg, const TurnMessage* msg,
const std::string& key) { const std::string& key) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// Check the parameters in the request. // Check the parameters in the request.
const StunUInt32Attribute* transport_attr = const StunUInt32Attribute* transport_attr =
msg->GetUInt32(STUN_ATTR_REQUESTED_TRANSPORT); msg->GetUInt32(STUN_ATTR_REQUESTED_TRANSPORT);
@ -415,7 +415,7 @@ void TurnServer::HandleAllocateRequest(TurnServerConnection* conn,
} }
std::string TurnServer::GenerateNonce(int64_t now) const { std::string TurnServer::GenerateNonce(int64_t now) const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// Generate a nonce of the form hex(now + HMAC-MD5(nonce_key_, now)) // Generate a nonce of the form hex(now + HMAC-MD5(nonce_key_, now))
std::string input(reinterpret_cast<const char*>(&now), sizeof(now)); std::string input(reinterpret_cast<const char*>(&now), sizeof(now));
std::string nonce = rtc::hex_encode(input.c_str(), input.size()); std::string nonce = rtc::hex_encode(input.c_str(), input.size());
@ -426,7 +426,7 @@ std::string TurnServer::GenerateNonce(int64_t now) const {
} }
bool TurnServer::ValidateNonce(const std::string& nonce) const { bool TurnServer::ValidateNonce(const std::string& nonce) const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// Check the size. // Check the size.
if (nonce.size() != kNonceSize) { if (nonce.size() != kNonceSize) {
return false; return false;
@ -452,7 +452,7 @@ bool TurnServer::ValidateNonce(const std::string& nonce) const {
} }
TurnServerAllocation* TurnServer::FindAllocation(TurnServerConnection* conn) { TurnServerAllocation* TurnServer::FindAllocation(TurnServerConnection* conn) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
AllocationMap::const_iterator it = allocations_.find(*conn); AllocationMap::const_iterator it = allocations_.find(*conn);
return (it != allocations_.end()) ? it->second.get() : nullptr; return (it != allocations_.end()) ? it->second.get() : nullptr;
} }
@ -460,7 +460,7 @@ TurnServerAllocation* TurnServer::FindAllocation(TurnServerConnection* conn) {
TurnServerAllocation* TurnServer::CreateAllocation(TurnServerConnection* conn, TurnServerAllocation* TurnServer::CreateAllocation(TurnServerConnection* conn,
int proto, int proto,
const std::string& key) { const std::string& key) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
rtc::AsyncPacketSocket* external_socket = (external_socket_factory_) ? rtc::AsyncPacketSocket* external_socket = (external_socket_factory_) ?
external_socket_factory_->CreateUdpSocket(external_addr_, 0, 0) : NULL; external_socket_factory_->CreateUdpSocket(external_addr_, 0, 0) : NULL;
if (!external_socket) { if (!external_socket) {
@ -478,7 +478,7 @@ TurnServerAllocation* TurnServer::CreateAllocation(TurnServerConnection* conn,
void TurnServer::SendErrorResponse(TurnServerConnection* conn, void TurnServer::SendErrorResponse(TurnServerConnection* conn,
const StunMessage* req, const StunMessage* req,
int code, const std::string& reason) { int code, const std::string& reason) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
TurnMessage resp; TurnMessage resp;
InitErrorResponse(req, code, reason, &resp); InitErrorResponse(req, code, reason, &resp);
RTC_LOG(LS_INFO) << "Sending error response, type=" << resp.type() RTC_LOG(LS_INFO) << "Sending error response, type=" << resp.type()
@ -489,7 +489,7 @@ void TurnServer::SendErrorResponse(TurnServerConnection* conn,
void TurnServer::SendErrorResponseWithRealmAndNonce( void TurnServer::SendErrorResponseWithRealmAndNonce(
TurnServerConnection* conn, const StunMessage* msg, TurnServerConnection* conn, const StunMessage* msg,
int code, const std::string& reason) { int code, const std::string& reason) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
TurnMessage resp; TurnMessage resp;
InitErrorResponse(msg, code, reason, &resp); InitErrorResponse(msg, code, reason, &resp);
@ -508,7 +508,7 @@ void TurnServer::SendErrorResponseWithRealmAndNonce(
void TurnServer::SendErrorResponseWithAlternateServer( void TurnServer::SendErrorResponseWithAlternateServer(
TurnServerConnection* conn, const StunMessage* msg, TurnServerConnection* conn, const StunMessage* msg,
const rtc::SocketAddress& addr) { const rtc::SocketAddress& addr) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
TurnMessage resp; TurnMessage resp;
InitErrorResponse(msg, STUN_ERROR_TRY_ALTERNATE, InitErrorResponse(msg, STUN_ERROR_TRY_ALTERNATE,
STUN_ERROR_REASON_TRY_ALTERNATE_SERVER, &resp); STUN_ERROR_REASON_TRY_ALTERNATE_SERVER, &resp);
@ -518,7 +518,7 @@ void TurnServer::SendErrorResponseWithAlternateServer(
} }
void TurnServer::SendStun(TurnServerConnection* conn, StunMessage* msg) { void TurnServer::SendStun(TurnServerConnection* conn, StunMessage* msg) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
rtc::ByteBufferWriter buf; rtc::ByteBufferWriter buf;
// Add a SOFTWARE attribute if one is set. // Add a SOFTWARE attribute if one is set.
if (!software_.empty()) { if (!software_.empty()) {
@ -531,13 +531,13 @@ void TurnServer::SendStun(TurnServerConnection* conn, StunMessage* msg) {
void TurnServer::Send(TurnServerConnection* conn, void TurnServer::Send(TurnServerConnection* conn,
const rtc::ByteBufferWriter& buf) { const rtc::ByteBufferWriter& buf) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
rtc::PacketOptions options; rtc::PacketOptions options;
conn->socket()->SendTo(buf.Data(), buf.Length(), conn->src(), options); conn->socket()->SendTo(buf.Data(), buf.Length(), conn->src(), options);
} }
void TurnServer::OnAllocationDestroyed(TurnServerAllocation* allocation) { void TurnServer::OnAllocationDestroyed(TurnServerAllocation* allocation) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// Removing the internal socket if the connection is not udp. // Removing the internal socket if the connection is not udp.
rtc::AsyncPacketSocket* socket = allocation->conn()->socket(); rtc::AsyncPacketSocket* socket = allocation->conn()->socket();
InternalSocketMap::iterator iter = server_sockets_.find(socket); InternalSocketMap::iterator iter = server_sockets_.find(socket);
@ -557,7 +557,7 @@ void TurnServer::OnAllocationDestroyed(TurnServerAllocation* allocation) {
} }
void TurnServer::DestroyInternalSocket(rtc::AsyncPacketSocket* socket) { void TurnServer::DestroyInternalSocket(rtc::AsyncPacketSocket* socket) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
InternalSocketMap::iterator iter = server_sockets_.find(socket); InternalSocketMap::iterator iter = server_sockets_.find(socket);
if (iter != server_sockets_.end()) { if (iter != server_sockets_.end()) {
rtc::AsyncPacketSocket* socket = iter->first; rtc::AsyncPacketSocket* socket = iter->first;
@ -574,7 +574,7 @@ void TurnServer::DestroyInternalSocket(rtc::AsyncPacketSocket* socket) {
} }
void TurnServer::FreeSockets() { void TurnServer::FreeSockets() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
sockets_to_delete_.clear(); sockets_to_delete_.clear();
} }

View File

@ -181,53 +181,53 @@ class TurnServer : public sigslot::has_slots<> {
// Gets/sets the realm value to use for the server. // Gets/sets the realm value to use for the server.
const std::string& realm() const { const std::string& realm() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return realm_; return realm_;
} }
void set_realm(const std::string& realm) { void set_realm(const std::string& realm) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
realm_ = realm; realm_ = realm;
} }
// Gets/sets the value for the SOFTWARE attribute for TURN messages. // Gets/sets the value for the SOFTWARE attribute for TURN messages.
const std::string& software() const { const std::string& software() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return software_; return software_;
} }
void set_software(const std::string& software) { void set_software(const std::string& software) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
software_ = software; software_ = software;
} }
const AllocationMap& allocations() const { const AllocationMap& allocations() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return allocations_; return allocations_;
} }
// Sets the authentication callback; does not take ownership. // Sets the authentication callback; does not take ownership.
void set_auth_hook(TurnAuthInterface* auth_hook) { void set_auth_hook(TurnAuthInterface* auth_hook) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
auth_hook_ = auth_hook; auth_hook_ = auth_hook;
} }
void set_redirect_hook(TurnRedirectInterface* redirect_hook) { void set_redirect_hook(TurnRedirectInterface* redirect_hook) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
redirect_hook_ = redirect_hook; redirect_hook_ = redirect_hook;
} }
void set_enable_otu_nonce(bool enable) { void set_enable_otu_nonce(bool enable) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
enable_otu_nonce_ = enable; enable_otu_nonce_ = enable;
} }
// If set to true, reject CreatePermission requests to RFC1918 addresses. // If set to true, reject CreatePermission requests to RFC1918 addresses.
void set_reject_private_addresses(bool filter) { void set_reject_private_addresses(bool filter) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
reject_private_addresses_ = filter; reject_private_addresses_ = filter;
} }
void set_enable_permission_checks(bool enable) { void set_enable_permission_checks(bool enable) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
enable_permission_checks_ = enable; enable_permission_checks_ = enable;
} }
@ -244,14 +244,14 @@ class TurnServer : public sigslot::has_slots<> {
const rtc::SocketAddress& address); const rtc::SocketAddress& address);
// For testing only. // For testing only.
std::string SetTimestampForNextNonce(int64_t timestamp) { std::string SetTimestampForNextNonce(int64_t timestamp) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
ts_for_next_nonce_ = timestamp; ts_for_next_nonce_ = timestamp;
return GenerateNonce(timestamp); return GenerateNonce(timestamp);
} }
void SetStunMessageObserver( void SetStunMessageObserver(
std::unique_ptr<StunMessageObserver> observer) { std::unique_ptr<StunMessageObserver> observer) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
stun_message_observer_ = std::move(observer); stun_message_observer_ = std::move(observer);
} }

View File

@ -133,7 +133,7 @@ StunProber::Requester::~Requester() {
} }
void StunProber::Requester::SendStunRequest() { void StunProber::Requester::SendStunRequest() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
requests_.push_back(new Request()); requests_.push_back(new Request());
Request& request = *(requests_.back()); Request& request = *(requests_.back());
cricket::StunMessage message; cricket::StunMessage message;
@ -205,7 +205,7 @@ void StunProber::Requester::OnStunResponseReceived(
size_t size, size_t size,
const rtc::SocketAddress& addr, const rtc::SocketAddress& addr,
const int64_t& /* packet_time_us */) { const int64_t& /* packet_time_us */) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(socket_); RTC_DCHECK(socket_);
Request* request = GetRequestByAddress(addr.ipaddr()); Request* request = GetRequestByAddress(addr.ipaddr());
if (!request) { if (!request) {
@ -220,7 +220,7 @@ void StunProber::Requester::OnStunResponseReceived(
StunProber::Requester::Request* StunProber::Requester::GetRequestByAddress( StunProber::Requester::Request* StunProber::Requester::GetRequestByAddress(
const rtc::IPAddress& ipaddr) { const rtc::IPAddress& ipaddr) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
for (auto* request : requests_) { for (auto* request : requests_) {
if (request->server_addr == ipaddr) { if (request->server_addr == ipaddr) {
return request; return request;
@ -290,7 +290,7 @@ bool StunProber::Prepare(const std::vector<rtc::SocketAddress>& servers,
int num_request_per_ip, int num_request_per_ip,
int timeout_ms, int timeout_ms,
StunProber::Observer* observer) { StunProber::Observer* observer) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
interval_ms_ = interval_ms; interval_ms_ = interval_ms;
shared_socket_mode_ = shared_socket_mode; shared_socket_mode_ = shared_socket_mode;
@ -347,7 +347,7 @@ void StunProber::OnSocketReady(rtc::AsyncPacketSocket* socket,
} }
void StunProber::OnServerResolved(rtc::AsyncResolverInterface* resolver) { void StunProber::OnServerResolved(rtc::AsyncResolverInterface* resolver) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (resolver->GetError() == 0) { if (resolver->GetError() == 0) {
rtc::SocketAddress addr(resolver->address().ipaddr(), rtc::SocketAddress addr(resolver->address().ipaddr(),
@ -404,7 +404,7 @@ void StunProber::CreateSockets() {
} }
StunProber::Requester* StunProber::CreateRequester() { StunProber::Requester* StunProber::CreateRequester() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!sockets_.size()) { if (!sockets_.size()) {
return nullptr; return nullptr;
} }
@ -452,7 +452,7 @@ int StunProber::get_wake_up_interval_ms() {
} }
void StunProber::MaybeScheduleStunRequests() { void StunProber::MaybeScheduleStunRequests() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
int64_t now = rtc::TimeMillis(); int64_t now = rtc::TimeMillis();
if (Done()) { if (Done()) {

View File

@ -32,36 +32,36 @@ AudioTrack::AudioTrack(const std::string& label,
} }
AudioTrack::~AudioTrack() { AudioTrack::~AudioTrack() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
set_state(MediaStreamTrackInterface::kEnded); set_state(MediaStreamTrackInterface::kEnded);
if (audio_source_) if (audio_source_)
audio_source_->UnregisterObserver(this); audio_source_->UnregisterObserver(this);
} }
std::string AudioTrack::kind() const { std::string AudioTrack::kind() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return kAudioKind; return kAudioKind;
} }
AudioSourceInterface* AudioTrack::GetSource() const { AudioSourceInterface* AudioTrack::GetSource() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return audio_source_.get(); return audio_source_.get();
} }
void AudioTrack::AddSink(AudioTrackSinkInterface* sink) { void AudioTrack::AddSink(AudioTrackSinkInterface* sink) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (audio_source_) if (audio_source_)
audio_source_->AddSink(sink); audio_source_->AddSink(sink);
} }
void AudioTrack::RemoveSink(AudioTrackSinkInterface* sink) { void AudioTrack::RemoveSink(AudioTrackSinkInterface* sink) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (audio_source_) if (audio_source_)
audio_source_->RemoveSink(sink); audio_source_->RemoveSink(sink);
} }
void AudioTrack::OnChanged() { void AudioTrack::OnChanged() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (audio_source_->state() == MediaSourceInterface::kEnded) { if (audio_source_->state() == MediaSourceInterface::kEnded) {
set_state(kEnded); set_state(kEnded);
} else { } else {

View File

@ -67,7 +67,7 @@ bool SrtpSession::UpdateRecv(int cs,
} }
bool SrtpSession::ProtectRtp(void* p, int in_len, int max_len, int* out_len) { bool SrtpSession::ProtectRtp(void* p, int in_len, int max_len, int* out_len) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!session_) { if (!session_) {
RTC_LOG(LS_WARNING) << "Failed to protect SRTP packet: no SRTP Session"; RTC_LOG(LS_WARNING) << "Failed to protect SRTP packet: no SRTP Session";
return false; return false;
@ -106,7 +106,7 @@ bool SrtpSession::ProtectRtp(void* p,
} }
bool SrtpSession::ProtectRtcp(void* p, int in_len, int max_len, int* out_len) { bool SrtpSession::ProtectRtcp(void* p, int in_len, int max_len, int* out_len) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!session_) { if (!session_) {
RTC_LOG(LS_WARNING) << "Failed to protect SRTCP packet: no SRTP Session"; RTC_LOG(LS_WARNING) << "Failed to protect SRTCP packet: no SRTP Session";
return false; return false;
@ -129,7 +129,7 @@ bool SrtpSession::ProtectRtcp(void* p, int in_len, int max_len, int* out_len) {
} }
bool SrtpSession::UnprotectRtp(void* p, int in_len, int* out_len) { bool SrtpSession::UnprotectRtp(void* p, int in_len, int* out_len) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!session_) { if (!session_) {
RTC_LOG(LS_WARNING) << "Failed to unprotect SRTP packet: no SRTP Session"; RTC_LOG(LS_WARNING) << "Failed to unprotect SRTP packet: no SRTP Session";
return false; return false;
@ -155,7 +155,7 @@ bool SrtpSession::UnprotectRtp(void* p, int in_len, int* out_len) {
} }
bool SrtpSession::UnprotectRtcp(void* p, int in_len, int* out_len) { bool SrtpSession::UnprotectRtcp(void* p, int in_len, int* out_len) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!session_) { if (!session_) {
RTC_LOG(LS_WARNING) << "Failed to unprotect SRTCP packet: no SRTP Session"; RTC_LOG(LS_WARNING) << "Failed to unprotect SRTCP packet: no SRTP Session";
return false; return false;
@ -173,7 +173,7 @@ bool SrtpSession::UnprotectRtcp(void* p, int in_len, int* out_len) {
} }
bool SrtpSession::GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len) { bool SrtpSession::GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(IsExternalAuthActive()); RTC_DCHECK(IsExternalAuthActive());
if (!IsExternalAuthActive()) { if (!IsExternalAuthActive()) {
return false; return false;
@ -220,7 +220,7 @@ bool SrtpSession::IsExternalAuthActive() const {
bool SrtpSession::GetSendStreamPacketIndex(void* p, bool SrtpSession::GetSendStreamPacketIndex(void* p,
int in_len, int in_len,
int64_t* index) { int64_t* index) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
srtp_hdr_t* hdr = reinterpret_cast<srtp_hdr_t*>(p); srtp_hdr_t* hdr = reinterpret_cast<srtp_hdr_t*>(p);
srtp_stream_ctx_t* stream = srtp_get_stream(session_, hdr->ssrc); srtp_stream_ctx_t* stream = srtp_get_stream(session_, hdr->ssrc);
if (!stream) { if (!stream) {
@ -238,7 +238,7 @@ bool SrtpSession::DoSetKey(int type,
const uint8_t* key, const uint8_t* key,
size_t len, size_t len,
const std::vector<int>& extension_ids) { const std::vector<int>& extension_ids) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
srtp_policy_t policy; srtp_policy_t policy;
memset(&policy, 0, sizeof(policy)); memset(&policy, 0, sizeof(policy));
@ -330,7 +330,7 @@ bool SrtpSession::SetKey(int type,
const uint8_t* key, const uint8_t* key,
size_t len, size_t len,
const std::vector<int>& extension_ids) { const std::vector<int>& extension_ids) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (session_) { if (session_) {
RTC_LOG(LS_ERROR) << "Failed to create SRTP session: " RTC_LOG(LS_ERROR) << "Failed to create SRTP session: "
"SRTP session already created"; "SRTP session already created";
@ -353,7 +353,7 @@ bool SrtpSession::UpdateKey(int type,
const uint8_t* key, const uint8_t* key,
size_t len, size_t len,
const std::vector<int>& extension_ids) { const std::vector<int>& extension_ids) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!session_) { if (!session_) {
RTC_LOG(LS_ERROR) << "Failed to update non-existing SRTP session"; RTC_LOG(LS_ERROR) << "Failed to update non-existing SRTP session";
return false; return false;
@ -408,7 +408,7 @@ void SrtpSession::DecrementLibsrtpUsageCountAndMaybeDeinit() {
} }
void SrtpSession::HandleEvent(const srtp_event_data_t* ev) { void SrtpSession::HandleEvent(const srtp_event_data_t* ev) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
switch (ev->event) { switch (ev->event) {
case event_ssrc_collision: case event_ssrc_collision:
RTC_LOG(LS_INFO) << "SRTP event: SSRC collision"; RTC_LOG(LS_INFO) << "SRTP event: SSRC collision";

View File

@ -46,7 +46,7 @@ class FakePeriodicVideoSource final
config.timestamp_offset_ms * rtc::kNumMicrosecsPerMillisec), config.timestamp_offset_ms * rtc::kNumMicrosecsPerMillisec),
task_queue_(absl::make_unique<TaskQueueForTest>( task_queue_(absl::make_unique<TaskQueueForTest>(
"FakePeriodicVideoTrackSource")) { "FakePeriodicVideoTrackSource")) {
thread_checker_.DetachFromThread(); thread_checker_.Detach();
frame_source_.SetRotation(config.rotation); frame_source_.SetRotation(config.rotation);
TimeDelta frame_interval = TimeDelta::ms(config.frame_interval_ms); TimeDelta frame_interval = TimeDelta::ms(config.frame_interval_ms);
@ -61,13 +61,13 @@ class FakePeriodicVideoSource final
} }
void RemoveSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) override { void RemoveSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) override {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
broadcaster_.RemoveSink(sink); broadcaster_.RemoveSink(sink);
} }
void AddOrUpdateSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink, void AddOrUpdateSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink,
const rtc::VideoSinkWants& wants) override { const rtc::VideoSinkWants& wants) override {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
broadcaster_.AddOrUpdateSink(sink, wants); broadcaster_.AddOrUpdateSink(sink, wants);
} }

View File

@ -79,7 +79,7 @@ PeerConnectionTestWrapper::PeerConnectionTestWrapper(
: name_(name), : name_(name),
network_thread_(network_thread), network_thread_(network_thread),
worker_thread_(worker_thread) { worker_thread_(worker_thread) {
pc_thread_checker_.DetachFromThread(); pc_thread_checker_.Detach();
} }
PeerConnectionTestWrapper::~PeerConnectionTestWrapper() { PeerConnectionTestWrapper::~PeerConnectionTestWrapper() {

View File

@ -26,14 +26,14 @@ class RTCStatsObtainer : public RTCStatsCollectorCallback {
void OnStatsDelivered( void OnStatsDelivered(
const rtc::scoped_refptr<const RTCStatsReport>& report) override { const rtc::scoped_refptr<const RTCStatsReport>& report) override {
EXPECT_TRUE(thread_checker_.CalledOnValidThread()); EXPECT_TRUE(thread_checker_.IsCurrent());
report_ = report; report_ = report;
if (report_ptr_) if (report_ptr_)
*report_ptr_ = report_; *report_ptr_ = report_;
} }
rtc::scoped_refptr<const RTCStatsReport> report() const { rtc::scoped_refptr<const RTCStatsReport> report() const {
EXPECT_TRUE(thread_checker_.CalledOnValidThread()); EXPECT_TRUE(thread_checker_.IsCurrent());
return report_; return report_;
} }

View File

@ -68,7 +68,7 @@ void VideoTrack::set_content_hint(ContentHint hint) {
} }
bool VideoTrack::set_enabled(bool enable) { bool VideoTrack::set_enabled(bool enable) {
RTC_DCHECK(signaling_thread_checker_.CalledOnValidThread()); RTC_DCHECK(signaling_thread_checker_.IsCurrent());
worker_thread_->Invoke<void>(RTC_FROM_HERE, [enable, this] { worker_thread_->Invoke<void>(RTC_FROM_HERE, [enable, this] {
RTC_DCHECK(worker_thread_->IsCurrent()); RTC_DCHECK(worker_thread_->IsCurrent());
for (auto& sink_pair : sink_pairs()) { for (auto& sink_pair : sink_pairs()) {
@ -81,7 +81,7 @@ bool VideoTrack::set_enabled(bool enable) {
} }
void VideoTrack::OnChanged() { void VideoTrack::OnChanged() {
RTC_DCHECK(signaling_thread_checker_.CalledOnValidThread()); RTC_DCHECK(signaling_thread_checker_.IsCurrent());
if (video_source_->state() == MediaSourceInterface::kEnded) { if (video_source_->state() == MediaSourceInterface::kEnded) {
set_state(kEnded); set_state(kEnded);
} else { } else {

View File

@ -17,7 +17,7 @@ namespace webrtc {
VideoTrackSource::VideoTrackSource( VideoTrackSource::VideoTrackSource(
bool remote) bool remote)
: state_(kInitializing), remote_(remote) { : state_(kInitializing), remote_(remote) {
worker_thread_checker_.DetachFromThread(); worker_thread_checker_.Detach();
} }
void VideoTrackSource::SetState(SourceState new_state) { void VideoTrackSource::SetState(SourceState new_state) {
@ -30,12 +30,12 @@ void VideoTrackSource::SetState(SourceState new_state) {
void VideoTrackSource::AddOrUpdateSink( void VideoTrackSource::AddOrUpdateSink(
rtc::VideoSinkInterface<VideoFrame>* sink, rtc::VideoSinkInterface<VideoFrame>* sink,
const rtc::VideoSinkWants& wants) { const rtc::VideoSinkWants& wants) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
source()->AddOrUpdateSink(sink, wants); source()->AddOrUpdateSink(sink, wants);
} }
void VideoTrackSource::RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) { void VideoTrackSource::RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.IsCurrent());
source()->RemoveSink(sink); source()->RemoveSink(sink);
} }

View File

@ -319,6 +319,7 @@ rtc_source_set("thread_checker") {
"thread_checker.h", "thread_checker.h",
] ]
deps = [ deps = [
":deprecation",
"synchronization:sequence_checker", "synchronization:sequence_checker",
] ]
} }

View File

@ -91,7 +91,7 @@ class EventLogger final {
this, this,
"EventTracingThread", "EventTracingThread",
kLowPriority) {} kLowPriority) {}
~EventLogger() { RTC_DCHECK(thread_checker_.CalledOnValidThread()); } ~EventLogger() { RTC_DCHECK(thread_checker_.IsCurrent()); }
void AddTraceEvent(const char* name, void AddTraceEvent(const char* name,
const unsigned char* category_enabled, const unsigned char* category_enabled,
@ -189,7 +189,7 @@ class EventLogger final {
} }
void Start(FILE* file, bool owned) { void Start(FILE* file, bool owned) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(file); RTC_DCHECK(file);
RTC_DCHECK(!output_file_); RTC_DCHECK(!output_file_);
output_file_ = file; output_file_ = file;
@ -213,7 +213,7 @@ class EventLogger final {
} }
void Stop() { void Stop() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
TRACE_EVENT_INSTANT0("webrtc", "EventLogger::Stop"); TRACE_EVENT_INSTANT0("webrtc", "EventLogger::Stop");
// Try to stop. Abort if we're not currently logging. // Try to stop. Abort if we're not currently logging.
if (rtc::AtomicOps::CompareAndSwap(&g_event_logging_active, 1, 0) == 0) if (rtc::AtomicOps::CompareAndSwap(&g_event_logging_active, 1, 0) == 0)

View File

@ -43,7 +43,7 @@ PlatformThread::PlatformThread(ThreadRunFunctionDeprecated func,
: run_function_deprecated_(func), obj_(obj), name_(thread_name) { : run_function_deprecated_(func), obj_(obj), name_(thread_name) {
RTC_DCHECK(func); RTC_DCHECK(func);
RTC_DCHECK(name_.length() < 64); RTC_DCHECK(name_.length() < 64);
spawned_thread_checker_.DetachFromThread(); spawned_thread_checker_.Detach();
} }
PlatformThread::PlatformThread(ThreadRunFunction func, PlatformThread::PlatformThread(ThreadRunFunction func,
@ -55,11 +55,11 @@ PlatformThread::PlatformThread(ThreadRunFunction func,
RTC_DCHECK(!name_.empty()); RTC_DCHECK(!name_.empty());
// TODO(tommi): Consider lowering the limit to 15 (limit on Linux). // TODO(tommi): Consider lowering the limit to 15 (limit on Linux).
RTC_DCHECK(name_.length() < 64); RTC_DCHECK(name_.length() < 64);
spawned_thread_checker_.DetachFromThread(); spawned_thread_checker_.Detach();
} }
PlatformThread::~PlatformThread() { PlatformThread::~PlatformThread() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
#if defined(WEBRTC_WIN) #if defined(WEBRTC_WIN)
RTC_DCHECK(!thread_); RTC_DCHECK(!thread_);
RTC_DCHECK(!thread_id_); RTC_DCHECK(!thread_id_);
@ -84,7 +84,7 @@ void* PlatformThread::StartThread(void* param) {
#endif // defined(WEBRTC_WIN) #endif // defined(WEBRTC_WIN)
void PlatformThread::Start() { void PlatformThread::Start() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!thread_) << "Thread already started?"; RTC_DCHECK(!thread_) << "Thread already started?";
#if defined(WEBRTC_WIN) #if defined(WEBRTC_WIN)
stop_ = false; stop_ = false;
@ -105,7 +105,7 @@ void PlatformThread::Start() {
} }
bool PlatformThread::IsRunning() const { bool PlatformThread::IsRunning() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
#if defined(WEBRTC_WIN) #if defined(WEBRTC_WIN)
return thread_ != nullptr; return thread_ != nullptr;
#else #else
@ -122,7 +122,7 @@ PlatformThreadRef PlatformThread::GetThreadRef() const {
} }
void PlatformThread::Stop() { void PlatformThread::Stop() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!IsRunning()) if (!IsRunning())
return; return;
@ -150,7 +150,7 @@ void PlatformThread::Stop() {
AtomicOps::ReleaseStore(&stop_flag_, 0); AtomicOps::ReleaseStore(&stop_flag_, 0);
thread_ = 0; thread_ = 0;
#endif // defined(WEBRTC_WIN) #endif // defined(WEBRTC_WIN)
spawned_thread_checker_.DetachFromThread(); spawned_thread_checker_.Detach();
} }
// TODO(tommi): Deprecate the loop behavior in PlatformThread. // TODO(tommi): Deprecate the loop behavior in PlatformThread.
@ -162,7 +162,7 @@ void PlatformThread::Stop() {
// and encouraging a busy polling loop, can be costly in terms of power and cpu. // and encouraging a busy polling loop, can be costly in terms of power and cpu.
void PlatformThread::Run() { void PlatformThread::Run() {
// Attach the worker thread checker to this thread. // Attach the worker thread checker to this thread.
RTC_DCHECK(spawned_thread_checker_.CalledOnValidThread()); RTC_DCHECK(spawned_thread_checker_.IsCurrent());
rtc::SetCurrentThreadName(name_.c_str()); rtc::SetCurrentThreadName(name_.c_str());
if (run_function_) { if (run_function_) {
@ -225,11 +225,11 @@ bool PlatformThread::SetPriority(ThreadPriority priority) {
if (run_function_) { if (run_function_) {
// The non-deprecated way of how this function gets called, is that it must // The non-deprecated way of how this function gets called, is that it must
// be called on the worker thread itself. // be called on the worker thread itself.
RTC_DCHECK(spawned_thread_checker_.CalledOnValidThread()); RTC_DCHECK(spawned_thread_checker_.IsCurrent());
} else { } else {
// In the case of deprecated use of this method, it must be called on the // In the case of deprecated use of this method, it must be called on the
// same thread as the PlatformThread object is constructed on. // same thread as the PlatformThread object is constructed on.
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(IsRunning()); RTC_DCHECK(IsRunning());
} }
#endif #endif
@ -283,7 +283,7 @@ bool PlatformThread::SetPriority(ThreadPriority priority) {
#if defined(WEBRTC_WIN) #if defined(WEBRTC_WIN)
bool PlatformThread::QueueAPC(PAPCFUNC function, ULONG_PTR data) { bool PlatformThread::QueueAPC(PAPCFUNC function, ULONG_PTR data) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(IsRunning()); RTC_DCHECK(IsRunning());
return QueueUserAPC(function, thread_, data) != FALSE; return QueueUserAPC(function, thread_, data) != FALSE;

View File

@ -77,7 +77,7 @@ TEST(SequencedTaskCheckerTest, DestructorAllowedOnDifferentThread) {
}); });
} }
TEST(SequencedTaskCheckerTest, DetachFromThread) { TEST(SequencedTaskCheckerTest, Detach) {
SequencedTaskChecker sequenced_task_checker; SequencedTaskChecker sequenced_task_checker;
sequenced_task_checker.Detach(); sequenced_task_checker.Detach();
RunOnDifferentThread( RunOnDifferentThread(

View File

@ -13,14 +13,15 @@
#ifndef RTC_BASE_THREAD_CHECKER_H_ #ifndef RTC_BASE_THREAD_CHECKER_H_
#define RTC_BASE_THREAD_CHECKER_H_ #define RTC_BASE_THREAD_CHECKER_H_
#include "rtc_base/deprecation.h"
#include "rtc_base/synchronization/sequence_checker.h" #include "rtc_base/synchronization/sequence_checker.h"
namespace rtc { namespace rtc {
// TODO(srte): Replace usages of this with SequenceChecker. // TODO(srte): Replace usages of this with SequenceChecker.
class ThreadChecker : public webrtc::SequenceChecker { class ThreadChecker : public webrtc::SequenceChecker {
public: public:
bool CalledOnValidThread() const { return IsCurrent(); } RTC_DEPRECATED bool CalledOnValidThread() const { return IsCurrent(); }
void DetachFromThread() { Detach(); } RTC_DEPRECATED void DetachFromThread() { Detach(); }
}; };
} // namespace rtc } // namespace rtc
#endif // RTC_BASE_THREAD_CHECKER_H_ #endif // RTC_BASE_THREAD_CHECKER_H_

View File

@ -38,9 +38,9 @@ class ThreadCheckerClass : public ThreadChecker {
ThreadCheckerClass() {} ThreadCheckerClass() {}
// Verifies that it was called on the same thread as the constructor. // Verifies that it was called on the same thread as the constructor.
void DoStuff() { RTC_DCHECK(CalledOnValidThread()); } void DoStuff() { RTC_DCHECK(IsCurrent()); }
void DetachFromThread() { ThreadChecker::DetachFromThread(); } void Detach() { ThreadChecker::Detach(); }
static void MethodOnDifferentThreadImpl(); static void MethodOnDifferentThreadImpl();
static void DetachThenCallFromDifferentThreadImpl(); static void DetachThenCallFromDifferentThreadImpl();
@ -124,13 +124,13 @@ TEST(ThreadCheckerTest, DestructorAllowedOnDifferentThread) {
EXPECT_TRUE(delete_on_thread.has_been_deleted()); EXPECT_TRUE(delete_on_thread.has_been_deleted());
} }
TEST(ThreadCheckerTest, DetachFromThread) { TEST(ThreadCheckerTest, Detach) {
std::unique_ptr<ThreadCheckerClass> thread_checker_class( std::unique_ptr<ThreadCheckerClass> thread_checker_class(
new ThreadCheckerClass); new ThreadCheckerClass);
// Verify that DoStuff doesn't assert when called on a different thread after // Verify that DoStuff doesn't assert when called on a different thread after
// a call to DetachFromThread. // a call to Detach.
thread_checker_class->DetachFromThread(); thread_checker_class->Detach();
CallDoStuffOnThread call_on_thread(thread_checker_class.get()); CallDoStuffOnThread call_on_thread(thread_checker_class.get());
call_on_thread.Start(); call_on_thread.Start();
@ -166,8 +166,8 @@ void ThreadCheckerClass::DetachThenCallFromDifferentThreadImpl() {
new ThreadCheckerClass); new ThreadCheckerClass);
// DoStuff doesn't assert when called on a different thread // DoStuff doesn't assert when called on a different thread
// after a call to DetachFromThread. // after a call to Detach.
thread_checker_class->DetachFromThread(); thread_checker_class->Detach();
CallDoStuffOnThread call_on_thread(thread_checker_class.get()); CallDoStuffOnThread call_on_thread(thread_checker_class.get());
call_on_thread.Start(); call_on_thread.Start();

View File

@ -58,7 +58,7 @@ Iterable::Iterator::~Iterator() = default;
// Advances the iterator one step. // Advances the iterator one step.
Iterable::Iterator& Iterable::Iterator::operator++() { Iterable::Iterator& Iterable::Iterator::operator++() {
RTC_CHECK(thread_checker_.CalledOnValidThread()); RTC_CHECK(thread_checker_.IsCurrent());
if (AtEnd()) { if (AtEnd()) {
// Can't move past the end. // Can't move past the end.
return *this; return *this;
@ -93,7 +93,7 @@ ScopedJavaLocalRef<jobject>& Iterable::Iterator::operator*() {
} }
bool Iterable::Iterator::AtEnd() const { bool Iterable::Iterator::AtEnd() const {
RTC_CHECK(thread_checker_.CalledOnValidThread()); RTC_CHECK(thread_checker_.IsCurrent());
return jni_ == nullptr || IsNull(jni_, iterator_); return jni_ == nullptr || IsNull(jni_, iterator_);
} }

View File

@ -174,7 +174,7 @@ AndroidNetworkMonitor::AndroidNetworkMonitor(
AndroidNetworkMonitor::~AndroidNetworkMonitor() = default; AndroidNetworkMonitor::~AndroidNetworkMonitor() = default;
void AndroidNetworkMonitor::Start() { void AndroidNetworkMonitor::Start() {
RTC_CHECK(thread_checker_.CalledOnValidThread()); RTC_CHECK(thread_checker_.IsCurrent());
if (started_) { if (started_) {
return; return;
} }
@ -191,7 +191,7 @@ void AndroidNetworkMonitor::Start() {
} }
void AndroidNetworkMonitor::Stop() { void AndroidNetworkMonitor::Stop() {
RTC_CHECK(thread_checker_.CalledOnValidThread()); RTC_CHECK(thread_checker_.IsCurrent());
if (!started_) { if (!started_) {
return; return;
} }
@ -216,7 +216,7 @@ void AndroidNetworkMonitor::Stop() {
rtc::NetworkBindingResult AndroidNetworkMonitor::BindSocketToNetwork( rtc::NetworkBindingResult AndroidNetworkMonitor::BindSocketToNetwork(
int socket_fd, int socket_fd,
const rtc::IPAddress& address) { const rtc::IPAddress& address) {
RTC_CHECK(thread_checker_.CalledOnValidThread()); RTC_CHECK(thread_checker_.IsCurrent());
// Android prior to Lollipop didn't have support for binding sockets to // Android prior to Lollipop didn't have support for binding sockets to
// networks. This may also occur if there is no connectivity manager service. // networks. This may also occur if there is no connectivity manager service.
@ -354,7 +354,7 @@ void AndroidNetworkMonitor::OnNetworkDisconnected_w(NetworkHandle handle) {
void AndroidNetworkMonitor::SetNetworkInfos( void AndroidNetworkMonitor::SetNetworkInfos(
const std::vector<NetworkInformation>& network_infos) { const std::vector<NetworkInformation>& network_infos) {
RTC_CHECK(thread_checker_.CalledOnValidThread()); RTC_CHECK(thread_checker_.IsCurrent());
network_handle_by_address_.clear(); network_handle_by_address_.clear();
network_info_by_handle_.clear(); network_info_by_handle_.clear();
RTC_LOG(LS_INFO) << "Android network monitor found " << network_infos.size() RTC_LOG(LS_INFO) << "Android network monitor found " << network_infos.size()

View File

@ -28,7 +28,7 @@ AAudioPlayer::AAudioPlayer(const AudioParameters& audio_parameters)
: main_thread_(rtc::Thread::Current()), : main_thread_(rtc::Thread::Current()),
aaudio_(audio_parameters, AAUDIO_DIRECTION_OUTPUT, this) { aaudio_(audio_parameters, AAUDIO_DIRECTION_OUTPUT, this) {
RTC_LOG(INFO) << "ctor"; RTC_LOG(INFO) << "ctor";
thread_checker_aaudio_.DetachFromThread(); thread_checker_aaudio_.Detach();
} }
AAudioPlayer::~AAudioPlayer() { AAudioPlayer::~AAudioPlayer() {
@ -102,7 +102,7 @@ int AAudioPlayer::StopPlayout() {
RTC_LOG(LS_ERROR) << "StopPlayout failed"; RTC_LOG(LS_ERROR) << "StopPlayout failed";
return -1; return -1;
} }
thread_checker_aaudio_.DetachFromThread(); thread_checker_aaudio_.Detach();
initialized_ = false; initialized_ = false;
playing_ = false; playing_ = false;
return 0; return 0;

View File

@ -31,19 +31,19 @@ AAudioRecorder::AAudioRecorder(const AudioParameters& audio_parameters)
: main_thread_(rtc::Thread::Current()), : main_thread_(rtc::Thread::Current()),
aaudio_(audio_parameters, AAUDIO_DIRECTION_INPUT, this) { aaudio_(audio_parameters, AAUDIO_DIRECTION_INPUT, this) {
RTC_LOG(INFO) << "ctor"; RTC_LOG(INFO) << "ctor";
thread_checker_aaudio_.DetachFromThread(); thread_checker_aaudio_.Detach();
} }
AAudioRecorder::~AAudioRecorder() { AAudioRecorder::~AAudioRecorder() {
RTC_LOG(INFO) << "dtor"; RTC_LOG(INFO) << "dtor";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
Terminate(); Terminate();
RTC_LOG(INFO) << "detected owerflows: " << overflow_count_; RTC_LOG(INFO) << "detected owerflows: " << overflow_count_;
} }
int AAudioRecorder::Init() { int AAudioRecorder::Init() {
RTC_LOG(INFO) << "Init"; RTC_LOG(INFO) << "Init";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (aaudio_.audio_parameters().channels() == 2) { if (aaudio_.audio_parameters().channels() == 2) {
RTC_DLOG(LS_WARNING) << "Stereo mode is enabled"; RTC_DLOG(LS_WARNING) << "Stereo mode is enabled";
} }
@ -52,14 +52,14 @@ int AAudioRecorder::Init() {
int AAudioRecorder::Terminate() { int AAudioRecorder::Terminate() {
RTC_LOG(INFO) << "Terminate"; RTC_LOG(INFO) << "Terminate";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
StopRecording(); StopRecording();
return 0; return 0;
} }
int AAudioRecorder::InitRecording() { int AAudioRecorder::InitRecording() {
RTC_LOG(INFO) << "InitRecording"; RTC_LOG(INFO) << "InitRecording";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!initialized_); RTC_DCHECK(!initialized_);
RTC_DCHECK(!recording_); RTC_DCHECK(!recording_);
if (!aaudio_.Init()) { if (!aaudio_.Init()) {
@ -75,7 +75,7 @@ bool AAudioRecorder::RecordingIsInitialized() const {
int AAudioRecorder::StartRecording() { int AAudioRecorder::StartRecording() {
RTC_LOG(INFO) << "StartRecording"; RTC_LOG(INFO) << "StartRecording";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(initialized_); RTC_DCHECK(initialized_);
RTC_DCHECK(!recording_); RTC_DCHECK(!recording_);
if (fine_audio_buffer_) { if (fine_audio_buffer_) {
@ -92,14 +92,14 @@ int AAudioRecorder::StartRecording() {
int AAudioRecorder::StopRecording() { int AAudioRecorder::StopRecording() {
RTC_LOG(INFO) << "StopRecording"; RTC_LOG(INFO) << "StopRecording";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!initialized_ || !recording_) { if (!initialized_ || !recording_) {
return 0; return 0;
} }
if (!aaudio_.Stop()) { if (!aaudio_.Stop()) {
return -1; return -1;
} }
thread_checker_aaudio_.DetachFromThread(); thread_checker_aaudio_.Detach();
initialized_ = false; initialized_ = false;
recording_ = false; recording_ = false;
return 0; return 0;
@ -111,7 +111,7 @@ bool AAudioRecorder::Recording() const {
void AAudioRecorder::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) { void AAudioRecorder::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
RTC_LOG(INFO) << "AttachAudioBuffer"; RTC_LOG(INFO) << "AttachAudioBuffer";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
audio_device_buffer_ = audioBuffer; audio_device_buffer_ = audioBuffer;
const AudioParameters audio_parameters = aaudio_.audio_parameters(); const AudioParameters audio_parameters = aaudio_.audio_parameters();
audio_device_buffer_->SetRecordingSampleRate(audio_parameters.sample_rate()); audio_device_buffer_->SetRecordingSampleRate(audio_parameters.sample_rate());
@ -145,7 +145,7 @@ int AAudioRecorder::EnableBuiltInNS(bool enable) {
void AAudioRecorder::OnErrorCallback(aaudio_result_t error) { void AAudioRecorder::OnErrorCallback(aaudio_result_t error) {
RTC_LOG(LS_ERROR) << "OnErrorCallback: " << AAudio_convertResultToText(error); RTC_LOG(LS_ERROR) << "OnErrorCallback: " << AAudio_convertResultToText(error);
// RTC_DCHECK(thread_checker_aaudio_.CalledOnValidThread()); // RTC_DCHECK(thread_checker_aaudio_.IsCurrent());
if (aaudio_.stream_state() == AAUDIO_STREAM_STATE_DISCONNECTED) { if (aaudio_.stream_state() == AAUDIO_STREAM_STATE_DISCONNECTED) {
// The stream is disconnected and any attempt to use it will return // The stream is disconnected and any attempt to use it will return
// AAUDIO_ERROR_DISCONNECTED.. // AAUDIO_ERROR_DISCONNECTED..
@ -165,7 +165,7 @@ aaudio_data_callback_result_t AAudioRecorder::OnDataCallback(
void* audio_data, void* audio_data,
int32_t num_frames) { int32_t num_frames) {
// TODO(henrika): figure out why we sometimes hit this one. // TODO(henrika): figure out why we sometimes hit this one.
// RTC_DCHECK(thread_checker_aaudio_.CalledOnValidThread()); // RTC_DCHECK(thread_checker_aaudio_.IsCurrent());
// RTC_LOG(INFO) << "OnDataCallback: " << num_frames; // RTC_LOG(INFO) << "OnDataCallback: " << num_frames;
// Drain the input buffer at first callback to ensure that it does not // Drain the input buffer at first callback to ensure that it does not
// contain any old data. Will also ensure that the lowest possible latency // contain any old data. Will also ensure that the lowest possible latency

View File

@ -139,19 +139,19 @@ AAudioWrapper::AAudioWrapper(const AudioParameters& audio_parameters,
observer_(observer) { observer_(observer) {
RTC_LOG(INFO) << "ctor"; RTC_LOG(INFO) << "ctor";
RTC_DCHECK(observer_); RTC_DCHECK(observer_);
aaudio_thread_checker_.DetachFromThread(); aaudio_thread_checker_.Detach();
RTC_LOG(INFO) << audio_parameters_.ToString(); RTC_LOG(INFO) << audio_parameters_.ToString();
} }
AAudioWrapper::~AAudioWrapper() { AAudioWrapper::~AAudioWrapper() {
RTC_LOG(INFO) << "dtor"; RTC_LOG(INFO) << "dtor";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!stream_); RTC_DCHECK(!stream_);
} }
bool AAudioWrapper::Init() { bool AAudioWrapper::Init() {
RTC_LOG(INFO) << "Init"; RTC_LOG(INFO) << "Init";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// Creates a stream builder which can be used to open an audio stream. // Creates a stream builder which can be used to open an audio stream.
ScopedStreamBuilder builder; ScopedStreamBuilder builder;
// Configures the stream builder using audio parameters given at construction. // Configures the stream builder using audio parameters given at construction.
@ -175,7 +175,7 @@ bool AAudioWrapper::Init() {
bool AAudioWrapper::Start() { bool AAudioWrapper::Start() {
RTC_LOG(INFO) << "Start"; RTC_LOG(INFO) << "Start";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// TODO(henrika): this state check might not be needed. // TODO(henrika): this state check might not be needed.
aaudio_stream_state_t current_state = AAudioStream_getState(stream_); aaudio_stream_state_t current_state = AAudioStream_getState(stream_);
if (current_state != AAUDIO_STREAM_STATE_OPEN) { if (current_state != AAUDIO_STREAM_STATE_OPEN) {
@ -191,11 +191,11 @@ bool AAudioWrapper::Start() {
bool AAudioWrapper::Stop() { bool AAudioWrapper::Stop() {
RTC_LOG(INFO) << "Stop: " << DirectionToString(direction()); RTC_LOG(INFO) << "Stop: " << DirectionToString(direction());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// Asynchronous request for the stream to stop. // Asynchronous request for the stream to stop.
RETURN_ON_ERROR(AAudioStream_requestStop(stream_), false); RETURN_ON_ERROR(AAudioStream_requestStop(stream_), false);
CloseStream(); CloseStream();
aaudio_thread_checker_.DetachFromThread(); aaudio_thread_checker_.Detach();
return true; return true;
} }
@ -242,7 +242,7 @@ double AAudioWrapper::EstimateLatencyMillis() const {
bool AAudioWrapper::IncreaseOutputBufferSize() { bool AAudioWrapper::IncreaseOutputBufferSize() {
RTC_LOG(INFO) << "IncreaseBufferSize"; RTC_LOG(INFO) << "IncreaseBufferSize";
RTC_DCHECK(stream_); RTC_DCHECK(stream_);
RTC_DCHECK(aaudio_thread_checker_.CalledOnValidThread()); RTC_DCHECK(aaudio_thread_checker_.IsCurrent());
RTC_DCHECK_EQ(direction(), AAUDIO_DIRECTION_OUTPUT); RTC_DCHECK_EQ(direction(), AAUDIO_DIRECTION_OUTPUT);
aaudio_result_t buffer_size = AAudioStream_getBufferSizeInFrames(stream_); aaudio_result_t buffer_size = AAudioStream_getBufferSizeInFrames(stream_);
// Try to increase size of buffer with one burst to reduce risk of underrun. // Try to increase size of buffer with one burst to reduce risk of underrun.
@ -270,7 +270,7 @@ bool AAudioWrapper::IncreaseOutputBufferSize() {
void AAudioWrapper::ClearInputStream(void* audio_data, int32_t num_frames) { void AAudioWrapper::ClearInputStream(void* audio_data, int32_t num_frames) {
RTC_LOG(INFO) << "ClearInputStream"; RTC_LOG(INFO) << "ClearInputStream";
RTC_DCHECK(stream_); RTC_DCHECK(stream_);
RTC_DCHECK(aaudio_thread_checker_.CalledOnValidThread()); RTC_DCHECK(aaudio_thread_checker_.IsCurrent());
RTC_DCHECK_EQ(direction(), AAUDIO_DIRECTION_INPUT); RTC_DCHECK_EQ(direction(), AAUDIO_DIRECTION_INPUT);
aaudio_result_t cleared_frames = 0; aaudio_result_t cleared_frames = 0;
do { do {
@ -359,7 +359,7 @@ int64_t AAudioWrapper::frames_read() const {
void AAudioWrapper::SetStreamConfiguration(AAudioStreamBuilder* builder) { void AAudioWrapper::SetStreamConfiguration(AAudioStreamBuilder* builder) {
RTC_LOG(INFO) << "SetStreamConfiguration"; RTC_LOG(INFO) << "SetStreamConfiguration";
RTC_DCHECK(builder); RTC_DCHECK(builder);
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// Request usage of default primary output/input device. // Request usage of default primary output/input device.
// TODO(henrika): verify that default device follows Java APIs. // TODO(henrika): verify that default device follows Java APIs.
// https://developer.android.com/reference/android/media/AudioDeviceInfo.html. // https://developer.android.com/reference/android/media/AudioDeviceInfo.html.

View File

@ -69,7 +69,7 @@ class AndroidAudioDeviceModule : public AudioDeviceModule {
RTC_CHECK(input_); RTC_CHECK(input_);
RTC_CHECK(output_); RTC_CHECK(output_);
RTC_LOG(INFO) << __FUNCTION__; RTC_LOG(INFO) << __FUNCTION__;
thread_checker_.DetachFromThread(); thread_checker_.Detach();
} }
~AndroidAudioDeviceModule() override { RTC_LOG(INFO) << __FUNCTION__; } ~AndroidAudioDeviceModule() override { RTC_LOG(INFO) << __FUNCTION__; }
@ -88,7 +88,7 @@ class AndroidAudioDeviceModule : public AudioDeviceModule {
int32_t Init() override { int32_t Init() override {
RTC_LOG(INFO) << __FUNCTION__; RTC_LOG(INFO) << __FUNCTION__;
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
audio_device_buffer_ = audio_device_buffer_ =
absl::make_unique<AudioDeviceBuffer>(&GlobalTaskQueueFactory()); absl::make_unique<AudioDeviceBuffer>(&GlobalTaskQueueFactory());
AttachAudioBuffer(); AttachAudioBuffer();
@ -119,11 +119,11 @@ class AndroidAudioDeviceModule : public AudioDeviceModule {
RTC_LOG(INFO) << __FUNCTION__; RTC_LOG(INFO) << __FUNCTION__;
if (!initialized_) if (!initialized_)
return 0; return 0;
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
int32_t err = input_->Terminate(); int32_t err = input_->Terminate();
err |= output_->Terminate(); err |= output_->Terminate();
initialized_ = false; initialized_ = false;
thread_checker_.DetachFromThread(); thread_checker_.Detach();
audio_device_buffer_.reset(nullptr); audio_device_buffer_.reset(nullptr);
RTC_DCHECK_EQ(err, 0); RTC_DCHECK_EQ(err, 0);
return err; return err;

View File

@ -74,34 +74,34 @@ AudioRecordJni::AudioRecordJni(JNIEnv* env,
jni::jlongFromPointer(this)); jni::jlongFromPointer(this));
// Detach from this thread since construction is allowed to happen on a // Detach from this thread since construction is allowed to happen on a
// different thread. // different thread.
thread_checker_.DetachFromThread(); thread_checker_.Detach();
thread_checker_java_.DetachFromThread(); thread_checker_java_.Detach();
} }
AudioRecordJni::~AudioRecordJni() { AudioRecordJni::~AudioRecordJni() {
RTC_LOG(INFO) << "dtor"; RTC_LOG(INFO) << "dtor";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
Terminate(); Terminate();
} }
int32_t AudioRecordJni::Init() { int32_t AudioRecordJni::Init() {
RTC_LOG(INFO) << "Init"; RTC_LOG(INFO) << "Init";
env_ = AttachCurrentThreadIfNeeded(); env_ = AttachCurrentThreadIfNeeded();
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return 0; return 0;
} }
int32_t AudioRecordJni::Terminate() { int32_t AudioRecordJni::Terminate() {
RTC_LOG(INFO) << "Terminate"; RTC_LOG(INFO) << "Terminate";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
StopRecording(); StopRecording();
thread_checker_.DetachFromThread(); thread_checker_.Detach();
return 0; return 0;
} }
int32_t AudioRecordJni::InitRecording() { int32_t AudioRecordJni::InitRecording() {
RTC_LOG(INFO) << "InitRecording"; RTC_LOG(INFO) << "InitRecording";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (initialized_) { if (initialized_) {
// Already initialized. // Already initialized.
return 0; return 0;
@ -133,7 +133,7 @@ bool AudioRecordJni::RecordingIsInitialized() const {
int32_t AudioRecordJni::StartRecording() { int32_t AudioRecordJni::StartRecording() {
RTC_LOG(INFO) << "StartRecording"; RTC_LOG(INFO) << "StartRecording";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (recording_) { if (recording_) {
// Already recording. // Already recording.
return 0; return 0;
@ -154,7 +154,7 @@ int32_t AudioRecordJni::StartRecording() {
int32_t AudioRecordJni::StopRecording() { int32_t AudioRecordJni::StopRecording() {
RTC_LOG(INFO) << "StopRecording"; RTC_LOG(INFO) << "StopRecording";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!initialized_ || !recording_) { if (!initialized_ || !recording_) {
return 0; return 0;
} }
@ -165,7 +165,7 @@ int32_t AudioRecordJni::StopRecording() {
// If we don't detach here, we will hit a RTC_DCHECK in OnDataIsRecorded() // If we don't detach here, we will hit a RTC_DCHECK in OnDataIsRecorded()
// next time StartRecording() is called since it will create a new Java // next time StartRecording() is called since it will create a new Java
// thread. // thread.
thread_checker_java_.DetachFromThread(); thread_checker_java_.Detach();
initialized_ = false; initialized_ = false;
recording_ = false; recording_ = false;
direct_buffer_address_ = nullptr; direct_buffer_address_ = nullptr;
@ -178,7 +178,7 @@ bool AudioRecordJni::Recording() const {
void AudioRecordJni::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) { void AudioRecordJni::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
RTC_LOG(INFO) << "AttachAudioBuffer"; RTC_LOG(INFO) << "AttachAudioBuffer";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
audio_device_buffer_ = audioBuffer; audio_device_buffer_ = audioBuffer;
const int sample_rate_hz = audio_parameters_.sample_rate(); const int sample_rate_hz = audio_parameters_.sample_rate();
RTC_LOG(INFO) << "SetRecordingSampleRate(" << sample_rate_hz << ")"; RTC_LOG(INFO) << "SetRecordingSampleRate(" << sample_rate_hz << ")";
@ -189,20 +189,20 @@ void AudioRecordJni::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
} }
bool AudioRecordJni::IsAcousticEchoCancelerSupported() const { bool AudioRecordJni::IsAcousticEchoCancelerSupported() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return Java_WebRtcAudioRecord_isAcousticEchoCancelerSupported( return Java_WebRtcAudioRecord_isAcousticEchoCancelerSupported(
env_, j_audio_record_); env_, j_audio_record_);
} }
bool AudioRecordJni::IsNoiseSuppressorSupported() const { bool AudioRecordJni::IsNoiseSuppressorSupported() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return Java_WebRtcAudioRecord_isNoiseSuppressorSupported(env_, return Java_WebRtcAudioRecord_isNoiseSuppressorSupported(env_,
j_audio_record_); j_audio_record_);
} }
int32_t AudioRecordJni::EnableBuiltInAEC(bool enable) { int32_t AudioRecordJni::EnableBuiltInAEC(bool enable) {
RTC_LOG(INFO) << "EnableBuiltInAEC(" << enable << ")"; RTC_LOG(INFO) << "EnableBuiltInAEC(" << enable << ")";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return Java_WebRtcAudioRecord_enableBuiltInAEC(env_, j_audio_record_, enable) return Java_WebRtcAudioRecord_enableBuiltInAEC(env_, j_audio_record_, enable)
? 0 ? 0
: -1; : -1;
@ -210,7 +210,7 @@ int32_t AudioRecordJni::EnableBuiltInAEC(bool enable) {
int32_t AudioRecordJni::EnableBuiltInNS(bool enable) { int32_t AudioRecordJni::EnableBuiltInNS(bool enable) {
RTC_LOG(INFO) << "EnableBuiltInNS(" << enable << ")"; RTC_LOG(INFO) << "EnableBuiltInNS(" << enable << ")";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return Java_WebRtcAudioRecord_enableBuiltInNS(env_, j_audio_record_, enable) return Java_WebRtcAudioRecord_enableBuiltInNS(env_, j_audio_record_, enable)
? 0 ? 0
: -1; : -1;
@ -221,7 +221,7 @@ void AudioRecordJni::CacheDirectBufferAddress(
const JavaParamRef<jobject>& j_caller, const JavaParamRef<jobject>& j_caller,
const JavaParamRef<jobject>& byte_buffer) { const JavaParamRef<jobject>& byte_buffer) {
RTC_LOG(INFO) << "OnCacheDirectBufferAddress"; RTC_LOG(INFO) << "OnCacheDirectBufferAddress";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!direct_buffer_address_); RTC_DCHECK(!direct_buffer_address_);
direct_buffer_address_ = env->GetDirectBufferAddress(byte_buffer.obj()); direct_buffer_address_ = env->GetDirectBufferAddress(byte_buffer.obj());
jlong capacity = env->GetDirectBufferCapacity(byte_buffer.obj()); jlong capacity = env->GetDirectBufferCapacity(byte_buffer.obj());
@ -234,7 +234,7 @@ void AudioRecordJni::CacheDirectBufferAddress(
void AudioRecordJni::DataIsRecorded(JNIEnv* env, void AudioRecordJni::DataIsRecorded(JNIEnv* env,
const JavaParamRef<jobject>& j_caller, const JavaParamRef<jobject>& j_caller,
int length) { int length) {
RTC_DCHECK(thread_checker_java_.CalledOnValidThread()); RTC_DCHECK(thread_checker_java_.IsCurrent());
if (!audio_device_buffer_) { if (!audio_device_buffer_) {
RTC_LOG(LS_ERROR) << "AttachAudioBuffer has not been called"; RTC_LOG(LS_ERROR) << "AttachAudioBuffer has not been called";
return; return;

View File

@ -48,34 +48,34 @@ AudioTrackJni::AudioTrackJni(JNIEnv* env,
jni::jlongFromPointer(this)); jni::jlongFromPointer(this));
// Detach from this thread since construction is allowed to happen on a // Detach from this thread since construction is allowed to happen on a
// different thread. // different thread.
thread_checker_.DetachFromThread(); thread_checker_.Detach();
thread_checker_java_.DetachFromThread(); thread_checker_java_.Detach();
} }
AudioTrackJni::~AudioTrackJni() { AudioTrackJni::~AudioTrackJni() {
RTC_LOG(INFO) << "dtor"; RTC_LOG(INFO) << "dtor";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
Terminate(); Terminate();
} }
int32_t AudioTrackJni::Init() { int32_t AudioTrackJni::Init() {
RTC_LOG(INFO) << "Init"; RTC_LOG(INFO) << "Init";
env_ = AttachCurrentThreadIfNeeded(); env_ = AttachCurrentThreadIfNeeded();
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return 0; return 0;
} }
int32_t AudioTrackJni::Terminate() { int32_t AudioTrackJni::Terminate() {
RTC_LOG(INFO) << "Terminate"; RTC_LOG(INFO) << "Terminate";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
StopPlayout(); StopPlayout();
thread_checker_.DetachFromThread(); thread_checker_.Detach();
return 0; return 0;
} }
int32_t AudioTrackJni::InitPlayout() { int32_t AudioTrackJni::InitPlayout() {
RTC_LOG(INFO) << "InitPlayout"; RTC_LOG(INFO) << "InitPlayout";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (initialized_) { if (initialized_) {
// Already initialized. // Already initialized.
return 0; return 0;
@ -97,7 +97,7 @@ bool AudioTrackJni::PlayoutIsInitialized() const {
int32_t AudioTrackJni::StartPlayout() { int32_t AudioTrackJni::StartPlayout() {
RTC_LOG(INFO) << "StartPlayout"; RTC_LOG(INFO) << "StartPlayout";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (playing_) { if (playing_) {
// Already playing. // Already playing.
return 0; return 0;
@ -117,7 +117,7 @@ int32_t AudioTrackJni::StartPlayout() {
int32_t AudioTrackJni::StopPlayout() { int32_t AudioTrackJni::StopPlayout() {
RTC_LOG(INFO) << "StopPlayout"; RTC_LOG(INFO) << "StopPlayout";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!initialized_ || !playing_) { if (!initialized_ || !playing_) {
return 0; return 0;
} }
@ -127,7 +127,7 @@ int32_t AudioTrackJni::StopPlayout() {
} }
// If we don't detach here, we will hit a RTC_DCHECK next time StartPlayout() // If we don't detach here, we will hit a RTC_DCHECK next time StartPlayout()
// is called since it will create a new Java thread. // is called since it will create a new Java thread.
thread_checker_java_.DetachFromThread(); thread_checker_java_.Detach();
initialized_ = false; initialized_ = false;
playing_ = false; playing_ = false;
direct_buffer_address_ = nullptr; direct_buffer_address_ = nullptr;
@ -144,7 +144,7 @@ bool AudioTrackJni::SpeakerVolumeIsAvailable() {
int AudioTrackJni::SetSpeakerVolume(uint32_t volume) { int AudioTrackJni::SetSpeakerVolume(uint32_t volume) {
RTC_LOG(INFO) << "SetSpeakerVolume(" << volume << ")"; RTC_LOG(INFO) << "SetSpeakerVolume(" << volume << ")";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return Java_WebRtcAudioTrack_setStreamVolume(env_, j_audio_track_, return Java_WebRtcAudioTrack_setStreamVolume(env_, j_audio_track_,
static_cast<int>(volume)) static_cast<int>(volume))
? 0 ? 0
@ -152,17 +152,17 @@ int AudioTrackJni::SetSpeakerVolume(uint32_t volume) {
} }
absl::optional<uint32_t> AudioTrackJni::MaxSpeakerVolume() const { absl::optional<uint32_t> AudioTrackJni::MaxSpeakerVolume() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return Java_WebRtcAudioTrack_getStreamMaxVolume(env_, j_audio_track_); return Java_WebRtcAudioTrack_getStreamMaxVolume(env_, j_audio_track_);
} }
absl::optional<uint32_t> AudioTrackJni::MinSpeakerVolume() const { absl::optional<uint32_t> AudioTrackJni::MinSpeakerVolume() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
return 0; return 0;
} }
absl::optional<uint32_t> AudioTrackJni::SpeakerVolume() const { absl::optional<uint32_t> AudioTrackJni::SpeakerVolume() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
const uint32_t volume = const uint32_t volume =
Java_WebRtcAudioTrack_getStreamVolume(env_, j_audio_track_); Java_WebRtcAudioTrack_getStreamVolume(env_, j_audio_track_);
RTC_LOG(INFO) << "SpeakerVolume: " << volume; RTC_LOG(INFO) << "SpeakerVolume: " << volume;
@ -172,7 +172,7 @@ absl::optional<uint32_t> AudioTrackJni::SpeakerVolume() const {
// TODO(henrika): possibly add stereo support. // TODO(henrika): possibly add stereo support.
void AudioTrackJni::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) { void AudioTrackJni::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
RTC_LOG(INFO) << "AttachAudioBuffer"; RTC_LOG(INFO) << "AttachAudioBuffer";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
audio_device_buffer_ = audioBuffer; audio_device_buffer_ = audioBuffer;
const int sample_rate_hz = audio_parameters_.sample_rate(); const int sample_rate_hz = audio_parameters_.sample_rate();
RTC_LOG(INFO) << "SetPlayoutSampleRate(" << sample_rate_hz << ")"; RTC_LOG(INFO) << "SetPlayoutSampleRate(" << sample_rate_hz << ")";
@ -187,7 +187,7 @@ void AudioTrackJni::CacheDirectBufferAddress(
const JavaParamRef<jobject>&, const JavaParamRef<jobject>&,
const JavaParamRef<jobject>& byte_buffer) { const JavaParamRef<jobject>& byte_buffer) {
RTC_LOG(INFO) << "OnCacheDirectBufferAddress"; RTC_LOG(INFO) << "OnCacheDirectBufferAddress";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!direct_buffer_address_); RTC_DCHECK(!direct_buffer_address_);
direct_buffer_address_ = env->GetDirectBufferAddress(byte_buffer.obj()); direct_buffer_address_ = env->GetDirectBufferAddress(byte_buffer.obj());
jlong capacity = env->GetDirectBufferCapacity(byte_buffer.obj()); jlong capacity = env->GetDirectBufferCapacity(byte_buffer.obj());
@ -203,7 +203,7 @@ void AudioTrackJni::CacheDirectBufferAddress(
void AudioTrackJni::GetPlayoutData(JNIEnv* env, void AudioTrackJni::GetPlayoutData(JNIEnv* env,
const JavaParamRef<jobject>&, const JavaParamRef<jobject>&,
size_t length) { size_t length) {
RTC_DCHECK(thread_checker_java_.CalledOnValidThread()); RTC_DCHECK(thread_checker_java_.IsCurrent());
const size_t bytes_per_frame = audio_parameters_.channels() * sizeof(int16_t); const size_t bytes_per_frame = audio_parameters_.channels() * sizeof(int16_t);
RTC_DCHECK_EQ(frames_per_buffer_, length / bytes_per_frame); RTC_DCHECK_EQ(frames_per_buffer_, length / bytes_per_frame);
if (!audio_device_buffer_) { if (!audio_device_buffer_) {

View File

@ -103,14 +103,14 @@ SLDataFormat_PCM CreatePCMConfiguration(size_t channels,
} }
OpenSLEngineManager::OpenSLEngineManager() { OpenSLEngineManager::OpenSLEngineManager() {
thread_checker_.DetachFromThread(); thread_checker_.Detach();
} }
OpenSLEngineManager::~OpenSLEngineManager() = default; OpenSLEngineManager::~OpenSLEngineManager() = default;
SLObjectItf OpenSLEngineManager::GetOpenSLEngine() { SLObjectItf OpenSLEngineManager::GetOpenSLEngine() {
RTC_LOG(INFO) << "GetOpenSLEngine"; RTC_LOG(INFO) << "GetOpenSLEngine";
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// OpenSL ES for Android only supports a single engine per application. // OpenSL ES for Android only supports a single engine per application.
// If one already has been created, return existing object instead of // If one already has been created, return existing object instead of
// creating a new. // creating a new.

View File

@ -64,12 +64,12 @@ OpenSLESPlayer::OpenSLESPlayer(
audio_parameters_.bits_per_sample()); audio_parameters_.bits_per_sample());
// Detach from this thread since we want to use the checker to verify calls // Detach from this thread since we want to use the checker to verify calls
// from the internal audio thread. // from the internal audio thread.
thread_checker_opensles_.DetachFromThread(); thread_checker_opensles_.Detach();
} }
OpenSLESPlayer::~OpenSLESPlayer() { OpenSLESPlayer::~OpenSLESPlayer() {
ALOGD("dtor[tid=%d]", rtc::CurrentThreadId()); ALOGD("dtor[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
Terminate(); Terminate();
DestroyAudioPlayer(); DestroyAudioPlayer();
DestroyMix(); DestroyMix();
@ -83,7 +83,7 @@ OpenSLESPlayer::~OpenSLESPlayer() {
int OpenSLESPlayer::Init() { int OpenSLESPlayer::Init() {
ALOGD("Init[tid=%d]", rtc::CurrentThreadId()); ALOGD("Init[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (audio_parameters_.channels() == 2) { if (audio_parameters_.channels() == 2) {
ALOGW("Stereo mode is enabled"); ALOGW("Stereo mode is enabled");
} }
@ -92,14 +92,14 @@ int OpenSLESPlayer::Init() {
int OpenSLESPlayer::Terminate() { int OpenSLESPlayer::Terminate() {
ALOGD("Terminate[tid=%d]", rtc::CurrentThreadId()); ALOGD("Terminate[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
StopPlayout(); StopPlayout();
return 0; return 0;
} }
int OpenSLESPlayer::InitPlayout() { int OpenSLESPlayer::InitPlayout() {
ALOGD("InitPlayout[tid=%d]", rtc::CurrentThreadId()); ALOGD("InitPlayout[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!initialized_); RTC_DCHECK(!initialized_);
RTC_DCHECK(!playing_); RTC_DCHECK(!playing_);
if (!ObtainEngineInterface()) { if (!ObtainEngineInterface()) {
@ -118,7 +118,7 @@ bool OpenSLESPlayer::PlayoutIsInitialized() const {
int OpenSLESPlayer::StartPlayout() { int OpenSLESPlayer::StartPlayout() {
ALOGD("StartPlayout[tid=%d]", rtc::CurrentThreadId()); ALOGD("StartPlayout[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(initialized_); RTC_DCHECK(initialized_);
RTC_DCHECK(!playing_); RTC_DCHECK(!playing_);
if (fine_audio_buffer_) { if (fine_audio_buffer_) {
@ -146,7 +146,7 @@ int OpenSLESPlayer::StartPlayout() {
int OpenSLESPlayer::StopPlayout() { int OpenSLESPlayer::StopPlayout() {
ALOGD("StopPlayout[tid=%d]", rtc::CurrentThreadId()); ALOGD("StopPlayout[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!initialized_ || !playing_) { if (!initialized_ || !playing_) {
return 0; return 0;
} }
@ -164,7 +164,7 @@ int OpenSLESPlayer::StopPlayout() {
// The number of lower latency audio players is limited, hence we create the // The number of lower latency audio players is limited, hence we create the
// audio player in Start() and destroy it in Stop(). // audio player in Start() and destroy it in Stop().
DestroyAudioPlayer(); DestroyAudioPlayer();
thread_checker_opensles_.DetachFromThread(); thread_checker_opensles_.Detach();
initialized_ = false; initialized_ = false;
playing_ = false; playing_ = false;
return 0; return 0;
@ -196,7 +196,7 @@ absl::optional<uint32_t> OpenSLESPlayer::MinSpeakerVolume() const {
void OpenSLESPlayer::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) { void OpenSLESPlayer::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
ALOGD("AttachAudioBuffer"); ALOGD("AttachAudioBuffer");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
audio_device_buffer_ = audioBuffer; audio_device_buffer_ = audioBuffer;
const int sample_rate_hz = audio_parameters_.sample_rate(); const int sample_rate_hz = audio_parameters_.sample_rate();
ALOGD("SetPlayoutSampleRate(%d)", sample_rate_hz); ALOGD("SetPlayoutSampleRate(%d)", sample_rate_hz);
@ -210,7 +210,7 @@ void OpenSLESPlayer::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
void OpenSLESPlayer::AllocateDataBuffers() { void OpenSLESPlayer::AllocateDataBuffers() {
ALOGD("AllocateDataBuffers"); ALOGD("AllocateDataBuffers");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!simple_buffer_queue_); RTC_DCHECK(!simple_buffer_queue_);
RTC_CHECK(audio_device_buffer_); RTC_CHECK(audio_device_buffer_);
// Create a modified audio buffer class which allows us to ask for any number // Create a modified audio buffer class which allows us to ask for any number
@ -235,7 +235,7 @@ void OpenSLESPlayer::AllocateDataBuffers() {
bool OpenSLESPlayer::ObtainEngineInterface() { bool OpenSLESPlayer::ObtainEngineInterface() {
ALOGD("ObtainEngineInterface"); ALOGD("ObtainEngineInterface");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (engine_) if (engine_)
return true; return true;
// Get access to (or create if not already existing) the global OpenSL Engine // Get access to (or create if not already existing) the global OpenSL Engine
@ -254,7 +254,7 @@ bool OpenSLESPlayer::ObtainEngineInterface() {
bool OpenSLESPlayer::CreateMix() { bool OpenSLESPlayer::CreateMix() {
ALOGD("CreateMix"); ALOGD("CreateMix");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(engine_); RTC_DCHECK(engine_);
if (output_mix_.Get()) if (output_mix_.Get())
return true; return true;
@ -270,7 +270,7 @@ bool OpenSLESPlayer::CreateMix() {
void OpenSLESPlayer::DestroyMix() { void OpenSLESPlayer::DestroyMix() {
ALOGD("DestroyMix"); ALOGD("DestroyMix");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!output_mix_.Get()) if (!output_mix_.Get())
return; return;
output_mix_.Reset(); output_mix_.Reset();
@ -278,7 +278,7 @@ void OpenSLESPlayer::DestroyMix() {
bool OpenSLESPlayer::CreateAudioPlayer() { bool OpenSLESPlayer::CreateAudioPlayer() {
ALOGD("CreateAudioPlayer"); ALOGD("CreateAudioPlayer");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(output_mix_.Get()); RTC_DCHECK(output_mix_.Get());
if (player_object_.Get()) if (player_object_.Get())
return true; return true;
@ -362,7 +362,7 @@ bool OpenSLESPlayer::CreateAudioPlayer() {
void OpenSLESPlayer::DestroyAudioPlayer() { void OpenSLESPlayer::DestroyAudioPlayer() {
ALOGD("DestroyAudioPlayer"); ALOGD("DestroyAudioPlayer");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!player_object_.Get()) if (!player_object_.Get())
return; return;
(*simple_buffer_queue_) (*simple_buffer_queue_)
@ -382,7 +382,7 @@ void OpenSLESPlayer::SimpleBufferQueueCallback(
} }
void OpenSLESPlayer::FillBufferQueue() { void OpenSLESPlayer::FillBufferQueue() {
RTC_DCHECK(thread_checker_opensles_.CalledOnValidThread()); RTC_DCHECK(thread_checker_opensles_.IsCurrent());
SLuint32 state = GetPlayState(); SLuint32 state = GetPlayState();
if (state != SL_PLAYSTATE_PLAYING) { if (state != SL_PLAYSTATE_PLAYING) {
ALOGW("Buffer callback in non-playing state!"); ALOGW("Buffer callback in non-playing state!");
@ -404,13 +404,13 @@ void OpenSLESPlayer::EnqueuePlayoutData(bool silence) {
SLint8* audio_ptr8 = SLint8* audio_ptr8 =
reinterpret_cast<SLint8*>(audio_buffers_[buffer_index_].get()); reinterpret_cast<SLint8*>(audio_buffers_[buffer_index_].get());
if (silence) { if (silence) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
// Avoid acquiring real audio data from WebRTC and fill the buffer with // Avoid acquiring real audio data from WebRTC and fill the buffer with
// zeros instead. Used to prime the buffer with silence and to avoid asking // zeros instead. Used to prime the buffer with silence and to avoid asking
// for audio data from two different threads. // for audio data from two different threads.
memset(audio_ptr8, 0, audio_parameters_.GetBytesPerBuffer()); memset(audio_ptr8, 0, audio_parameters_.GetBytesPerBuffer());
} else { } else {
RTC_DCHECK(thread_checker_opensles_.CalledOnValidThread()); RTC_DCHECK(thread_checker_opensles_.IsCurrent());
// Read audio data from the WebRTC source using the FineAudioBuffer object // Read audio data from the WebRTC source using the FineAudioBuffer object
// to adjust for differences in buffer size between WebRTC (10ms) and native // to adjust for differences in buffer size between WebRTC (10ms) and native
// OpenSL ES. Use hardcoded delay estimate since OpenSL ES does not support // OpenSL ES. Use hardcoded delay estimate since OpenSL ES does not support

View File

@ -59,7 +59,7 @@ OpenSLESRecorder::OpenSLESRecorder(
ALOGD("ctor[tid=%d]", rtc::CurrentThreadId()); ALOGD("ctor[tid=%d]", rtc::CurrentThreadId());
// Detach from this thread since we want to use the checker to verify calls // Detach from this thread since we want to use the checker to verify calls
// from the internal audio thread. // from the internal audio thread.
thread_checker_opensles_.DetachFromThread(); thread_checker_opensles_.Detach();
// Use native audio output parameters provided by the audio manager and // Use native audio output parameters provided by the audio manager and
// define the PCM format structure. // define the PCM format structure.
pcm_format_ = CreatePCMConfiguration(audio_parameters_.channels(), pcm_format_ = CreatePCMConfiguration(audio_parameters_.channels(),
@ -69,7 +69,7 @@ OpenSLESRecorder::OpenSLESRecorder(
OpenSLESRecorder::~OpenSLESRecorder() { OpenSLESRecorder::~OpenSLESRecorder() {
ALOGD("dtor[tid=%d]", rtc::CurrentThreadId()); ALOGD("dtor[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
Terminate(); Terminate();
DestroyAudioRecorder(); DestroyAudioRecorder();
engine_ = nullptr; engine_ = nullptr;
@ -80,7 +80,7 @@ OpenSLESRecorder::~OpenSLESRecorder() {
int OpenSLESRecorder::Init() { int OpenSLESRecorder::Init() {
ALOGD("Init[tid=%d]", rtc::CurrentThreadId()); ALOGD("Init[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (audio_parameters_.channels() == 2) { if (audio_parameters_.channels() == 2) {
ALOGD("Stereo mode is enabled"); ALOGD("Stereo mode is enabled");
} }
@ -89,14 +89,14 @@ int OpenSLESRecorder::Init() {
int OpenSLESRecorder::Terminate() { int OpenSLESRecorder::Terminate() {
ALOGD("Terminate[tid=%d]", rtc::CurrentThreadId()); ALOGD("Terminate[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
StopRecording(); StopRecording();
return 0; return 0;
} }
int OpenSLESRecorder::InitRecording() { int OpenSLESRecorder::InitRecording() {
ALOGD("InitRecording[tid=%d]", rtc::CurrentThreadId()); ALOGD("InitRecording[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!initialized_); RTC_DCHECK(!initialized_);
RTC_DCHECK(!recording_); RTC_DCHECK(!recording_);
if (!ObtainEngineInterface()) { if (!ObtainEngineInterface()) {
@ -115,7 +115,7 @@ bool OpenSLESRecorder::RecordingIsInitialized() const {
int OpenSLESRecorder::StartRecording() { int OpenSLESRecorder::StartRecording() {
ALOGD("StartRecording[tid=%d]", rtc::CurrentThreadId()); ALOGD("StartRecording[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(initialized_); RTC_DCHECK(initialized_);
RTC_DCHECK(!recording_); RTC_DCHECK(!recording_);
if (fine_audio_buffer_) { if (fine_audio_buffer_) {
@ -152,7 +152,7 @@ int OpenSLESRecorder::StartRecording() {
int OpenSLESRecorder::StopRecording() { int OpenSLESRecorder::StopRecording() {
ALOGD("StopRecording[tid=%d]", rtc::CurrentThreadId()); ALOGD("StopRecording[tid=%d]", rtc::CurrentThreadId());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!initialized_ || !recording_) { if (!initialized_ || !recording_) {
return 0; return 0;
} }
@ -165,7 +165,7 @@ int OpenSLESRecorder::StopRecording() {
if (LOG_ON_ERROR((*simple_buffer_queue_)->Clear(simple_buffer_queue_))) { if (LOG_ON_ERROR((*simple_buffer_queue_)->Clear(simple_buffer_queue_))) {
return -1; return -1;
} }
thread_checker_opensles_.DetachFromThread(); thread_checker_opensles_.Detach();
initialized_ = false; initialized_ = false;
recording_ = false; recording_ = false;
return 0; return 0;
@ -177,7 +177,7 @@ bool OpenSLESRecorder::Recording() const {
void OpenSLESRecorder::AttachAudioBuffer(AudioDeviceBuffer* audio_buffer) { void OpenSLESRecorder::AttachAudioBuffer(AudioDeviceBuffer* audio_buffer) {
ALOGD("AttachAudioBuffer"); ALOGD("AttachAudioBuffer");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_CHECK(audio_buffer); RTC_CHECK(audio_buffer);
audio_device_buffer_ = audio_buffer; audio_device_buffer_ = audio_buffer;
// Ensure that the audio device buffer is informed about the native sample // Ensure that the audio device buffer is informed about the native sample
@ -204,21 +204,21 @@ bool OpenSLESRecorder::IsNoiseSuppressorSupported() const {
int OpenSLESRecorder::EnableBuiltInAEC(bool enable) { int OpenSLESRecorder::EnableBuiltInAEC(bool enable) {
ALOGD("EnableBuiltInAEC(%d)", enable); ALOGD("EnableBuiltInAEC(%d)", enable);
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
ALOGE("Not implemented"); ALOGE("Not implemented");
return 0; return 0;
} }
int OpenSLESRecorder::EnableBuiltInNS(bool enable) { int OpenSLESRecorder::EnableBuiltInNS(bool enable) {
ALOGD("EnableBuiltInNS(%d)", enable); ALOGD("EnableBuiltInNS(%d)", enable);
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
ALOGE("Not implemented"); ALOGE("Not implemented");
return 0; return 0;
} }
bool OpenSLESRecorder::ObtainEngineInterface() { bool OpenSLESRecorder::ObtainEngineInterface() {
ALOGD("ObtainEngineInterface"); ALOGD("ObtainEngineInterface");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (engine_) if (engine_)
return true; return true;
// Get access to (or create if not already existing) the global OpenSL Engine // Get access to (or create if not already existing) the global OpenSL Engine
@ -239,7 +239,7 @@ bool OpenSLESRecorder::ObtainEngineInterface() {
bool OpenSLESRecorder::CreateAudioRecorder() { bool OpenSLESRecorder::CreateAudioRecorder() {
ALOGD("CreateAudioRecorder"); ALOGD("CreateAudioRecorder");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (recorder_object_.Get()) if (recorder_object_.Get())
return true; return true;
RTC_DCHECK(!recorder_); RTC_DCHECK(!recorder_);
@ -320,7 +320,7 @@ bool OpenSLESRecorder::CreateAudioRecorder() {
void OpenSLESRecorder::DestroyAudioRecorder() { void OpenSLESRecorder::DestroyAudioRecorder() {
ALOGD("DestroyAudioRecorder"); ALOGD("DestroyAudioRecorder");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
if (!recorder_object_.Get()) if (!recorder_object_.Get())
return; return;
(*simple_buffer_queue_) (*simple_buffer_queue_)
@ -339,7 +339,7 @@ void OpenSLESRecorder::SimpleBufferQueueCallback(
void OpenSLESRecorder::AllocateDataBuffers() { void OpenSLESRecorder::AllocateDataBuffers() {
ALOGD("AllocateDataBuffers"); ALOGD("AllocateDataBuffers");
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
RTC_DCHECK(!simple_buffer_queue_); RTC_DCHECK(!simple_buffer_queue_);
RTC_CHECK(audio_device_buffer_); RTC_CHECK(audio_device_buffer_);
// Create a modified audio buffer class which allows us to deliver any number // Create a modified audio buffer class which allows us to deliver any number
@ -364,7 +364,7 @@ void OpenSLESRecorder::AllocateDataBuffers() {
} }
void OpenSLESRecorder::ReadBufferQueue() { void OpenSLESRecorder::ReadBufferQueue() {
RTC_DCHECK(thread_checker_opensles_.CalledOnValidThread()); RTC_DCHECK(thread_checker_opensles_.IsCurrent());
SLuint32 state = GetRecordState(); SLuint32 state = GetRecordState();
if (state != SL_RECORDSTATE_RECORDING) { if (state != SL_RECORDSTATE_RECORDING) {
ALOGW("Buffer callback in non-recording state!"); ALOGW("Buffer callback in non-recording state!");

View File

@ -49,7 +49,7 @@ VideoDecoderWrapper::VideoDecoderWrapper(JNIEnv* jni,
// if the decoder provides frames. // if the decoder provides frames.
{ {
decoder_thread_checker_.DetachFromThread(); decoder_thread_checker_.Detach();
} }
VideoDecoderWrapper::~VideoDecoderWrapper() = default; VideoDecoderWrapper::~VideoDecoderWrapper() = default;
@ -141,7 +141,7 @@ int32_t VideoDecoderWrapper::Release() {
} }
initialized_ = false; initialized_ = false;
// It is allowed to reinitialize the codec on a different thread. // It is allowed to reinitialize the codec on a different thread.
decoder_thread_checker_.DetachFromThread(); decoder_thread_checker_.Detach();
return status; return status;
} }

View File

@ -115,15 +115,15 @@ AudioDeviceIOS::AudioDeviceIOS()
num_playout_callbacks_(0), num_playout_callbacks_(0),
last_output_volume_change_time_(0) { last_output_volume_change_time_(0) {
LOGI() << "ctor" << ios::GetCurrentThreadDescription(); LOGI() << "ctor" << ios::GetCurrentThreadDescription();
io_thread_checker_.DetachFromThread(); io_thread_checker_.Detach();
thread_checker_.DetachFromThread(); thread_checker_.Detach();
thread_ = rtc::Thread::Current(); thread_ = rtc::Thread::Current();
audio_session_observer_ = [[RTCNativeAudioSessionDelegateAdapter alloc] initWithObserver:this]; audio_session_observer_ = [[RTCNativeAudioSessionDelegateAdapter alloc] initWithObserver:this];
} }
AudioDeviceIOS::~AudioDeviceIOS() { AudioDeviceIOS::~AudioDeviceIOS() {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
LOGI() << "~dtor" << ios::GetCurrentThreadDescription(); LOGI() << "~dtor" << ios::GetCurrentThreadDescription();
Terminate(); Terminate();
audio_session_observer_ = nil; audio_session_observer_ = nil;
@ -132,14 +132,14 @@ AudioDeviceIOS::~AudioDeviceIOS() {
void AudioDeviceIOS::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) { void AudioDeviceIOS::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
LOGI() << "AttachAudioBuffer"; LOGI() << "AttachAudioBuffer";
RTC_DCHECK(audioBuffer); RTC_DCHECK(audioBuffer);
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
audio_device_buffer_ = audioBuffer; audio_device_buffer_ = audioBuffer;
} }
AudioDeviceGeneric::InitStatus AudioDeviceIOS::Init() { AudioDeviceGeneric::InitStatus AudioDeviceIOS::Init() {
LOGI() << "Init"; LOGI() << "Init";
io_thread_checker_.DetachFromThread(); io_thread_checker_.Detach();
thread_checker_.DetachFromThread(); thread_checker_.Detach();
RTC_DCHECK_RUN_ON(&thread_checker_); RTC_DCHECK_RUN_ON(&thread_checker_);
if (initialized_) { if (initialized_) {
@ -322,7 +322,7 @@ int32_t AudioDeviceIOS::PlayoutDelay(uint16_t& delayMS) const {
int AudioDeviceIOS::GetPlayoutAudioParameters(AudioParameters* params) const { int AudioDeviceIOS::GetPlayoutAudioParameters(AudioParameters* params) const {
LOGI() << "GetPlayoutAudioParameters"; LOGI() << "GetPlayoutAudioParameters";
RTC_DCHECK(playout_parameters_.is_valid()); RTC_DCHECK(playout_parameters_.is_valid());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
*params = playout_parameters_; *params = playout_parameters_;
return 0; return 0;
} }
@ -330,7 +330,7 @@ int AudioDeviceIOS::GetPlayoutAudioParameters(AudioParameters* params) const {
int AudioDeviceIOS::GetRecordAudioParameters(AudioParameters* params) const { int AudioDeviceIOS::GetRecordAudioParameters(AudioParameters* params) const {
LOGI() << "GetRecordAudioParameters"; LOGI() << "GetRecordAudioParameters";
RTC_DCHECK(record_parameters_.is_valid()); RTC_DCHECK(record_parameters_.is_valid());
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.IsCurrent());
*params = record_parameters_; *params = record_parameters_;
return 0; return 0;
} }
@ -911,7 +911,7 @@ void AudioDeviceIOS::ShutdownPlayOrRecord() {
// Detach thread checker for the AURemoteIO::IOThread to ensure that the // Detach thread checker for the AURemoteIO::IOThread to ensure that the
// next session uses a fresh thread id. // next session uses a fresh thread id.
io_thread_checker_.DetachFromThread(); io_thread_checker_.Detach();
// Remove audio session notification observers. // Remove audio session notification observers.
RTCAudioSession* session = [RTCAudioSession sharedInstance]; RTCAudioSession* session = [RTCAudioSession sharedInstance];
@ -928,7 +928,7 @@ void AudioDeviceIOS::PrepareForNewStart() {
// restart. It will result in audio callbacks from a new native I/O thread // restart. It will result in audio callbacks from a new native I/O thread
// which means that we must detach thread checkers here to be prepared for an // which means that we must detach thread checkers here to be prepared for an
// upcoming new audio stream. // upcoming new audio stream.
io_thread_checker_.DetachFromThread(); io_thread_checker_.Detach();
} }
bool AudioDeviceIOS::IsInterrupted() { bool AudioDeviceIOS::IsInterrupted() {

View File

@ -185,7 +185,7 @@ EmulatedEndpoint::EmulatedEndpoint(uint64_t id,
prefix_length, rtc::AdapterType::ADAPTER_TYPE_UNKNOWN); prefix_length, rtc::AdapterType::ADAPTER_TYPE_UNKNOWN);
network_->AddIP(ip); network_->AddIP(ip);
enabled_state_checker_.DetachFromThread(); enabled_state_checker_.Detach();
} }
EmulatedEndpoint::~EmulatedEndpoint() = default; EmulatedEndpoint::~EmulatedEndpoint() = default;

View File

@ -101,7 +101,7 @@ CallStats::CallStats(Clock* clock, ProcessThread* process_thread)
process_thread_(process_thread), process_thread_(process_thread),
process_thread_running_(false) { process_thread_running_(false) {
RTC_DCHECK(process_thread_); RTC_DCHECK(process_thread_);
process_thread_checker_.DetachFromThread(); process_thread_checker_.Detach();
} }
CallStats::~CallStats() { CallStats::~CallStats() {
@ -151,7 +151,7 @@ void CallStats::ProcessThreadAttached(ProcessThread* process_thread) {
// |process_thread_checker_| so that it can be used to protect variables // |process_thread_checker_| so that it can be used to protect variables
// in either the process thread when it starts again, or UpdateHistograms() // in either the process thread when it starts again, or UpdateHistograms()
// (mutually exclusive). // (mutually exclusive).
process_thread_checker_.DetachFromThread(); process_thread_checker_.Detach();
} }
void CallStats::RegisterStatsObserver(CallStatsObserver* observer) { void CallStats::RegisterStatsObserver(CallStatsObserver* observer) {

View File

@ -117,8 +117,8 @@ ReceiveStatisticsProxy::ReceiveStatisticsProxy(
num_delayed_frames_rendered_(0), num_delayed_frames_rendered_(0),
sum_missed_render_deadline_ms_(0), sum_missed_render_deadline_ms_(0),
timing_frame_info_counter_(kMovingMaxWindowMs) { timing_frame_info_counter_(kMovingMaxWindowMs) {
decode_thread_.DetachFromThread(); decode_thread_.Detach();
network_thread_.DetachFromThread(); network_thread_.Detach();
stats_.ssrc = config_.rtp.remote_ssrc; stats_.ssrc = config_.rtp.remote_ssrc;
// TODO(brandtr): Replace |rtx_stats_| with a single instance of // TODO(brandtr): Replace |rtx_stats_| with a single instance of
// StreamDataCounters. // StreamDataCounters.
@ -880,7 +880,7 @@ void ReceiveStatisticsProxy::DecoderThreadStarting() {
void ReceiveStatisticsProxy::DecoderThreadStopped() { void ReceiveStatisticsProxy::DecoderThreadStopped() {
RTC_DCHECK_RUN_ON(&main_thread_); RTC_DCHECK_RUN_ON(&main_thread_);
decode_thread_.DetachFromThread(); decode_thread_.Detach();
} }
ReceiveStatisticsProxy::ContentSpecificStats::ContentSpecificStats() ReceiveStatisticsProxy::ContentSpecificStats::ContentSpecificStats()

View File

@ -40,7 +40,7 @@ RtpStreamsSynchronizer::RtpStreamsSynchronizer(Syncable* syncable_video)
sync_(), sync_(),
last_sync_time_(rtc::TimeNanos()) { last_sync_time_(rtc::TimeNanos()) {
RTC_DCHECK(syncable_video); RTC_DCHECK(syncable_video);
process_thread_checker_.DetachFromThread(); process_thread_checker_.Detach();
} }
RtpStreamsSynchronizer::~RtpStreamsSynchronizer() = default; RtpStreamsSynchronizer::~RtpStreamsSynchronizer() = default;