commit 7b3ffb0d1f9137aaa06ef570734b2702aeda2421
parent 6d0ed8ea2d1c20cd1948a734542aa82a364d3036
Author: Dan Baker <dbaker@mozilla.com>
Date: Fri, 24 Oct 2025 14:05:10 -0600
Bug 1995393 - Vendor libwebrtc from 92fd6cff81
Upstream commit: https://webrtc.googlesource.com/src/+/92fd6cff81c4fdaa8e0a1209cb3cb6b99496f722
Use injected clock in audio device buffer
Bug: webrtc:42223992
Change-Id: I4d1f2a16db3a9e1925e26735b23efffe3b0bba10
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/405382
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45403}
Diffstat:
3 files changed, 16 insertions(+), 22 deletions(-)
diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor
@@ -1,4 +1,4 @@
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
-libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-24T20:02:46.407172+00:00.
+libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-24T20:04:55.890062+00:00.
# base of lastest vendoring
-c57720cdc6
+92fd6cff81
diff --git a/third_party/libwebrtc/modules/audio_device/audio_device_buffer.cc b/third_party/libwebrtc/modules/audio_device/audio_device_buffer.cc
@@ -50,15 +50,8 @@ static const double k2Pi = 6.28318530717959;
AudioDeviceBuffer::AudioDeviceBuffer(const Environment& env,
bool create_detached)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- : AudioDeviceBuffer(&env.task_queue_factory(), create_detached) {
-}
-#pragma clang diagnostic pop
-
-AudioDeviceBuffer::AudioDeviceBuffer(TaskQueueFactory* task_queue_factory,
- bool create_detached)
- : task_queue_(task_queue_factory->CreateTaskQueue(
+ : env_(env),
+ task_queue_(env_.task_queue_factory().CreateTaskQueue(
kTimerQueueName,
TaskQueueFactory::Priority::NORMAL)),
audio_transport_cb_(nullptr),
@@ -134,7 +127,7 @@ void AudioDeviceBuffer::StartPlayout() {
if (!recording_) {
StartPeriodicLogging();
}
- const int64_t now_time = TimeMillis();
+ const int64_t now_time = env_.clock().TimeInMilliseconds();
// Clear members that are only touched on the main (creating) thread.
play_start_time_ = now_time;
playing_ = true;
@@ -154,7 +147,7 @@ void AudioDeviceBuffer::StartRecording() {
StartPeriodicLogging();
}
// Clear members that will be touched on the main (creating) thread.
- rec_start_time_ = TimeMillis();
+ rec_start_time_ = env_.clock().TimeInMilliseconds();
recording_ = true;
// And finally a member which can be modified on the native audio thread.
// It is safe to do so since we know by design that the owning ADM has not
@@ -173,7 +166,8 @@ void AudioDeviceBuffer::StopPlayout() {
if (!recording_) {
StopPeriodicLogging();
}
- RTC_LOG(LS_INFO) << "total playout time: " << TimeSince(play_start_time_);
+ RTC_LOG(LS_INFO) << "total playout time: "
+ << (env_.clock().TimeInMilliseconds() - play_start_time_);
}
void AudioDeviceBuffer::StopRecording() {
@@ -197,7 +191,8 @@ void AudioDeviceBuffer::StopRecording() {
// the fact that `only_silence_recorded_` can be affected during the complete
// call makes chances of conflicts with potentially one last callback very
// small.
- const size_t time_since_start = TimeSince(rec_start_time_);
+ const size_t time_since_start =
+ env_.clock().TimeInMilliseconds() - rec_start_time_;
if (time_since_start > kMinValidCallTimeTimeInMilliseconds) {
const int only_zeros = static_cast<int>(only_silence_recorded_);
RTC_HISTOGRAM_BOOLEAN("WebRTC.Audio.RecordedOnlyZeros", only_zeros);
@@ -277,7 +272,7 @@ int32_t AudioDeviceBuffer::SetRecordedBuffer(
}
if (capture_timestamp_ns) {
- int64_t align_offsync_estimation_time = TimeMicros();
+ int64_t align_offsync_estimation_time = env_.clock().TimeInMicroseconds();
if (align_offsync_estimation_time - TimestampAligner::kMinFrameIntervalUs >
align_offsync_estimation_time_) {
align_offsync_estimation_time_ = align_offsync_estimation_time;
@@ -421,7 +416,7 @@ void AudioDeviceBuffer::StopPeriodicLogging() {
void AudioDeviceBuffer::LogStats(LogState state) {
RTC_DCHECK_RUN_ON(task_queue_.get());
- int64_t now_time = TimeMillis();
+ int64_t now_time = env_.clock().TimeInMilliseconds();
if (state == AudioDeviceBuffer::LOG_START) {
// Reset counters at start. We will not add any logging in this state but
@@ -517,7 +512,8 @@ void AudioDeviceBuffer::LogStats(LogState state) {
}
last_stats_ = stats;
- int64_t time_to_wait_ms = next_callback_time - TimeMillis();
+ int64_t time_to_wait_ms =
+ next_callback_time - env_.clock().TimeInMilliseconds();
RTC_DCHECK_GT(time_to_wait_ms, 0) << "Invalid timer interval";
// Keep posting new (delayed) tasks until state is changed to kLogStop.
diff --git a/third_party/libwebrtc/modules/audio_device/audio_device_buffer.h b/third_party/libwebrtc/modules/audio_device/audio_device_buffer.h
@@ -21,7 +21,6 @@
#include "api/environment/environment.h"
#include "api/sequence_checker.h"
#include "api/task_queue/task_queue_base.h"
-#include "api/task_queue/task_queue_factory.h"
#include "rtc_base/buffer.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
@@ -85,9 +84,6 @@ class AudioDeviceBuffer {
// testing.
explicit AudioDeviceBuffer(const Environment& env,
bool create_detached = false);
- [[deprecated("bugs.webrtc.org/42223992")]]
- explicit AudioDeviceBuffer(TaskQueueFactory* task_queue_factory,
- bool create_detached = false);
virtual ~AudioDeviceBuffer();
int32_t RegisterAudioCallback(AudioTransport* audio_callback);
@@ -147,6 +143,8 @@ class AudioDeviceBuffer {
void ResetRecStats();
void ResetPlayStats();
+ const Environment env_;
+
// This object lives on the main (creating) thread and most methods are
// called on that same thread. When audio has started some methods will be
// called on either a native audio thread for playout or a native thread for