Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: webrtc/common_audio/smoothing_filter.cc

Issue 2782563003: Replace Clock with timeutils in AudioEncoder. (Closed)
Patch Set: Fix for failing unittest. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/common_audio/smoothing_filter.h ('k') | webrtc/common_audio/smoothing_filter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/common_audio/smoothing_filter.cc
diff --git a/webrtc/common_audio/smoothing_filter.cc b/webrtc/common_audio/smoothing_filter.cc
index 2ab25981f1e3af4b4777026f212591094f75a78c..91bcb22a25d6c3f08eaf2fe45c3a313114d788b3 100644
--- a/webrtc/common_audio/smoothing_filter.cc
+++ b/webrtc/common_audio/smoothing_filter.cc
@@ -12,30 +12,32 @@
#include <cmath>
+#include "webrtc/base/timeutils.h"
+
namespace webrtc {
-SmoothingFilterImpl::SmoothingFilterImpl(int init_time_ms, const Clock* clock)
+SmoothingFilterImpl::SmoothingFilterImpl(int init_time_ms)
: init_time_ms_(init_time_ms),
// Duing the initalization time, we use an increasing alpha. Specifically,
// alpha(n) = exp(-powf(init_factor_, n)),
// where |init_factor_| is chosen such that
// alpha(init_time_ms_) = exp(-1.0f / init_time_ms_),
- init_factor_(init_time_ms_ == 0 ? 0.0f : powf(init_time_ms_,
- -1.0f / init_time_ms_)),
+ init_factor_(init_time_ms_ == 0
+ ? 0.0f
+ : powf(init_time_ms_, -1.0f / init_time_ms_)),
// |init_const_| is to a factor to help the calculation during
// initialization phase.
init_const_(init_time_ms_ == 0
? 0.0f
: init_time_ms_ -
- powf(init_time_ms_, 1.0f - 1.0f / init_time_ms_)),
- clock_(clock) {
+ powf(init_time_ms_, 1.0f - 1.0f / init_time_ms_)) {
UpdateAlpha(init_time_ms_);
}
SmoothingFilterImpl::~SmoothingFilterImpl() = default;
void SmoothingFilterImpl::AddSample(float sample) {
- const int64_t now_ms = clock_->TimeInMilliseconds();
+ const int64_t now_ms = rtc::TimeMillis();
if (!init_end_time_ms_) {
// This is equivalent to assuming the filter has been receiving the same
@@ -55,7 +57,7 @@ rtc::Optional<float> SmoothingFilterImpl::GetAverage() {
// |init_end_time_ms_| undefined since we have not received any sample.
return rtc::Optional<float>();
}
- ExtrapolateLastSample(clock_->TimeInMilliseconds());
+ ExtrapolateLastSample(rtc::TimeMillis());
return rtc::Optional<float>(state_);
}
« no previous file with comments | « webrtc/common_audio/smoothing_filter.h ('k') | webrtc/common_audio/smoothing_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698