Index: webrtc/voice_engine/channel_proxy.cc |
diff --git a/webrtc/voice_engine/channel_proxy.cc b/webrtc/voice_engine/channel_proxy.cc |
index a58b2e19557790c9248ae0133a714fa4d50729ae..4e690fb62f071d6483feb0d90d4de9d52a62964a 100644 |
--- a/webrtc/voice_engine/channel_proxy.cc |
+++ b/webrtc/voice_engine/channel_proxy.cc |
@@ -23,22 +23,24 @@ ChannelProxy::ChannelProxy() : channel_owner_(nullptr) {} |
ChannelProxy::ChannelProxy(const ChannelOwner& channel_owner) : |
channel_owner_(channel_owner) { |
RTC_CHECK(channel_owner_.channel()); |
+ module_process_thread_checker_.DetachFromThread(); |
} |
ChannelProxy::~ChannelProxy() {} |
void ChannelProxy::SetRTCPStatus(bool enable) { |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
channel()->SetRTCPStatus(enable); |
} |
void ChannelProxy::SetLocalSSRC(uint32_t ssrc) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
int error = channel()->SetLocalSSRC(ssrc); |
RTC_DCHECK_EQ(0, error); |
} |
void ChannelProxy::SetRTCP_CNAME(const std::string& c_name) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
// Note: VoERTP_RTCP::SetRTCP_CNAME() accepts a char[256] array. |
std::string c_name_limited = c_name.substr(0, 255); |
int error = channel()->SetRTCP_CNAME(c_name_limited.c_str()); |
@@ -46,29 +48,29 @@ void ChannelProxy::SetRTCP_CNAME(const std::string& c_name) { |
} |
void ChannelProxy::SetNACKStatus(bool enable, int max_packets) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
channel()->SetNACKStatus(enable, max_packets); |
} |
void ChannelProxy::SetSendAudioLevelIndicationStatus(bool enable, int id) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
int error = channel()->SetSendAudioLevelIndicationStatus(enable, id); |
RTC_DCHECK_EQ(0, error); |
} |
void ChannelProxy::SetReceiveAudioLevelIndicationStatus(bool enable, int id) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
int error = channel()->SetReceiveAudioLevelIndicationStatus(enable, id); |
RTC_DCHECK_EQ(0, error); |
} |
void ChannelProxy::EnableSendTransportSequenceNumber(int id) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
channel()->EnableSendTransportSequenceNumber(id); |
} |
void ChannelProxy::EnableReceiveTransportSequenceNumber(int id) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
channel()->EnableReceiveTransportSequenceNumber(id); |
} |
@@ -77,7 +79,7 @@ void ChannelProxy::RegisterSenderCongestionControlObjects( |
TransportFeedbackObserver* transport_feedback_observer, |
PacketRouter* packet_router, |
RtcpBandwidthObserver* bandwidth_observer) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
channel()->RegisterSenderCongestionControlObjects( |
rtp_packet_sender, transport_feedback_observer, packet_router, |
bandwidth_observer); |
@@ -85,17 +87,17 @@ void ChannelProxy::RegisterSenderCongestionControlObjects( |
void ChannelProxy::RegisterReceiverCongestionControlObjects( |
PacketRouter* packet_router) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
channel()->RegisterReceiverCongestionControlObjects(packet_router); |
} |
void ChannelProxy::ResetCongestionControlObjects() { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
channel()->ResetCongestionControlObjects(); |
} |
CallStatistics ChannelProxy::GetRTCPStatistics() const { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
CallStatistics stats = {0}; |
int error = channel()->GetRTPStatistics(stats); |
RTC_DCHECK_EQ(0, error); |
@@ -103,7 +105,7 @@ CallStatistics ChannelProxy::GetRTCPStatistics() const { |
} |
std::vector<ReportBlock> ChannelProxy::GetRemoteRTCPReportBlocks() const { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
std::vector<webrtc::ReportBlock> blocks; |
int error = channel()->GetRemoteRTCPReportBlocks(&blocks); |
RTC_DCHECK_EQ(0, error); |
@@ -111,7 +113,7 @@ std::vector<ReportBlock> ChannelProxy::GetRemoteRTCPReportBlocks() const { |
} |
NetworkStatistics ChannelProxy::GetNetworkStatistics() const { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
NetworkStatistics stats = {0}; |
int error = channel()->GetNetworkStatistics(stats); |
RTC_DCHECK_EQ(0, error); |
@@ -119,14 +121,14 @@ NetworkStatistics ChannelProxy::GetNetworkStatistics() const { |
} |
AudioDecodingCallStats ChannelProxy::GetDecodingCallStatistics() const { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
AudioDecodingCallStats stats; |
channel()->GetDecodingCallStatistics(&stats); |
return stats; |
} |
int32_t ChannelProxy::GetSpeechOutputLevelFullRange() const { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
uint32_t level = 0; |
int error = channel()->GetSpeechOutputLevelFullRange(level); |
RTC_DCHECK_EQ(0, error); |
@@ -134,53 +136,55 @@ int32_t ChannelProxy::GetSpeechOutputLevelFullRange() const { |
} |
uint32_t ChannelProxy::GetDelayEstimate() const { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() || |
+ module_process_thread_checker_.CalledOnValidThread()); |
return channel()->GetDelayEstimate(); |
} |
bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type, |
int payload_frequency) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
return channel()->SetSendTelephoneEventPayloadType(payload_type, |
payload_frequency) == 0; |
} |
bool ChannelProxy::SendTelephoneEventOutband(int event, int duration_ms) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
return channel()->SendTelephoneEventOutband(event, duration_ms) == 0; |
} |
void ChannelProxy::SetBitrate(int bitrate_bps, int64_t probing_interval_ms) { |
- // May be called on different threads and needs to be handled by the channel. |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() || |
+ module_process_thread_checker_.CalledOnValidThread()); |
channel()->SetBitRate(bitrate_bps, probing_interval_ms); |
} |
void ChannelProxy::SetRecPayloadType(int payload_type, |
const SdpAudioFormat& format) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
const int result = channel()->SetRecPayloadType(payload_type, format); |
RTC_DCHECK_EQ(0, result); |
} |
void ChannelProxy::SetSink(std::unique_ptr<AudioSinkInterface> sink) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
channel()->SetSink(std::move(sink)); |
} |
void ChannelProxy::SetInputMute(bool muted) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
int error = channel()->SetInputMute(muted); |
RTC_DCHECK_EQ(0, error); |
} |
void ChannelProxy::RegisterExternalTransport(Transport* transport) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
int error = channel()->RegisterExternalTransport(transport); |
RTC_DCHECK_EQ(0, error); |
} |
void ChannelProxy::DeRegisterExternalTransport() { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
channel()->DeRegisterExternalTransport(); |
} |
@@ -198,35 +202,35 @@ bool ChannelProxy::ReceivedRTCPPacket(const uint8_t* packet, size_t length) { |
const rtc::scoped_refptr<AudioDecoderFactory>& |
ChannelProxy::GetAudioDecoderFactory() const { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
return channel()->GetAudioDecoderFactory(); |
} |
void ChannelProxy::SetChannelOutputVolumeScaling(float scaling) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
int error = channel()->SetChannelOutputVolumeScaling(scaling); |
RTC_DCHECK_EQ(0, error); |
} |
void ChannelProxy::SetRtcEventLog(RtcEventLog* event_log) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
channel()->SetRtcEventLog(event_log); |
} |
void ChannelProxy::EnableAudioNetworkAdaptor(const std::string& config_string) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
bool ret = channel()->EnableAudioNetworkAdaptor(config_string); |
RTC_DCHECK(ret); |
;} |
void ChannelProxy::DisableAudioNetworkAdaptor() { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
channel()->DisableAudioNetworkAdaptor(); |
} |
void ChannelProxy::SetReceiverFrameLengthRange(int min_frame_length_ms, |
int max_frame_length_ms) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
channel()->SetReceiverFrameLengthRange(min_frame_length_ms, |
max_frame_length_ms); |
} |
@@ -234,51 +238,42 @@ void ChannelProxy::SetReceiverFrameLengthRange(int min_frame_length_ms, |
AudioMixer::Source::AudioFrameInfo ChannelProxy::GetAudioFrameWithInfo( |
int sample_rate_hz, |
AudioFrame* audio_frame) { |
- RTC_DCHECK_RUNS_SERIALIZED(&race_checker_); |
+ RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_); |
return channel()->GetAudioFrameWithInfo(sample_rate_hz, audio_frame); |
} |
int ChannelProxy::NeededFrequency() const { |
+ RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_); |
return static_cast<int>(channel()->NeededFrequency(-1)); |
} |
void ChannelProxy::SetTransportOverhead(int transport_overhead_per_packet) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
channel()->SetTransportOverhead(transport_overhead_per_packet); |
} |
void ChannelProxy::AssociateSendChannel( |
const ChannelProxy& send_channel_proxy) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
channel()->set_associate_send_channel(send_channel_proxy.channel_owner_); |
} |
void ChannelProxy::DisassociateSendChannel() { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
channel()->set_associate_send_channel(ChannelOwner(nullptr)); |
} |
void ChannelProxy::GetRtpRtcp(RtpRtcp** rtp_rtcp, |
RtpReceiver** rtp_receiver) const { |
- // Called on Call's module_process_thread_. |
+ RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread()); |
RTC_DCHECK(rtp_rtcp); |
RTC_DCHECK(rtp_receiver); |
int error = channel()->GetRtpRtcp(rtp_rtcp, rtp_receiver); |
RTC_DCHECK_EQ(0, error); |
} |
-void ChannelProxy::GetDelayEstimate(int* jitter_buffer_delay_ms, |
- int* playout_buffer_delay_ms) const { |
- // Called on Call's module_process_thread_. |
- RTC_DCHECK(jitter_buffer_delay_ms); |
- RTC_DCHECK(playout_buffer_delay_ms); |
- bool error = channel()->GetDelayEstimate(jitter_buffer_delay_ms, |
- playout_buffer_delay_ms); |
- RTC_DCHECK(error); |
-} |
- |
uint32_t ChannelProxy::GetPlayoutTimestamp() const { |
- // Called on video capture thread. |
+ RTC_DCHECK_RUNS_SERIALIZED(&video_capture_thread_race_checker_); |
unsigned int timestamp = 0; |
int error = channel()->GetPlayoutTimestamp(timestamp); |
RTC_DCHECK(!error || timestamp == 0); |
@@ -286,7 +281,7 @@ uint32_t ChannelProxy::GetPlayoutTimestamp() const { |
} |
void ChannelProxy::SetMinimumPlayoutDelay(int delay_ms) { |
- // Called on Call's module_process_thread_. |
+ RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread()); |
// Limit to range accepted by both VoE and ACM, so we're at least getting as |
// close as possible, instead of failing. |
delay_ms = std::max(0, std::min(delay_ms, 10000)); |
@@ -295,42 +290,42 @@ void ChannelProxy::SetMinimumPlayoutDelay(int delay_ms) { |
} |
void ChannelProxy::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
channel()->SetRtcpRttStats(rtcp_rtt_stats); |
} |
bool ChannelProxy::GetRecCodec(CodecInst* codec_inst) const { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
return channel()->GetRecCodec(*codec_inst) == 0; |
} |
bool ChannelProxy::GetSendCodec(CodecInst* codec_inst) const { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
return channel()->GetSendCodec(*codec_inst) == 0; |
} |
bool ChannelProxy::SetVADStatus(bool enable) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
return channel()->SetVADStatus(enable, VADNormal, false) == 0; |
} |
bool ChannelProxy::SetCodecFECStatus(bool enable) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
return channel()->SetCodecFECStatus(enable) == 0; |
} |
bool ChannelProxy::SetOpusDtx(bool enable) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
return channel()->SetOpusDtx(enable) == 0; |
} |
bool ChannelProxy::SetOpusMaxPlaybackRate(int frequency_hz) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
return channel()->SetOpusMaxPlaybackRate(frequency_hz) == 0; |
} |
bool ChannelProxy::SetSendCodec(const CodecInst& codec_inst) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
// Validation code copied from VoECodecImpl::SetSendCodec(). |
if ((STR_CASE_CMP(codec_inst.plname, "L16") == 0) && |
(codec_inst.pacsize >= 960)) { |
@@ -352,7 +347,7 @@ bool ChannelProxy::SetSendCodec(const CodecInst& codec_inst) { |
bool ChannelProxy::SetSendCNPayloadType(int type, |
PayloadFrequencies frequency) { |
- RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
// Validation code copied from VoECodecImpl::SetSendCNPayloadType(). |
if (type < 96 || type > 127) { |
// Only allow dynamic range: 96 to 127 |