diff options
Diffstat (limited to 'third_party/libwebrtc/audio/voip')
-rw-r--r-- | third_party/libwebrtc/audio/voip/BUILD.gn | 1 | ||||
-rw-r--r-- | third_party/libwebrtc/audio/voip/audio_egress.cc | 18 | ||||
-rw-r--r-- | third_party/libwebrtc/audio/voip/audio_egress.h | 10 |
3 files changed, 17 insertions, 12 deletions
diff --git a/third_party/libwebrtc/audio/voip/BUILD.gn b/third_party/libwebrtc/audio/voip/BUILD.gn index e807e2276b..75f20a6ed2 100644 --- a/third_party/libwebrtc/audio/voip/BUILD.gn +++ b/third_party/libwebrtc/audio/voip/BUILD.gn @@ -94,7 +94,6 @@ rtc_library("audio_egress") { "../../modules/rtp_rtcp", "../../modules/rtp_rtcp:rtp_rtcp_format", "../../rtc_base:logging", - "../../rtc_base:rtc_task_queue", "../../rtc_base:timeutils", "../../rtc_base/synchronization:mutex", "../../rtc_base/system:no_unique_address", diff --git a/third_party/libwebrtc/audio/voip/audio_egress.cc b/third_party/libwebrtc/audio/voip/audio_egress.cc index 95a1a3351e..09396cd28d 100644 --- a/third_party/libwebrtc/audio/voip/audio_egress.cc +++ b/third_party/libwebrtc/audio/voip/audio_egress.cc @@ -13,6 +13,7 @@ #include <utility> #include <vector> +#include "api/sequence_checker.h" #include "rtc_base/logging.h" namespace webrtc { @@ -25,12 +26,17 @@ AudioEgress::AudioEgress(RtpRtcpInterface* rtp_rtcp, audio_coding_(AudioCodingModule::Create()), encoder_queue_(task_queue_factory->CreateTaskQueue( "AudioEncoder", - TaskQueueFactory::Priority::NORMAL)) { + TaskQueueFactory::Priority::NORMAL)), + encoder_queue_checker_(encoder_queue_.get()) { audio_coding_->RegisterTransportCallback(this); } AudioEgress::~AudioEgress() { audio_coding_->RegisterTransportCallback(nullptr); + + // Delete first to ensure that there are no running tasks when the other + // members are destroyed. + encoder_queue_ = nullptr; } bool AudioEgress::IsSending() const { @@ -73,9 +79,9 @@ void AudioEgress::SendAudioData(std::unique_ptr<AudioFrame> audio_frame) { RTC_DCHECK_GT(audio_frame->samples_per_channel_, 0); RTC_DCHECK_LE(audio_frame->num_channels_, 8); - encoder_queue_.PostTask( + encoder_queue_->PostTask( [this, audio_frame = std::move(audio_frame)]() mutable { - RTC_DCHECK_RUN_ON(&encoder_queue_); + RTC_DCHECK_RUN_ON(&encoder_queue_checker_); if (!rtp_rtcp_->SendingMedia()) { return; } @@ -112,7 +118,7 @@ int32_t AudioEgress::SendData(AudioFrameType frame_type, uint32_t timestamp, const uint8_t* payload_data, size_t payload_size) { - RTC_DCHECK_RUN_ON(&encoder_queue_); + RTC_DCHECK_RUN_ON(&encoder_queue_checker_); rtc::ArrayView<const uint8_t> payload(payload_data, payload_size); @@ -175,8 +181,8 @@ bool AudioEgress::SendTelephoneEvent(int dtmf_event, int duration_ms) { } void AudioEgress::SetMute(bool mute) { - encoder_queue_.PostTask([this, mute] { - RTC_DCHECK_RUN_ON(&encoder_queue_); + encoder_queue_->PostTask([this, mute] { + RTC_DCHECK_RUN_ON(&encoder_queue_checker_); encoder_context_.mute_ = mute; }); } diff --git a/third_party/libwebrtc/audio/voip/audio_egress.h b/third_party/libwebrtc/audio/voip/audio_egress.h index 989e5bda59..6d1489db34 100644 --- a/third_party/libwebrtc/audio/voip/audio_egress.h +++ b/third_party/libwebrtc/audio/voip/audio_egress.h @@ -16,6 +16,7 @@ #include "api/audio_codecs/audio_format.h" #include "api/sequence_checker.h" +#include "api/task_queue/task_queue_base.h" #include "api/task_queue/task_queue_factory.h" #include "audio/audio_level.h" #include "audio/utility/audio_frame_operations.h" @@ -25,7 +26,7 @@ #include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" #include "modules/rtp_rtcp/source/rtp_sender_audio.h" #include "rtc_base/synchronization/mutex.h" -#include "rtc_base/task_queue.h" +#include "rtc_base/system/no_unique_address.h" #include "rtc_base/time_utils.h" namespace webrtc { @@ -146,11 +147,10 @@ class AudioEgress : public AudioSender, public AudioPacketizationCallback { bool previously_muted_ = false; }; - EncoderContext encoder_context_ RTC_GUARDED_BY(encoder_queue_); + EncoderContext encoder_context_ RTC_GUARDED_BY(encoder_queue_checker_); - // Defined last to ensure that there are no running tasks when the other - // members are destroyed. - rtc::TaskQueue encoder_queue_; + std::unique_ptr<TaskQueueBase, TaskQueueDeleter> encoder_queue_; + RTC_NO_UNIQUE_ADDRESS SequenceChecker encoder_queue_checker_; }; } // namespace webrtc |