Fixing audio timestamp stall during inactivation (under a kill switch)

TEST: tested on chromium.

Bug: webrtc:12397
Change-Id: I1e15605f90e253a6ef61ab7ead8c576a80e8f01b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/203886
Reviewed-by: Jakob Ivarsson <jakobi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Minyue Li <minyue@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33080}
This commit is contained in:
Minyue Li 2021-01-26 12:50:06 +01:00 committed by Commit Bot
parent 14b0e73bd8
commit 49dbad021e

View File

@ -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<uint32_t>(audio_frame->samples_per_channel_);
}
return;
}
// Measure time between when the audio frame is added to the task queue