From a63d8d0b4b20f558e807a460cef935747a905c65 Mon Sep 17 00:00:00 2001 From: Minyue Li Date: Tue, 26 Jan 2021 12:50:06 +0100 Subject: [PATCH] Fixing audio timestamp stall during inactivation (under a kill switch) TEST: tested on chromium. (cherry picked from commit 49dbad021e802197b3c0b966c03b4aa766a5b578) No-Try: True Bug: webrtc:12397, chromium:1171206 Change-Id: I1e15605f90e253a6ef61ab7ead8c576a80e8f01b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/203886 Reviewed-by: Jakob Ivarsson Reviewed-by: Harald Alvestrand Reviewed-by: Sam Zackrisson Commit-Queue: Minyue Li Cr-Original-Commit-Position: refs/heads/master@{#33080} Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/204302 Reviewed-by: Mirko Bonadei Reviewed-by: Minyue Li Cr-Commit-Position: refs/branch-heads/4389@{#4} Cr-Branched-From: 7acc2d9fe3a6e3c4d8881d2bdfc9b8968a724cd5-refs/heads/master@{#32986} --- audio/channel_send.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/audio/channel_send.cc b/audio/channel_send.cc index 80e7ab2f478..d331f0129b0 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc @@ -241,6 +241,8 @@ class ChannelSend : public ChannelSendInterface, // Defined last to ensure that there are no running tasks when the other // members are destroyed. rtc::TaskQueue encoder_queue_; + + const bool fixing_timestamp_stall_; }; const int kTelephoneEventAttenuationdB = 10; @@ -471,7 +473,9 @@ ChannelSend::ChannelSend( crypto_options_(crypto_options), encoder_queue_(task_queue_factory->CreateTaskQueue( "AudioEncoder", - TaskQueueFactory::Priority::NORMAL)) { + TaskQueueFactory::Priority::NORMAL)), + fixing_timestamp_stall_( + !field_trial::IsDisabled("WebRTC-Audio-FixTimestampStall")) { RTC_DCHECK(module_process_thread); module_process_thread_checker_.Detach(); @@ -808,6 +812,10 @@ void ChannelSend::ProcessAndEncodeAudio( [this, audio_frame = std::move(audio_frame)]() mutable { RTC_DCHECK_RUN_ON(&encoder_queue_); if (!encoder_queue_is_active_) { + if (fixing_timestamp_stall_) { + _timeStamp += + static_cast(audio_frame->samples_per_channel_); + } return; } // Measure time between when the audio frame is added to the task queue