From d8bbc7858622b6d9c278469aab701ca0b609cddf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:35:49 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- third_party/libwebrtc/audio/voip/audio_egress.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'third_party/libwebrtc/audio/voip/audio_egress.cc') 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 #include +#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 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 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; }); } -- cgit v1.2.3