NackRequester::ClearUpTo: avoid PostTasks.

Under the combined network/worker thread project, tasks
are unnecessarily posted to the same thread. Avoid this
by posting only if invoked on a diffferent sequence.

TESTED=presubmit + local Meet calls.

Bug: chromium:1373439
Change-Id: I2ca15b2c725f412ca8a0b8132d6b221f9f6b6032
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/295868
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39477}
This commit is contained in:
Markus Handell 2023-03-03 16:35:35 +01:00 committed by WebRTC LUCI CQ
parent 271c01b38f
commit 5145d90660

View File

@ -14,7 +14,6 @@
#include <limits>
#include "api/sequence_checker.h"
#include "api/task_queue/task_queue_base.h"
#include "api/units/timestamp.h"
#include "rtc_base/checks.h"
#include "rtc_base/experiments/field_trial_parser.h"
@ -219,15 +218,17 @@ int NackRequester::OnReceivedPacket(uint16_t seq_num,
}
void NackRequester::ClearUpTo(uint16_t seq_num) {
// Called via RtpVideoStreamReceiver2::FrameContinuous on the network thread.
worker_thread_->PostTask(SafeTask(task_safety_.flag(), [seq_num, this]() {
RTC_DCHECK_RUN_ON(worker_thread_);
nack_list_.erase(nack_list_.begin(), nack_list_.lower_bound(seq_num));
keyframe_list_.erase(keyframe_list_.begin(),
keyframe_list_.lower_bound(seq_num));
recovered_list_.erase(recovered_list_.begin(),
recovered_list_.lower_bound(seq_num));
}));
// TODO(bugs.webrtc.org/11993): This method is actually called on the worker
// thread even though the caller stack to this call passes thread checkers
// indicating they belong to the network thread. The inline execution below
// needs to be posted to the worker thread if callers migrate to the network
// thread.
RTC_DCHECK_RUN_ON(worker_thread_);
nack_list_.erase(nack_list_.begin(), nack_list_.lower_bound(seq_num));
keyframe_list_.erase(keyframe_list_.begin(),
keyframe_list_.lower_bound(seq_num));
recovered_list_.erase(recovered_list_.begin(),
recovered_list_.lower_bound(seq_num));
}
void NackRequester::UpdateRtt(int64_t rtt_ms) {