mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-17 15:47:53 +01:00
Revert "TaskQueue: unexpose delayed task convenience methods."
This reverts commit 08bb6295ea
.
Reason for revert: Breaks downstream tests
Original change's description:
> TaskQueue: unexpose delayed task convenience methods.
>
> Bug: webrtc:14165
> Change-Id: Ieb8580670e9e521580afd68cca6ff631fb6df3f8
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/265400
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Auto-Submit: Markus Handell <handellm@webrtc.org>
> Commit-Queue: Harald Alvestrand <hta@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#37166}
Bug: webrtc:14165
Change-Id: Ia7368cf205622be448ec0ead5d22f211aa071a29
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/265411
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: Björn Terelius <terelius@webrtc.org>
Auto-Submit: Björn Terelius <terelius@webrtc.org>
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37167}
This commit is contained in:
parent
08bb6295ea
commit
4cd3a0d082
11 changed files with 50 additions and 29 deletions
|
@ -57,8 +57,8 @@ void IncomingVideoStream::Dequeue() {
|
||||||
|
|
||||||
if (render_buffers_.HasPendingFrames()) {
|
if (render_buffers_.HasPendingFrames()) {
|
||||||
uint32_t wait_time = render_buffers_.TimeToNextFrameRelease();
|
uint32_t wait_time = render_buffers_.TimeToNextFrameRelease();
|
||||||
incoming_render_queue_.PostDelayedHighPrecisionTask(
|
incoming_render_queue_.PostDelayedHighPrecisionTask([this]() { Dequeue(); },
|
||||||
ToQueuedTask([this]() { Dequeue(); }), wait_time);
|
wait_time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,7 @@ void RtcEventLogImpl::ScheduleOutput() {
|
||||||
const int64_t time_since_output_ms = now_ms - last_output_ms_;
|
const int64_t time_since_output_ms = now_ms - last_output_ms_;
|
||||||
const uint32_t delay = rtc::SafeClamp(
|
const uint32_t delay = rtc::SafeClamp(
|
||||||
*output_period_ms_ - time_since_output_ms, 0, *output_period_ms_);
|
*output_period_ms_ - time_since_output_ms, 0, *output_period_ms_);
|
||||||
task_queue_->PostDelayedTask(ToQueuedTask(std::move(output_task)), delay);
|
task_queue_->PostDelayedTask(output_task, delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -477,9 +477,7 @@ void AudioDeviceBuffer::LogStats(LogState state) {
|
||||||
|
|
||||||
// Keep posting new (delayed) tasks until state is changed to kLogStop.
|
// Keep posting new (delayed) tasks until state is changed to kLogStop.
|
||||||
task_queue_.PostDelayedTask(
|
task_queue_.PostDelayedTask(
|
||||||
ToQueuedTask([this] {
|
[this] { AudioDeviceBuffer::LogStats(AudioDeviceBuffer::LOG_ACTIVE); },
|
||||||
AudioDeviceBuffer::LogStats(AudioDeviceBuffer::LOG_ACTIVE);
|
|
||||||
}),
|
|
||||||
time_to_wait_ms);
|
time_to_wait_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -317,9 +317,8 @@ void TaskQueuePacedSender::MaybeProcessPackets(
|
||||||
}
|
}
|
||||||
|
|
||||||
task_queue_.PostDelayedTaskWithPrecision(
|
task_queue_.PostDelayedTaskWithPrecision(
|
||||||
precision, ToQueuedTask([this, next_send_time]() {
|
precision,
|
||||||
MaybeProcessPackets(next_send_time);
|
[this, next_send_time]() { MaybeProcessPackets(next_send_time); },
|
||||||
}),
|
|
||||||
time_to_next_process.RoundUpTo(TimeDelta::Millis(1)).ms<uint32_t>());
|
time_to_next_process.RoundUpTo(TimeDelta::Millis(1)).ms<uint32_t>());
|
||||||
next_process_time_ = next_send_time;
|
next_process_time_ = next_send_time;
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,6 +115,34 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueue {
|
||||||
void PostTask(Closure&& closure) {
|
void PostTask(Closure&& closure) {
|
||||||
PostTask(webrtc::ToQueuedTask(std::forward<Closure>(closure)));
|
PostTask(webrtc::ToQueuedTask(std::forward<Closure>(closure)));
|
||||||
}
|
}
|
||||||
|
template <class Closure,
|
||||||
|
typename std::enable_if<!std::is_convertible<
|
||||||
|
Closure,
|
||||||
|
std::unique_ptr<webrtc::QueuedTask>>::value>::type* = nullptr>
|
||||||
|
void PostDelayedTask(Closure&& closure, uint32_t milliseconds) {
|
||||||
|
PostDelayedTask(webrtc::ToQueuedTask(std::forward<Closure>(closure)),
|
||||||
|
milliseconds);
|
||||||
|
}
|
||||||
|
template <class Closure,
|
||||||
|
typename std::enable_if<!std::is_convertible<
|
||||||
|
Closure,
|
||||||
|
std::unique_ptr<webrtc::QueuedTask>>::value>::type* = nullptr>
|
||||||
|
void PostDelayedHighPrecisionTask(Closure&& closure, uint32_t milliseconds) {
|
||||||
|
PostDelayedHighPrecisionTask(
|
||||||
|
webrtc::ToQueuedTask(std::forward<Closure>(closure)), milliseconds);
|
||||||
|
}
|
||||||
|
template <class Closure,
|
||||||
|
typename std::enable_if<!std::is_convertible<
|
||||||
|
Closure,
|
||||||
|
std::unique_ptr<webrtc::QueuedTask>>::value>::type* = nullptr>
|
||||||
|
void PostDelayedTaskWithPrecision(
|
||||||
|
webrtc::TaskQueueBase::DelayPrecision precision,
|
||||||
|
Closure&& closure,
|
||||||
|
uint32_t milliseconds) {
|
||||||
|
PostDelayedTaskWithPrecision(
|
||||||
|
precision, webrtc::ToQueuedTask(std::forward<Closure>(closure)),
|
||||||
|
milliseconds);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
webrtc::TaskQueueBase* const impl_;
|
webrtc::TaskQueueBase* const impl_;
|
||||||
|
|
|
@ -66,9 +66,7 @@ TEST(TaskQueueTest, DISABLED_PostDelayedHighRes) {
|
||||||
webrtc::TaskQueueForTest queue(kQueueName, TaskQueue::Priority::HIGH);
|
webrtc::TaskQueueForTest queue(kQueueName, TaskQueue::Priority::HIGH);
|
||||||
|
|
||||||
uint32_t start = Time();
|
uint32_t start = Time();
|
||||||
queue.PostDelayedTask(
|
queue.PostDelayedTask([&event, &queue] { CheckCurrent(&event, &queue); }, 3);
|
||||||
webrtc::ToQueuedTask([&event, &queue] { CheckCurrent(&event, &queue); }),
|
|
||||||
3);
|
|
||||||
EXPECT_TRUE(event.Wait(1000));
|
EXPECT_TRUE(event.Wait(1000));
|
||||||
uint32_t end = TimeMillis();
|
uint32_t end = TimeMillis();
|
||||||
// These tests are a little relaxed due to how "powerful" our test bots can
|
// These tests are a little relaxed due to how "powerful" our test bots can
|
||||||
|
|
|
@ -61,11 +61,12 @@ int32_t FakeDecoder::Decode(const EncodedImage& input,
|
||||||
if (decode_delay_ms_ == 0 || !task_queue_) {
|
if (decode_delay_ms_ == 0 || !task_queue_) {
|
||||||
callback_->Decoded(frame);
|
callback_->Decoded(frame);
|
||||||
} else {
|
} else {
|
||||||
task_queue_->PostDelayedHighPrecisionTask(ToQueuedTask([frame, this]() {
|
task_queue_->PostDelayedHighPrecisionTask(
|
||||||
VideoFrame copy = frame;
|
[frame, this]() {
|
||||||
callback_->Decoded(copy);
|
VideoFrame copy = frame;
|
||||||
}),
|
callback_->Decoded(copy);
|
||||||
decode_delay_ms_);
|
},
|
||||||
|
decode_delay_ms_);
|
||||||
}
|
}
|
||||||
|
|
||||||
return WEBRTC_VIDEO_CODEC_OK;
|
return WEBRTC_VIDEO_CODEC_OK;
|
||||||
|
|
|
@ -103,10 +103,9 @@ void TestActivitiesExecutor::PostActivity(ScheduledActivity activity) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
task_queue_->PostDelayedTask(ToQueuedTask([activity, start_time, this]() {
|
task_queue_->PostDelayedTask(
|
||||||
activity.func(Now() - start_time);
|
[activity, start_time, this]() { activity.func(Now() - start_time); },
|
||||||
}),
|
remaining_delay.ms());
|
||||||
remaining_delay.ms());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Timestamp TestActivitiesExecutor::Now() const {
|
Timestamp TestActivitiesExecutor::Now() const {
|
||||||
|
|
|
@ -266,8 +266,7 @@ void Scenario::Post(std::function<void()> function) {
|
||||||
|
|
||||||
void Scenario::At(TimeDelta offset, std::function<void()> function) {
|
void Scenario::At(TimeDelta offset, std::function<void()> function) {
|
||||||
RTC_DCHECK_GT(offset, TimeSinceStart());
|
RTC_DCHECK_GT(offset, TimeSinceStart());
|
||||||
task_queue_.PostDelayedTask(ToQueuedTask(std::move(function)),
|
task_queue_.PostDelayedTask(function, TimeUntilTarget(offset).ms());
|
||||||
TimeUntilTarget(offset).ms());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scenario::RunFor(TimeDelta duration) {
|
void Scenario::RunFor(TimeDelta duration) {
|
||||||
|
|
|
@ -120,8 +120,7 @@ TEST(SimulatedTimeControllerTest, DelayTaskRunOnTime) {
|
||||||
"TestQueue", TaskQueueFactory::Priority::NORMAL));
|
"TestQueue", TaskQueueFactory::Priority::NORMAL));
|
||||||
|
|
||||||
bool delay_task_executed = false;
|
bool delay_task_executed = false;
|
||||||
task_queue.PostDelayedTask(ToQueuedTask([&] { delay_task_executed = true; }),
|
task_queue.PostDelayedTask([&] { delay_task_executed = true; }, 10);
|
||||||
10);
|
|
||||||
|
|
||||||
time_simulation.AdvanceTime(TimeDelta::Millis(10));
|
time_simulation.AdvanceTime(TimeDelta::Millis(10));
|
||||||
EXPECT_TRUE(delay_task_executed);
|
EXPECT_TRUE(delay_task_executed);
|
||||||
|
|
|
@ -867,13 +867,13 @@ TEST_F(VideoSendStreamImplTest, DisablesPaddingOnPausedEncoder) {
|
||||||
|
|
||||||
rtc::Event done;
|
rtc::Event done;
|
||||||
test_queue_.PostDelayedTask(
|
test_queue_.PostDelayedTask(
|
||||||
ToQueuedTask([&] {
|
[&] {
|
||||||
// No padding supposed to be sent for paused observer
|
// No padding supposed to be sent for paused observer
|
||||||
EXPECT_EQ(0, padding_bitrate);
|
EXPECT_EQ(0, padding_bitrate);
|
||||||
testing::Mock::VerifyAndClearExpectations(&bitrate_allocator_);
|
testing::Mock::VerifyAndClearExpectations(&bitrate_allocator_);
|
||||||
vss_impl->Stop();
|
vss_impl->Stop();
|
||||||
done.Set();
|
done.Set();
|
||||||
}),
|
},
|
||||||
5000);
|
5000);
|
||||||
|
|
||||||
// Pause the test suite so that the last delayed task executes.
|
// Pause the test suite so that the last delayed task executes.
|
||||||
|
@ -905,11 +905,11 @@ TEST_F(VideoSendStreamImplTest, KeepAliveOnDroppedFrame) {
|
||||||
|
|
||||||
rtc::Event done;
|
rtc::Event done;
|
||||||
test_queue_.PostDelayedTask(
|
test_queue_.PostDelayedTask(
|
||||||
ToQueuedTask([&] {
|
[&] {
|
||||||
testing::Mock::VerifyAndClearExpectations(&bitrate_allocator_);
|
testing::Mock::VerifyAndClearExpectations(&bitrate_allocator_);
|
||||||
vss_impl->Stop();
|
vss_impl->Stop();
|
||||||
done.Set();
|
done.Set();
|
||||||
}),
|
},
|
||||||
2000);
|
2000);
|
||||||
ASSERT_TRUE(done.Wait(5000));
|
ASSERT_TRUE(done.Wait(5000));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue