rtc::Event: Finalize migration to TimeDelta.
Bug: webrtc:14366
Change-Id: Icd8792a2f9efa5609dd13da2e175042fac101d36
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/272101
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Auto-Submit: Markus Handell <handellm@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37844}
diff --git a/sdk/android/native_unittests/audio_device/audio_device_unittest.cc b/sdk/android/native_unittests/audio_device/audio_device_unittest.cc
index 7d582d4..6cf2f1e 100644
--- a/sdk/android/native_unittests/audio_device/audio_device_unittest.cc
+++ b/sdk/android/native_unittests/audio_device/audio_device_unittest.cc
@@ -57,7 +57,7 @@
// an event indicating that the test was OK.
static const size_t kNumCallbacks = 10;
// Max amount of time we wait for an event to be set while counting callbacks.
-static const int kTestTimeOutInMilliseconds = 10 * 1000;
+static constexpr TimeDelta kTestTimeOut = TimeDelta::Seconds(10);
// Average number of audio callbacks per second assuming 10ms packet size.
static const size_t kNumCallbacksPerSecond = 100;
// Play out a test file during this time (unit is in seconds).
@@ -66,7 +66,7 @@
static const size_t kBytesPerSample = kBitsPerSample / 8;
// Run the full-duplex test during this time (unit is in seconds).
// Note that first `kNumIgnoreFirstCallbacks` are ignored.
-static const int kFullDuplexTimeInSec = 5;
+static constexpr TimeDelta kFullDuplexTime = TimeDelta::Seconds(5);
// Wait for the callback sequence to stabilize by ignoring this amount of the
// initial callbacks (avoids initial FIFO access).
// Only used in the RunPlayoutAndRecordingInFullDuplex test.
@@ -74,8 +74,8 @@
// Sets the number of impulses per second in the latency test.
static const int kImpulseFrequencyInHz = 1;
// Length of round-trip latency measurements. Number of transmitted impulses
-// is kImpulseFrequencyInHz * kMeasureLatencyTimeInSec - 1.
-static const int kMeasureLatencyTimeInSec = 11;
+// is kImpulseFrequencyInHz * kMeasureLatencyTime - 1.
+static constexpr TimeDelta kMeasureLatencyTime = TimeDelta::Seconds(11);
// Utilized in round-trip latency measurements to avoid capturing noise samples.
static const int kImpulseThreshold = 1000;
static const char kTag[] = "[..........] ";
@@ -880,7 +880,7 @@
.Times(AtLeast(kNumCallbacks));
EXPECT_EQ(0, audio_device()->RegisterAudioCallback(&mock));
StartPlayout();
- test_is_done_.Wait(kTestTimeOutInMilliseconds);
+ test_is_done_.Wait(kTestTimeOut);
StopPlayout();
}
@@ -897,7 +897,7 @@
EXPECT_EQ(0, audio_device()->RegisterAudioCallback(&mock));
StartRecording();
- test_is_done_.Wait(kTestTimeOutInMilliseconds);
+ test_is_done_.Wait(kTestTimeOut);
StopRecording();
}
@@ -918,7 +918,7 @@
EXPECT_EQ(0, audio_device()->RegisterAudioCallback(&mock));
StartPlayout();
StartRecording();
- test_is_done_.Wait(kTestTimeOutInMilliseconds);
+ test_is_done_.Wait(kTestTimeOut);
StopRecording();
StopPlayout();
}
@@ -938,7 +938,7 @@
// SetMaxPlayoutVolume();
EXPECT_EQ(0, audio_device()->RegisterAudioCallback(&mock));
StartPlayout();
- test_is_done_.Wait(kTestTimeOutInMilliseconds);
+ test_is_done_.Wait(kTestTimeOut);
StopPlayout();
}
@@ -1059,7 +1059,7 @@
// one packet on average. However, under more realistic conditions, the size
// of the FIFO will vary more due to an unbalance between the two sides.
// This test tries to verify that the device maintains a balanced callback-
-// sequence by running in loopback for kFullDuplexTimeInSec seconds while
+// sequence by running in loopback for kFullDuplexTime seconds while
// measuring the size (max and average) of the FIFO. The size of the FIFO is
// increased by the recording side and decreased by the playout side.
// TODO(henrika): tune the final test parameters after running tests on several
@@ -1077,13 +1077,12 @@
std::unique_ptr<FifoAudioStream> fifo_audio_stream(
new FifoAudioStream(playout_frames_per_10ms_buffer()));
mock.HandleCallbacks(&test_is_done_, fifo_audio_stream.get(),
- kFullDuplexTimeInSec * kNumCallbacksPerSecond);
+ kFullDuplexTime.seconds() * kNumCallbacksPerSecond);
SetMaxPlayoutVolume();
EXPECT_EQ(0, audio_device()->RegisterAudioCallback(&mock));
StartRecording();
StartPlayout();
- test_is_done_.Wait(
- std::max(kTestTimeOutInMilliseconds, 1000 * kFullDuplexTimeInSec));
+ test_is_done_.Wait(std::max(kTestTimeOut, kFullDuplexTime));
StopPlayout();
StopRecording();
@@ -1110,20 +1109,19 @@
std::unique_ptr<LatencyMeasuringAudioStream> latency_audio_stream(
new LatencyMeasuringAudioStream(playout_frames_per_10ms_buffer()));
mock.HandleCallbacks(&test_is_done_, latency_audio_stream.get(),
- kMeasureLatencyTimeInSec * kNumCallbacksPerSecond);
+ kMeasureLatencyTime.seconds() * kNumCallbacksPerSecond);
EXPECT_EQ(0, audio_device()->RegisterAudioCallback(&mock));
SetMaxPlayoutVolume();
DisableBuiltInAECIfAvailable();
StartRecording();
StartPlayout();
- test_is_done_.Wait(
- std::max(kTestTimeOutInMilliseconds, 1000 * kMeasureLatencyTimeInSec));
+ test_is_done_.Wait(std::max(kTestTimeOut, kMeasureLatencyTime));
StopPlayout();
StopRecording();
// Verify that the correct number of transmitted impulses are detected.
EXPECT_EQ(latency_audio_stream->num_latency_values(),
static_cast<size_t>(
- kImpulseFrequencyInHz * kMeasureLatencyTimeInSec - 1));
+ kImpulseFrequencyInHz * kMeasureLatencyTime.seconds() - 1));
latency_audio_stream->PrintResults();
}
diff --git a/sdk/android/native_unittests/stacktrace/stacktrace_unittest.cc b/sdk/android/native_unittests/stacktrace/stacktrace_unittest.cc
index 5cbd4aa..cc0e740 100644
--- a/sdk/android/native_unittests/stacktrace/stacktrace_unittest.cc
+++ b/sdk/android/native_unittests/stacktrace/stacktrace_unittest.cc
@@ -263,7 +263,7 @@
// The message should appear after 3 sec. We'll wait up to 10 sec in an
// attempt to not be flaky.
- EXPECT_TRUE(sink.WhenFound().Wait(10000));
+ EXPECT_TRUE(sink.WhenFound().Wait(TimeDelta::Seconds(10)));
// Unblock the thread and shut it down.
ev.Set();