Run `git cl format --full` on the C++ files in system_wrappers/
Specifically, this CL was generated by the following shell commands:
cd system_wrappers
for f in $(find . -type f | grep -E '[.](h|cc)$'); do echo >> $f; done
git cl format --full
Followed by a revert of the changes to asm_defines.h since that file
is assembly and not C++, and a manual edit to clock.cc to add some
blank lines in the #include list to prevent `git cl format` from
sorting <MMSystem.h> before "rtc_base/win32.h".
I needed to do this because otherwise `git cl format` introduces a lot
of unrelated formatting changes in other CLs that move these files
(since `git cl format` will try to re-format all lines of a moved
file).
BUG=none
Change-Id: I083e23a57ce2899add3e60bbd539f03343c7c219
Reviewed-on: https://webrtc-review.googlesource.com/21161
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20600}
diff --git a/system_wrappers/include/aligned_array.h b/system_wrappers/include/aligned_array.h
index 88b5269..793c785 100644
--- a/system_wrappers/include/aligned_array.h
+++ b/system_wrappers/include/aligned_array.h
@@ -18,17 +18,17 @@
// Wrapper class for aligned arrays. Every row (and the first dimension) are
// aligned to the given byte alignment.
-template<typename T> class AlignedArray {
+template <typename T>
+class AlignedArray {
public:
AlignedArray(size_t rows, size_t cols, size_t alignment)
- : rows_(rows),
- cols_(cols) {
+ : rows_(rows), cols_(cols) {
RTC_CHECK_GT(alignment, 0);
- head_row_ = static_cast<T**>(AlignedMalloc(rows_ * sizeof(*head_row_),
- alignment));
+ head_row_ =
+ static_cast<T**>(AlignedMalloc(rows_ * sizeof(*head_row_), alignment));
for (size_t i = 0; i < rows_; ++i) {
- head_row_[i] = static_cast<T*>(AlignedMalloc(cols_ * sizeof(**head_row_),
- alignment));
+ head_row_[i] = static_cast<T*>(
+ AlignedMalloc(cols_ * sizeof(**head_row_), alignment));
}
}
@@ -39,13 +39,9 @@
AlignedFree(head_row_);
}
- T* const* Array() {
- return head_row_;
- }
+ T* const* Array() { return head_row_; }
- const T* const* Array() const {
- return head_row_;
- }
+ const T* const* Array() const { return head_row_; }
T* Row(size_t row) {
RTC_CHECK_LE(row, rows_);
@@ -67,13 +63,9 @@
return Row(row)[col];
}
- size_t rows() const {
- return rows_;
- }
+ size_t rows() const { return rows_; }
- size_t cols() const {
- return cols_;
- }
+ size_t cols() const { return cols_; }
private:
size_t rows_;
diff --git a/system_wrappers/include/aligned_malloc.h b/system_wrappers/include/aligned_malloc.h
index ac049b0..33b23d2 100644
--- a/system_wrappers/include/aligned_malloc.h
+++ b/system_wrappers/include/aligned_malloc.h
@@ -36,12 +36,12 @@
// Templated versions to facilitate usage of aligned malloc without casting
// to and from void*.
-template<typename T>
+template <typename T>
T* GetRightAlign(const T* ptr, size_t alignment) {
- return reinterpret_cast<T*>(GetRightAlign(reinterpret_cast<const void*>(ptr),
- alignment));
+ return reinterpret_cast<T*>(
+ GetRightAlign(reinterpret_cast<const void*>(ptr), alignment));
}
-template<typename T>
+template <typename T>
T* AlignedMalloc(size_t size, size_t alignment) {
return reinterpret_cast<T*>(AlignedMalloc(size, alignment));
}
@@ -49,11 +49,9 @@
// Deleter for use with unique_ptr. E.g., use as
// std::unique_ptr<Foo, AlignedFreeDeleter> foo;
struct AlignedFreeDeleter {
- inline void operator()(void* ptr) const {
- AlignedFree(ptr);
- }
+ inline void operator()(void* ptr) const { AlignedFree(ptr); }
};
} // namespace webrtc
-#endif // SYSTEM_WRAPPERS_INCLUDE_ALIGNED_MALLOC_H_
+#endif // SYSTEM_WRAPPERS_INCLUDE_ALIGNED_MALLOC_H_
diff --git a/system_wrappers/include/cpu_features_wrapper.h b/system_wrappers/include/cpu_features_wrapper.h
index 7187077..07ee912 100644
--- a/system_wrappers/include/cpu_features_wrapper.h
+++ b/system_wrappers/include/cpu_features_wrapper.h
@@ -18,17 +18,14 @@
#include "typedefs.h" // NOLINT(build/include)
// List of features in x86.
-typedef enum {
- kSSE2,
- kSSE3
-} CPUFeature;
+typedef enum { kSSE2, kSSE3 } CPUFeature;
// List of features in ARM.
enum {
- kCPUFeatureARMv7 = (1 << 0),
- kCPUFeatureVFPv3 = (1 << 1),
- kCPUFeatureNEON = (1 << 2),
- kCPUFeatureLDREXSTREX = (1 << 3)
+ kCPUFeatureARMv7 = (1 << 0),
+ kCPUFeatureVFPv3 = (1 << 1),
+ kCPUFeatureNEON = (1 << 2),
+ kCPUFeatureLDREXSTREX = (1 << 3)
};
typedef int (*WebRtc_CPUInfo)(CPUFeature feature);
@@ -48,4 +45,4 @@
} // extern "C"
#endif
-#endif // SYSTEM_WRAPPERS_INCLUDE_CPU_FEATURES_WRAPPER_H_
+#endif // SYSTEM_WRAPPERS_INCLUDE_CPU_FEATURES_WRAPPER_H_
diff --git a/system_wrappers/include/cpu_info.h b/system_wrappers/include/cpu_info.h
index c4cf2da..dbd5d60 100644
--- a/system_wrappers/include/cpu_info.h
+++ b/system_wrappers/include/cpu_info.h
@@ -25,4 +25,4 @@
} // namespace webrtc
-#endif // SYSTEM_WRAPPERS_INCLUDE_CPU_INFO_H_
+#endif // SYSTEM_WRAPPERS_INCLUDE_CPU_INFO_H_
diff --git a/system_wrappers/include/event_wrapper.h b/system_wrappers/include/event_wrapper.h
index b8dab2c..0c29138 100644
--- a/system_wrappers/include/event_wrapper.h
+++ b/system_wrappers/include/event_wrapper.h
@@ -62,7 +62,6 @@
virtual bool StartTimer(bool periodic, unsigned long time) = 0;
virtual bool StopTimer() = 0;
-
};
} // namespace webrtc
diff --git a/system_wrappers/include/metrics.h b/system_wrappers/include/metrics.h
index 6a6878a..13f2483 100644
--- a/system_wrappers/include/metrics.h
+++ b/system_wrappers/include/metrics.h
@@ -61,7 +61,6 @@
// NOTE: It is recommended to do the Chromium review for modifications to
// histograms.xml before new metrics are committed to WebRTC.
-
// Macros for adding samples to a named histogram.
// Histogram for counters (exponentially spaced buckets).
@@ -83,9 +82,10 @@
#define RTC_HISTOGRAM_COUNTS_100000(name, sample) \
RTC_HISTOGRAM_COUNTS(name, sample, 1, 100000, 50)
-#define RTC_HISTOGRAM_COUNTS(name, sample, min, max, bucket_count) \
- RTC_HISTOGRAM_COMMON_BLOCK(name, sample, \
- webrtc::metrics::HistogramFactoryGetCounts(name, min, max, bucket_count))
+#define RTC_HISTOGRAM_COUNTS(name, sample, min, max, bucket_count) \
+ RTC_HISTOGRAM_COMMON_BLOCK(name, sample, \
+ webrtc::metrics::HistogramFactoryGetCounts( \
+ name, min, max, bucket_count))
#define RTC_HISTOGRAM_COUNTS_LINEAR(name, sample, min, max, bucket_count) \
RTC_HISTOGRAM_COMMON_BLOCK(name, sample, \
@@ -112,9 +112,10 @@
#define RTC_HISTOGRAM_COUNTS_SPARSE_100000(name, sample) \
RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, 1, 100000, 50)
-#define RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, min, max, bucket_count) \
- RTC_HISTOGRAM_COMMON_BLOCK_SLOW(name, sample, \
- webrtc::metrics::HistogramFactoryGetCounts(name, min, max, bucket_count))
+#define RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, min, max, bucket_count) \
+ RTC_HISTOGRAM_COMMON_BLOCK_SLOW(name, sample, \
+ webrtc::metrics::HistogramFactoryGetCounts( \
+ name, min, max, bucket_count))
// Histogram for percentage (evenly spaced buckets).
#define RTC_HISTOGRAM_PERCENTAGE_SPARSE(name, sample) \
@@ -142,7 +143,8 @@
// Histogram for enumerators (evenly spaced buckets).
// |boundary| should be above the max enumerator sample.
#define RTC_HISTOGRAM_ENUMERATION(name, sample, boundary) \
- RTC_HISTOGRAM_COMMON_BLOCK(name, sample, \
+ RTC_HISTOGRAM_COMMON_BLOCK( \
+ name, sample, \
webrtc::metrics::HistogramFactoryGetEnumeration(name, boundary))
// The name of the histogram should not vary.
@@ -185,36 +187,36 @@
// is cached. |index| should be different for different names. Allowed |index|
// values are 0, 1, and 2.
#define RTC_HISTOGRAMS_COUNTS_100(index, name, sample) \
- RTC_HISTOGRAMS_COMMON(index, name, sample, \
- RTC_HISTOGRAM_COUNTS(name, sample, 1, 100, 50))
+ RTC_HISTOGRAMS_COMMON(index, name, sample, \
+ RTC_HISTOGRAM_COUNTS(name, sample, 1, 100, 50))
#define RTC_HISTOGRAMS_COUNTS_200(index, name, sample) \
- RTC_HISTOGRAMS_COMMON(index, name, sample, \
- RTC_HISTOGRAM_COUNTS(name, sample, 1, 200, 50))
+ RTC_HISTOGRAMS_COMMON(index, name, sample, \
+ RTC_HISTOGRAM_COUNTS(name, sample, 1, 200, 50))
#define RTC_HISTOGRAMS_COUNTS_500(index, name, sample) \
- RTC_HISTOGRAMS_COMMON(index, name, sample, \
- RTC_HISTOGRAM_COUNTS(name, sample, 1, 500, 50))
+ RTC_HISTOGRAMS_COMMON(index, name, sample, \
+ RTC_HISTOGRAM_COUNTS(name, sample, 1, 500, 50))
#define RTC_HISTOGRAMS_COUNTS_1000(index, name, sample) \
- RTC_HISTOGRAMS_COMMON(index, name, sample, \
- RTC_HISTOGRAM_COUNTS(name, sample, 1, 1000, 50))
+ RTC_HISTOGRAMS_COMMON(index, name, sample, \
+ RTC_HISTOGRAM_COUNTS(name, sample, 1, 1000, 50))
#define RTC_HISTOGRAMS_COUNTS_10000(index, name, sample) \
- RTC_HISTOGRAMS_COMMON(index, name, sample, \
- RTC_HISTOGRAM_COUNTS(name, sample, 1, 10000, 50))
+ RTC_HISTOGRAMS_COMMON(index, name, sample, \
+ RTC_HISTOGRAM_COUNTS(name, sample, 1, 10000, 50))
#define RTC_HISTOGRAMS_COUNTS_100000(index, name, sample) \
- RTC_HISTOGRAMS_COMMON(index, name, sample, \
- RTC_HISTOGRAM_COUNTS(name, sample, 1, 100000, 50))
+ RTC_HISTOGRAMS_COMMON(index, name, sample, \
+ RTC_HISTOGRAM_COUNTS(name, sample, 1, 100000, 50))
#define RTC_HISTOGRAMS_ENUMERATION(index, name, sample, boundary) \
- RTC_HISTOGRAMS_COMMON(index, name, sample, \
- RTC_HISTOGRAM_ENUMERATION(name, sample, boundary))
+ RTC_HISTOGRAMS_COMMON(index, name, sample, \
+ RTC_HISTOGRAM_ENUMERATION(name, sample, boundary))
#define RTC_HISTOGRAMS_PERCENTAGE(index, name, sample) \
- RTC_HISTOGRAMS_COMMON(index, name, sample, \
- RTC_HISTOGRAM_PERCENTAGE(name, sample))
+ RTC_HISTOGRAMS_COMMON(index, name, sample, \
+ RTC_HISTOGRAM_PERCENTAGE(name, sample))
#define RTC_HISTOGRAMS_COMMON(index, name, sample, macro_invocation) \
do { \
@@ -245,8 +247,10 @@
// histogram).
// Get histogram for counters.
-Histogram* HistogramFactoryGetCounts(
- const std::string& name, int min, int max, int bucket_count);
+Histogram* HistogramFactoryGetCounts(const std::string& name,
+ int min,
+ int max,
+ int bucket_count);
// Get histogram for counters with linear bucket spacing.
Histogram* HistogramFactoryGetCountsLinear(const std::string& name,
@@ -256,8 +260,8 @@
// Get histogram for enumerators.
// |boundary| should be above the max enumerator sample.
-Histogram* HistogramFactoryGetEnumeration(
- const std::string& name, int boundary);
+Histogram* HistogramFactoryGetEnumeration(const std::string& name,
+ int boundary);
// Function for adding a |sample| to a histogram.
void HistogramAdd(Histogram* histogram_pointer, int sample);
diff --git a/system_wrappers/include/ntp_time.h b/system_wrappers/include/ntp_time.h
index 43ef161..e963ecf 100644
--- a/system_wrappers/include/ntp_time.h
+++ b/system_wrappers/include/ntp_time.h
@@ -1,12 +1,12 @@
/*
-* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
-*
-* Use of this source code is governed by a BSD-style license
-* that can be found in the LICENSE file in the root of the source
-* tree. An additional intellectual property rights grant can be found
-* in the file PATENTS. All contributing project authors may
-* be found in the AUTHORS file in the root of the source tree.
-*/
+ * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
#ifndef SYSTEM_WRAPPERS_INCLUDE_NTP_TIME_H_
#define SYSTEM_WRAPPERS_INCLUDE_NTP_TIME_H_
diff --git a/system_wrappers/include/timestamp_extrapolator.h b/system_wrappers/include/timestamp_extrapolator.h
index 907b56f..9418100 100644
--- a/system_wrappers/include/timestamp_extrapolator.h
+++ b/system_wrappers/include/timestamp_extrapolator.h
@@ -14,43 +14,41 @@
#include "system_wrappers/include/rw_lock_wrapper.h"
#include "typedefs.h" // NOLINT(build/include)
-namespace webrtc
-{
+namespace webrtc {
-class TimestampExtrapolator
-{
-public:
- explicit TimestampExtrapolator(int64_t start_ms);
- ~TimestampExtrapolator();
- void Update(int64_t tMs, uint32_t ts90khz);
- int64_t ExtrapolateLocalTime(uint32_t timestamp90khz);
- void Reset(int64_t start_ms);
+class TimestampExtrapolator {
+ public:
+ explicit TimestampExtrapolator(int64_t start_ms);
+ ~TimestampExtrapolator();
+ void Update(int64_t tMs, uint32_t ts90khz);
+ int64_t ExtrapolateLocalTime(uint32_t timestamp90khz);
+ void Reset(int64_t start_ms);
-private:
- void CheckForWrapArounds(uint32_t ts90khz);
- bool DelayChangeDetection(double error);
- RWLockWrapper* _rwLock;
- double _w[2];
- double _pP[2][2];
- int64_t _startMs;
- int64_t _prevMs;
- uint32_t _firstTimestamp;
- int32_t _wrapArounds;
- int64_t _prevUnwrappedTimestamp;
- int64_t _prevWrapTimestamp;
- const double _lambda;
- bool _firstAfterReset;
- uint32_t _packetCount;
- const uint32_t _startUpFilterDelayInPackets;
+ private:
+ void CheckForWrapArounds(uint32_t ts90khz);
+ bool DelayChangeDetection(double error);
+ RWLockWrapper* _rwLock;
+ double _w[2];
+ double _pP[2][2];
+ int64_t _startMs;
+ int64_t _prevMs;
+ uint32_t _firstTimestamp;
+ int32_t _wrapArounds;
+ int64_t _prevUnwrappedTimestamp;
+ int64_t _prevWrapTimestamp;
+ const double _lambda;
+ bool _firstAfterReset;
+ uint32_t _packetCount;
+ const uint32_t _startUpFilterDelayInPackets;
- double _detectorAccumulatorPos;
- double _detectorAccumulatorNeg;
- const double _alarmThreshold;
- const double _accDrift;
- const double _accMaxError;
- const double _pP11;
+ double _detectorAccumulatorPos;
+ double _detectorAccumulatorNeg;
+ const double _alarmThreshold;
+ const double _accDrift;
+ const double _accMaxError;
+ const double _pP11;
};
} // namespace webrtc
-#endif // SYSTEM_WRAPPERS_INCLUDE_TIMESTAMP_EXTRAPOLATOR_H_
+#endif // SYSTEM_WRAPPERS_INCLUDE_TIMESTAMP_EXTRAPOLATOR_H_
diff --git a/system_wrappers/source/aligned_malloc_unittest.cc b/system_wrappers/source/aligned_malloc_unittest.cc
index 2ae61e1..7afbf6d 100644
--- a/system_wrappers/source/aligned_malloc_unittest.cc
+++ b/system_wrappers/source/aligned_malloc_unittest.cc
@@ -30,7 +30,7 @@
if (scoped.get() == NULL) {
return false;
}
- const uintptr_t scoped_address = reinterpret_cast<uintptr_t> (scoped.get());
+ const uintptr_t scoped_address = reinterpret_cast<uintptr_t>(scoped.get());
return 0u == scoped_address % alignment;
}
@@ -41,10 +41,10 @@
std::unique_ptr<char, AlignedFreeDeleter> scoped(
static_cast<char*>(AlignedMalloc(size, alignment)));
EXPECT_TRUE(scoped.get() != NULL);
- const uintptr_t aligned_address = reinterpret_cast<uintptr_t> (scoped.get());
+ const uintptr_t aligned_address = reinterpret_cast<uintptr_t>(scoped.get());
const uintptr_t misaligned_address = aligned_address - left_misalignment;
- const char* misaligned_ptr = reinterpret_cast<const char*>(
- misaligned_address);
+ const char* misaligned_ptr =
+ reinterpret_cast<const char*>(misaligned_address);
const char* realigned_ptr = GetRightAlign(misaligned_ptr, alignment);
EXPECT_EQ(scoped.get(), realigned_ptr);
}
@@ -80,4 +80,3 @@
}
} // namespace webrtc
-
diff --git a/system_wrappers/source/clock.cc b/system_wrappers/source/clock.cc
index 184b35e..fc86355 100644
--- a/system_wrappers/source/clock.cc
+++ b/system_wrappers/source/clock.cc
@@ -11,12 +11,17 @@
#include "system_wrappers/include/clock.h"
#if defined(_WIN32)
+
// Windows needs to be included before mmsystem.h
#include "rtc_base/win32.h"
+
#include <MMSystem.h>
+
#elif ((defined WEBRTC_LINUX) || (defined WEBRTC_MAC))
+
#include <sys/time.h>
#include <time.h>
+
#endif
#include "rtc_base/criticalsection.h"
@@ -28,15 +33,11 @@
class RealTimeClock : public Clock {
// Return a timestamp in milliseconds relative to some arbitrary source; the
// source is fixed for this clock.
- int64_t TimeInMilliseconds() const override {
- return rtc::TimeMillis();
- }
+ int64_t TimeInMilliseconds() const override { return rtc::TimeMillis(); }
// Return a timestamp in microseconds relative to some arbitrary source; the
// source is fixed for this clock.
- int64_t TimeInMicroseconds() const override {
- return rtc::TimeMicros();
- }
+ int64_t TimeInMicroseconds() const override { return rtc::TimeMicros(); }
// Retrieve an NTP absolute timestamp.
NtpTime CurrentNtpTime() const override {
@@ -56,13 +57,14 @@
double microseconds_in_seconds;
Adjust(tv, &seconds, µseconds_in_seconds);
return 1000 * static_cast<int64_t>(seconds) +
- static_cast<int64_t>(1000.0 * microseconds_in_seconds + 0.5);
+ static_cast<int64_t>(1000.0 * microseconds_in_seconds + 0.5);
}
protected:
virtual timeval CurrentTimeVal() const = 0;
- static void Adjust(const timeval& tv, uint32_t* adjusted_s,
+ static void Adjust(const timeval& tv,
+ uint32_t* adjusted_s,
double* adjusted_us_in_s) {
*adjusted_s = tv.tv_sec + kNtpJan1970;
*adjusted_us_in_s = tv.tv_usec / 1e6;
@@ -107,8 +109,8 @@
// speed stepping.
GetTime(&StartTime);
- Time = (((uint64_t) StartTime.dwHighDateTime) << 32) +
- (uint64_t) StartTime.dwLowDateTime;
+ Time = (((uint64_t)StartTime.dwHighDateTime) << 32) +
+ (uint64_t)StartTime.dwLowDateTime;
// Convert the hecto-nano second time to tv format.
Time -= FILETIME_1970;
@@ -226,11 +228,9 @@
}
SimulatedClock::SimulatedClock(int64_t initial_time_us)
- : time_us_(initial_time_us), lock_(RWLockWrapper::CreateRWLock()) {
-}
+ : time_us_(initial_time_us), lock_(RWLockWrapper::CreateRWLock()) {}
-SimulatedClock::~SimulatedClock() {
-}
+SimulatedClock::~SimulatedClock() {}
int64_t SimulatedClock::TimeInMilliseconds() const {
ReadLockScoped synchronize(*lock_);
diff --git a/system_wrappers/source/cpu_features.cc b/system_wrappers/source/cpu_features.cc
index 1c7e45e..7417f53 100644
--- a/system_wrappers/source/cpu_features.cc
+++ b/system_wrappers/source/cpu_features.cc
@@ -30,18 +30,19 @@
#if defined(__pic__) && defined(__i386__)
static inline void __cpuid(int cpu_info[4], int info_type) {
__asm__ volatile(
- "mov %%ebx, %%edi\n"
- "cpuid\n"
- "xchg %%edi, %%ebx\n"
- : "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
- : "a"(info_type));
+ "mov %%ebx, %%edi\n"
+ "cpuid\n"
+ "xchg %%edi, %%ebx\n"
+ : "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]),
+ "=d"(cpu_info[3])
+ : "a"(info_type));
}
#else
static inline void __cpuid(int cpu_info[4], int info_type) {
- __asm__ volatile(
- "cpuid\n"
- : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
- : "a"(info_type));
+ __asm__ volatile("cpuid\n"
+ : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]),
+ "=d"(cpu_info[3])
+ : "a"(info_type));
}
#endif
#endif // _MSC_VER
diff --git a/system_wrappers/source/cpu_info.cc b/system_wrappers/source/cpu_info.cc
index b96369d..fa70ced 100644
--- a/system_wrappers/source/cpu_info.cc
+++ b/system_wrappers/source/cpu_info.cc
@@ -11,8 +11,8 @@
#include "system_wrappers/include/cpu_info.h"
#if defined(WEBRTC_WIN)
-#include <winsock2.h>
#include <windows.h>
+#include <winsock2.h>
#ifndef EXCLUDE_D3D9
#include <d3d9.h>
#endif
@@ -51,7 +51,7 @@
return number_of_cores;
}
-}
+} // namespace internal
namespace webrtc {
diff --git a/system_wrappers/source/event.cc b/system_wrappers/source/event.cc
index 1bbd01f..aac69f6 100644
--- a/system_wrappers/source/event.cc
+++ b/system_wrappers/source/event.cc
@@ -37,8 +37,9 @@
}
EventTypeWrapper Wait(unsigned long max_time) override {
- int to_wait = max_time == WEBRTC_EVENT_INFINITE ?
- rtc::Event::kForever : static_cast<int>(max_time);
+ int to_wait = max_time == WEBRTC_EVENT_INFINITE
+ ? rtc::Event::kForever
+ : static_cast<int>(max_time);
return event_.Wait(to_wait) ? kEventSignaled : kEventTimeout;
}
diff --git a/system_wrappers/source/event_timer_posix.cc b/system_wrappers/source/event_timer_posix.cc
index bc663ad..2a6a580 100644
--- a/system_wrappers/source/event_timer_posix.cc
+++ b/system_wrappers/source/event_timer_posix.cc
@@ -160,7 +160,7 @@
// Timer already started.
pthread_mutex_unlock(&mutex_);
return false;
- } else {
+ } else {
// New one shot timer.
time_ms_ = time_ms;
created_at_.tv_sec = 0;
diff --git a/system_wrappers/source/event_timer_posix.h b/system_wrappers/source/event_timer_posix.h
index 4de7422..72d6753 100644
--- a/system_wrappers/source/event_timer_posix.h
+++ b/system_wrappers/source/event_timer_posix.h
@@ -22,10 +22,7 @@
namespace webrtc {
-enum State {
- kUp = 1,
- kDown = 2
-};
+enum State { kUp = 1, kDown = 2 };
class EventTimerPosix : public EventTimerWrapper {
public:
@@ -47,16 +44,16 @@
virtual rtc::PlatformThread* CreateThread();
- pthread_cond_t cond_;
+ pthread_cond_t cond_;
pthread_mutex_t mutex_;
bool event_set_;
// TODO(pbos): Remove unique_ptr and use PlatformThread directly.
std::unique_ptr<rtc::PlatformThread> timer_thread_;
std::unique_ptr<EventTimerPosix> timer_event_;
- timespec created_at_;
+ timespec created_at_;
- bool periodic_;
+ bool periodic_;
unsigned long time_ms_;
unsigned long count_;
bool is_stopping_;
diff --git a/system_wrappers/source/event_timer_win.cc b/system_wrappers/source/event_timer_win.cc
index 19ed3fa..b6a93fe 100644
--- a/system_wrappers/source/event_timer_win.cc
+++ b/system_wrappers/source/event_timer_win.cc
@@ -24,8 +24,7 @@
FALSE, // manual reset
FALSE, // initial state
NULL)), // name of event
- timerID_(NULL) {
-}
+ timerID_(NULL) {}
EventTimerWin::~EventTimerWin() {
StopTimer();
diff --git a/system_wrappers/source/event_timer_win.h b/system_wrappers/source/event_timer_win.h
index 827390c..5631a3f 100644
--- a/system_wrappers/source/event_timer_win.h
+++ b/system_wrappers/source/event_timer_win.h
@@ -31,7 +31,7 @@
virtual bool StopTimer();
private:
- HANDLE event_;
+ HANDLE event_;
uint32_t timerID_;
};
diff --git a/system_wrappers/source/field_trial_default.cc b/system_wrappers/source/field_trial_default.cc
index 94e56b5..e8d8917 100644
--- a/system_wrappers/source/field_trial_default.cc
+++ b/system_wrappers/source/field_trial_default.cc
@@ -7,8 +7,8 @@
// be found in the AUTHORS file in the root of the source tree.
//
-#include "system_wrappers/include/field_trial.h"
#include "system_wrappers/include/field_trial_default.h"
+#include "system_wrappers/include/field_trial.h"
#include <string>
@@ -17,7 +17,7 @@
namespace webrtc {
namespace field_trial {
-static const char *trials_init_string = NULL;
+static const char* trials_init_string = NULL;
std::string FindFullName(const std::string& name) {
if (trials_init_string == NULL)
@@ -30,21 +30,20 @@
static const char kPersistentStringSeparator = '/';
size_t next_item = 0;
while (next_item < trials_string.length()) {
-
// Find next name/value pair in field trial configuration string.
- size_t field_name_end = trials_string.find(
- kPersistentStringSeparator, next_item);
+ size_t field_name_end =
+ trials_string.find(kPersistentStringSeparator, next_item);
if (field_name_end == trials_string.npos || field_name_end == next_item)
break;
- size_t field_value_end = trials_string.find(
- kPersistentStringSeparator, field_name_end + 1);
+ size_t field_value_end =
+ trials_string.find(kPersistentStringSeparator, field_name_end + 1);
if (field_value_end == trials_string.npos ||
field_value_end == field_name_end + 1)
break;
std::string field_name(trials_string, next_item,
- field_name_end - next_item);
+ field_name_end - next_item);
std::string field_value(trials_string, field_name_end + 1,
- field_value_end - field_name_end - 1);
+ field_value_end - field_name_end - 1);
next_item = field_value_end + 1;
if (name == field_name)
diff --git a/system_wrappers/source/metrics_default_unittest.cc b/system_wrappers/source/metrics_default_unittest.cc
index dfac863..fa253a9 100644
--- a/system_wrappers/source/metrics_default_unittest.cc
+++ b/system_wrappers/source/metrics_default_unittest.cc
@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "system_wrappers/include/metrics.h"
#include "system_wrappers/include/metrics_default.h"
+#include "system_wrappers/include/metrics.h"
#include "test/gtest.h"
namespace webrtc {
@@ -54,9 +54,7 @@
MetricsDefaultTest() {}
protected:
- virtual void SetUp() {
- metrics::Reset();
- }
+ virtual void SetUp() { metrics::Reset(); }
};
TEST_F(MetricsDefaultTest, Reset) {
diff --git a/system_wrappers/source/metrics_unittest.cc b/system_wrappers/source/metrics_unittest.cc
index fe909e8..53d43cd 100644
--- a/system_wrappers/source/metrics_unittest.cc
+++ b/system_wrappers/source/metrics_unittest.cc
@@ -29,9 +29,7 @@
MetricsTest() {}
protected:
- virtual void SetUp() {
- metrics::Reset();
- }
+ virtual void SetUp() { metrics::Reset(); }
};
TEST_F(MetricsTest, InitiallyNoSamples) {
diff --git a/system_wrappers/source/ntp_time_unittest.cc b/system_wrappers/source/ntp_time_unittest.cc
index 3fb1743..7be464d 100644
--- a/system_wrappers/source/ntp_time_unittest.cc
+++ b/system_wrappers/source/ntp_time_unittest.cc
@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "system_wrappers/include/clock.h"
#include "system_wrappers/include/ntp_time.h"
+#include "system_wrappers/include/clock.h"
#include "test/gtest.h"
namespace webrtc {
diff --git a/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc b/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc
index 4084620..6bf12f4 100644
--- a/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc
+++ b/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc
@@ -86,8 +86,8 @@
estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr));
int64_t timestamp_ms = -1;
- EXPECT_TRUE(estimator.Estimate(0xFFFFFFFF - 2 * kTimestampTicksPerMs,
- ×tamp_ms));
+ EXPECT_TRUE(
+ estimator.Estimate(0xFFFFFFFF - 2 * kTimestampTicksPerMs, ×tamp_ms));
// Since this RTP packet has the same timestamp as the RTCP packet constructed
// at time 0 it should be mapped to 0 as well.
EXPECT_EQ(0, timestamp_ms);
diff --git a/system_wrappers/source/rw_lock_posix.cc b/system_wrappers/source/rw_lock_posix.cc
index f1b743b..412873c 100644
--- a/system_wrappers/source/rw_lock_posix.cc
+++ b/system_wrappers/source/rw_lock_posix.cc
@@ -12,8 +12,7 @@
namespace webrtc {
-RWLockPosix::RWLockPosix() : lock_() {
-}
+RWLockPosix::RWLockPosix() : lock_() {}
RWLockPosix::~RWLockPosix() {
pthread_rwlock_destroy(&lock_);
diff --git a/system_wrappers/source/rw_lock_win.cc b/system_wrappers/source/rw_lock_win.cc
index 1debe7d..e81e9d7 100644
--- a/system_wrappers/source/rw_lock_win.cc
+++ b/system_wrappers/source/rw_lock_win.cc
@@ -18,18 +18,18 @@
static bool module_load_attempted = false;
static HMODULE library = NULL;
-typedef void (WINAPI* InitializeSRWLock)(PSRWLOCK);
+typedef void(WINAPI* InitializeSRWLock)(PSRWLOCK);
-typedef void (WINAPI* AcquireSRWLockExclusive)(PSRWLOCK);
-typedef void (WINAPI* ReleaseSRWLockExclusive)(PSRWLOCK);
+typedef void(WINAPI* AcquireSRWLockExclusive)(PSRWLOCK);
+typedef void(WINAPI* ReleaseSRWLockExclusive)(PSRWLOCK);
-typedef void (WINAPI* AcquireSRWLockShared)(PSRWLOCK);
-typedef void (WINAPI* ReleaseSRWLockShared)(PSRWLOCK);
+typedef void(WINAPI* AcquireSRWLockShared)(PSRWLOCK);
+typedef void(WINAPI* ReleaseSRWLockShared)(PSRWLOCK);
-InitializeSRWLock initialize_srw_lock;
+InitializeSRWLock initialize_srw_lock;
AcquireSRWLockExclusive acquire_srw_lock_exclusive;
-AcquireSRWLockShared acquire_srw_lock_shared;
-ReleaseSRWLockShared release_srw_lock_shared;
+AcquireSRWLockShared acquire_srw_lock_shared;
+ReleaseSRWLockShared release_srw_lock_shared;
ReleaseSRWLockExclusive release_srw_lock_exclusive;
RWLockWin::RWLockWin() {
@@ -72,18 +72,16 @@
LOG(LS_VERBOSE) << "Loaded Kernel.dll";
initialize_srw_lock =
- (InitializeSRWLock)GetProcAddress(library, "InitializeSRWLock");
+ (InitializeSRWLock)GetProcAddress(library, "InitializeSRWLock");
- acquire_srw_lock_exclusive =
- (AcquireSRWLockExclusive)GetProcAddress(library,
- "AcquireSRWLockExclusive");
- release_srw_lock_exclusive =
- (ReleaseSRWLockExclusive)GetProcAddress(library,
- "ReleaseSRWLockExclusive");
+ acquire_srw_lock_exclusive = (AcquireSRWLockExclusive)GetProcAddress(
+ library, "AcquireSRWLockExclusive");
+ release_srw_lock_exclusive = (ReleaseSRWLockExclusive)GetProcAddress(
+ library, "ReleaseSRWLockExclusive");
acquire_srw_lock_shared =
- (AcquireSRWLockShared)GetProcAddress(library, "AcquireSRWLockShared");
+ (AcquireSRWLockShared)GetProcAddress(library, "AcquireSRWLockShared");
release_srw_lock_shared =
- (ReleaseSRWLockShared)GetProcAddress(library, "ReleaseSRWLockShared");
+ (ReleaseSRWLockShared)GetProcAddress(library, "ReleaseSRWLockShared");
if (initialize_srw_lock && acquire_srw_lock_exclusive &&
release_srw_lock_exclusive && acquire_srw_lock_shared &&
diff --git a/system_wrappers/source/timestamp_extrapolator.cc b/system_wrappers/source/timestamp_extrapolator.cc
index 98f6a7b..b8c6ba0 100644
--- a/system_wrappers/source/timestamp_extrapolator.cc
+++ b/system_wrappers/source/timestamp_extrapolator.cc
@@ -31,205 +31,178 @@
_accDrift(6600), // in timestamp ticks, i.e. 15 ms
_accMaxError(7000),
_pP11(1e10) {
- Reset(start_ms);
+ Reset(start_ms);
}
-TimestampExtrapolator::~TimestampExtrapolator()
-{
- delete _rwLock;
+TimestampExtrapolator::~TimestampExtrapolator() {
+ delete _rwLock;
}
-void TimestampExtrapolator::Reset(int64_t start_ms)
-{
- WriteLockScoped wl(*_rwLock);
- _startMs = start_ms;
- _prevMs = _startMs;
- _firstTimestamp = 0;
- _w[0] = 90.0;
- _w[1] = 0;
- _pP[0][0] = 1;
- _pP[1][1] = _pP11;
- _pP[0][1] = _pP[1][0] = 0;
- _firstAfterReset = true;
- _prevUnwrappedTimestamp = -1;
- _prevWrapTimestamp = -1;
- _wrapArounds = 0;
- _packetCount = 0;
- _detectorAccumulatorPos = 0;
- _detectorAccumulatorNeg = 0;
+void TimestampExtrapolator::Reset(int64_t start_ms) {
+ WriteLockScoped wl(*_rwLock);
+ _startMs = start_ms;
+ _prevMs = _startMs;
+ _firstTimestamp = 0;
+ _w[0] = 90.0;
+ _w[1] = 0;
+ _pP[0][0] = 1;
+ _pP[1][1] = _pP11;
+ _pP[0][1] = _pP[1][0] = 0;
+ _firstAfterReset = true;
+ _prevUnwrappedTimestamp = -1;
+ _prevWrapTimestamp = -1;
+ _wrapArounds = 0;
+ _packetCount = 0;
+ _detectorAccumulatorPos = 0;
+ _detectorAccumulatorNeg = 0;
}
-void
-TimestampExtrapolator::Update(int64_t tMs, uint32_t ts90khz)
-{
-
- _rwLock->AcquireLockExclusive();
- if (tMs - _prevMs > 10e3)
- {
- // Ten seconds without a complete frame.
- // Reset the extrapolator
- _rwLock->ReleaseLockExclusive();
- Reset(tMs);
- _rwLock->AcquireLockExclusive();
- }
- else
- {
- _prevMs = tMs;
- }
-
- // Remove offset to prevent badly scaled matrices
- tMs -= _startMs;
-
- CheckForWrapArounds(ts90khz);
-
- int64_t unwrapped_ts90khz = static_cast<int64_t>(ts90khz) +
- _wrapArounds * ((static_cast<int64_t>(1) << 32) - 1);
-
- if (_firstAfterReset)
- {
- // Make an initial guess of the offset,
- // should be almost correct since tMs - _startMs
- // should about zero at this time.
- _w[1] = -_w[0] * tMs;
- _firstTimestamp = unwrapped_ts90khz;
- _firstAfterReset = false;
- }
-
- double residual =
- (static_cast<double>(unwrapped_ts90khz) - _firstTimestamp) -
- static_cast<double>(tMs) * _w[0] - _w[1];
- if (DelayChangeDetection(residual) &&
- _packetCount >= _startUpFilterDelayInPackets)
- {
- // A sudden change of average network delay has been detected.
- // Force the filter to adjust its offset parameter by changing
- // the offset uncertainty. Don't do this during startup.
- _pP[1][1] = _pP11;
- }
-
- if (_prevUnwrappedTimestamp >= 0 &&
- unwrapped_ts90khz < _prevUnwrappedTimestamp)
- {
- // Drop reordered frames.
- _rwLock->ReleaseLockExclusive();
- return;
- }
-
- //T = [t(k) 1]';
- //that = T'*w;
- //K = P*T/(lambda + T'*P*T);
- double K[2];
- K[0] = _pP[0][0] * tMs + _pP[0][1];
- K[1] = _pP[1][0] * tMs + _pP[1][1];
- double TPT = _lambda + tMs * K[0] + K[1];
- K[0] /= TPT;
- K[1] /= TPT;
- //w = w + K*(ts(k) - that);
- _w[0] = _w[0] + K[0] * residual;
- _w[1] = _w[1] + K[1] * residual;
- //P = 1/lambda*(P - K*T'*P);
- double p00 = 1 / _lambda *
- (_pP[0][0] - (K[0] * tMs * _pP[0][0] + K[0] * _pP[1][0]));
- double p01 = 1 / _lambda *
- (_pP[0][1] - (K[0] * tMs * _pP[0][1] + K[0] * _pP[1][1]));
- _pP[1][0] = 1 / _lambda *
- (_pP[1][0] - (K[1] * tMs * _pP[0][0] + K[1] * _pP[1][0]));
- _pP[1][1] = 1 / _lambda *
- (_pP[1][1] - (K[1] * tMs * _pP[0][1] + K[1] * _pP[1][1]));
- _pP[0][0] = p00;
- _pP[0][1] = p01;
- _prevUnwrappedTimestamp = unwrapped_ts90khz;
- if (_packetCount < _startUpFilterDelayInPackets)
- {
- _packetCount++;
- }
+void TimestampExtrapolator::Update(int64_t tMs, uint32_t ts90khz) {
+ _rwLock->AcquireLockExclusive();
+ if (tMs - _prevMs > 10e3) {
+ // Ten seconds without a complete frame.
+ // Reset the extrapolator
_rwLock->ReleaseLockExclusive();
+ Reset(tMs);
+ _rwLock->AcquireLockExclusive();
+ } else {
+ _prevMs = tMs;
+ }
+
+ // Remove offset to prevent badly scaled matrices
+ tMs -= _startMs;
+
+ CheckForWrapArounds(ts90khz);
+
+ int64_t unwrapped_ts90khz =
+ static_cast<int64_t>(ts90khz) +
+ _wrapArounds * ((static_cast<int64_t>(1) << 32) - 1);
+
+ if (_firstAfterReset) {
+ // Make an initial guess of the offset,
+ // should be almost correct since tMs - _startMs
+ // should about zero at this time.
+ _w[1] = -_w[0] * tMs;
+ _firstTimestamp = unwrapped_ts90khz;
+ _firstAfterReset = false;
+ }
+
+ double residual = (static_cast<double>(unwrapped_ts90khz) - _firstTimestamp) -
+ static_cast<double>(tMs) * _w[0] - _w[1];
+ if (DelayChangeDetection(residual) &&
+ _packetCount >= _startUpFilterDelayInPackets) {
+ // A sudden change of average network delay has been detected.
+ // Force the filter to adjust its offset parameter by changing
+ // the offset uncertainty. Don't do this during startup.
+ _pP[1][1] = _pP11;
+ }
+
+ if (_prevUnwrappedTimestamp >= 0 &&
+ unwrapped_ts90khz < _prevUnwrappedTimestamp) {
+ // Drop reordered frames.
+ _rwLock->ReleaseLockExclusive();
+ return;
+ }
+
+ // T = [t(k) 1]';
+ // that = T'*w;
+ // K = P*T/(lambda + T'*P*T);
+ double K[2];
+ K[0] = _pP[0][0] * tMs + _pP[0][1];
+ K[1] = _pP[1][0] * tMs + _pP[1][1];
+ double TPT = _lambda + tMs * K[0] + K[1];
+ K[0] /= TPT;
+ K[1] /= TPT;
+ // w = w + K*(ts(k) - that);
+ _w[0] = _w[0] + K[0] * residual;
+ _w[1] = _w[1] + K[1] * residual;
+ // P = 1/lambda*(P - K*T'*P);
+ double p00 =
+ 1 / _lambda * (_pP[0][0] - (K[0] * tMs * _pP[0][0] + K[0] * _pP[1][0]));
+ double p01 =
+ 1 / _lambda * (_pP[0][1] - (K[0] * tMs * _pP[0][1] + K[0] * _pP[1][1]));
+ _pP[1][0] =
+ 1 / _lambda * (_pP[1][0] - (K[1] * tMs * _pP[0][0] + K[1] * _pP[1][0]));
+ _pP[1][1] =
+ 1 / _lambda * (_pP[1][1] - (K[1] * tMs * _pP[0][1] + K[1] * _pP[1][1]));
+ _pP[0][0] = p00;
+ _pP[0][1] = p01;
+ _prevUnwrappedTimestamp = unwrapped_ts90khz;
+ if (_packetCount < _startUpFilterDelayInPackets) {
+ _packetCount++;
+ }
+ _rwLock->ReleaseLockExclusive();
}
-int64_t
-TimestampExtrapolator::ExtrapolateLocalTime(uint32_t timestamp90khz)
-{
- ReadLockScoped rl(*_rwLock);
- int64_t localTimeMs = 0;
- CheckForWrapArounds(timestamp90khz);
- double unwrapped_ts90khz = static_cast<double>(timestamp90khz) +
- _wrapArounds * ((static_cast<int64_t>(1) << 32) - 1);
- if (_packetCount == 0)
- {
- localTimeMs = -1;
- }
- else if (_packetCount < _startUpFilterDelayInPackets)
- {
- localTimeMs = _prevMs + static_cast<int64_t>(
+int64_t TimestampExtrapolator::ExtrapolateLocalTime(uint32_t timestamp90khz) {
+ ReadLockScoped rl(*_rwLock);
+ int64_t localTimeMs = 0;
+ CheckForWrapArounds(timestamp90khz);
+ double unwrapped_ts90khz =
+ static_cast<double>(timestamp90khz) +
+ _wrapArounds * ((static_cast<int64_t>(1) << 32) - 1);
+ if (_packetCount == 0) {
+ localTimeMs = -1;
+ } else if (_packetCount < _startUpFilterDelayInPackets) {
+ localTimeMs =
+ _prevMs +
+ static_cast<int64_t>(
static_cast<double>(unwrapped_ts90khz - _prevUnwrappedTimestamp) /
- 90.0 + 0.5);
+ 90.0 +
+ 0.5);
+ } else {
+ if (_w[0] < 1e-3) {
+ localTimeMs = _startMs;
+ } else {
+ double timestampDiff =
+ unwrapped_ts90khz - static_cast<double>(_firstTimestamp);
+ localTimeMs = static_cast<int64_t>(static_cast<double>(_startMs) +
+ (timestampDiff - _w[1]) / _w[0] + 0.5);
}
- else
- {
- if (_w[0] < 1e-3)
- {
- localTimeMs = _startMs;
- }
- else
- {
- double timestampDiff = unwrapped_ts90khz -
- static_cast<double>(_firstTimestamp);
- localTimeMs = static_cast<int64_t>(
- static_cast<double>(_startMs) + (timestampDiff - _w[1]) /
- _w[0] + 0.5);
- }
- }
- return localTimeMs;
+ }
+ return localTimeMs;
}
-// Investigates if the timestamp clock has overflowed since the last timestamp and
-// keeps track of the number of wrap arounds since reset.
-void
-TimestampExtrapolator::CheckForWrapArounds(uint32_t ts90khz)
-{
- if (_prevWrapTimestamp == -1)
- {
- _prevWrapTimestamp = ts90khz;
- return;
- }
- if (ts90khz < _prevWrapTimestamp)
- {
- // This difference will probably be less than -2^31 if we have had a wrap around
- // (e.g. timestamp = 1, _previousTimestamp = 2^32 - 1). Since it is casted to a Word32,
- // it should be positive.
- if (static_cast<int32_t>(ts90khz - _prevWrapTimestamp) > 0)
- {
- // Forward wrap around
- _wrapArounds++;
- }
- }
- // This difference will probably be less than -2^31 if we have had a backward wrap around.
- // Since it is casted to a Word32, it should be positive.
- else if (static_cast<int32_t>(_prevWrapTimestamp - ts90khz) > 0)
- {
- // Backward wrap around
- _wrapArounds--;
- }
+// Investigates if the timestamp clock has overflowed since the last timestamp
+// and keeps track of the number of wrap arounds since reset.
+void TimestampExtrapolator::CheckForWrapArounds(uint32_t ts90khz) {
+ if (_prevWrapTimestamp == -1) {
_prevWrapTimestamp = ts90khz;
-}
-
-bool
-TimestampExtrapolator::DelayChangeDetection(double error)
-{
- // CUSUM detection of sudden delay changes
- error = (error > 0) ? std::min(error, _accMaxError) :
- std::max(error, -_accMaxError);
- _detectorAccumulatorPos =
- std::max(_detectorAccumulatorPos + error - _accDrift, (double)0);
- _detectorAccumulatorNeg =
- std::min(_detectorAccumulatorNeg + error + _accDrift, (double)0);
- if (_detectorAccumulatorPos > _alarmThreshold || _detectorAccumulatorNeg < -_alarmThreshold)
- {
- // Alarm
- _detectorAccumulatorPos = _detectorAccumulatorNeg = 0;
- return true;
+ return;
+ }
+ if (ts90khz < _prevWrapTimestamp) {
+ // This difference will probably be less than -2^31 if we have had a wrap
+ // around (e.g. timestamp = 1, _previousTimestamp = 2^32 - 1). Since it is
+ // casted to a Word32, it should be positive.
+ if (static_cast<int32_t>(ts90khz - _prevWrapTimestamp) > 0) {
+ // Forward wrap around
+ _wrapArounds++;
}
- return false;
+ }
+ // This difference will probably be less than -2^31 if we have had a backward
+ // wrap around. Since it is casted to a Word32, it should be positive.
+ else if (static_cast<int32_t>(_prevWrapTimestamp - ts90khz) > 0) {
+ // Backward wrap around
+ _wrapArounds--;
+ }
+ _prevWrapTimestamp = ts90khz;
}
+bool TimestampExtrapolator::DelayChangeDetection(double error) {
+ // CUSUM detection of sudden delay changes
+ error = (error > 0) ? std::min(error, _accMaxError)
+ : std::max(error, -_accMaxError);
+ _detectorAccumulatorPos =
+ std::max(_detectorAccumulatorPos + error - _accDrift, (double)0);
+ _detectorAccumulatorNeg =
+ std::min(_detectorAccumulatorNeg + error + _accDrift, (double)0);
+ if (_detectorAccumulatorPos > _alarmThreshold ||
+ _detectorAccumulatorNeg < -_alarmThreshold) {
+ // Alarm
+ _detectorAccumulatorPos = _detectorAccumulatorNeg = 0;
+ return true;
+ }
+ return false;
}
+
+} // namespace webrtc