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

Unified Diff: webrtc/modules/audio_coding/neteq/delay_peak_detector.cc

Issue 2085233002: NetEq: Fix a bug in DelayPeakDetector causing asserts to trigger (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | webrtc/modules/audio_coding/neteq/delay_peak_detector_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_coding/neteq/delay_peak_detector.cc
diff --git a/webrtc/modules/audio_coding/neteq/delay_peak_detector.cc b/webrtc/modules/audio_coding/neteq/delay_peak_detector.cc
index ce9133bdaed3307805373b70262df9711083ae08..10535e23f53c816c987b2b60280cf5a7113b87bc 100644
--- a/webrtc/modules/audio_coding/neteq/delay_peak_detector.cc
+++ b/webrtc/modules/audio_coding/neteq/delay_peak_detector.cc
@@ -77,27 +77,29 @@ bool DelayPeakDetector::Update(int inter_arrival_time, int target_level) {
if (!peak_period_stopwatch_) {
// This is the first peak. Reset the period counter.
peak_period_stopwatch_ = tick_timer_->GetNewStopwatch();
- } else if (peak_period_stopwatch_->ElapsedMs() <= kMaxPeakPeriodMs) {
- // This is not the first peak, and the period is valid.
- // Store peak data in the vector.
- Peak peak_data;
- peak_data.period_ms = peak_period_stopwatch_->ElapsedMs();
- peak_data.peak_height_packets = inter_arrival_time;
- peak_history_.push_back(peak_data);
- while (peak_history_.size() > kMaxNumPeaks) {
- // Delete the oldest data point.
- peak_history_.pop_front();
+ } else if (peak_period_stopwatch_->ElapsedMs() > 0) {
+ if (peak_period_stopwatch_->ElapsedMs() <= kMaxPeakPeriodMs) {
+ // This is not the first peak, and the period is valid.
+ // Store peak data in the vector.
+ Peak peak_data;
+ peak_data.period_ms = peak_period_stopwatch_->ElapsedMs();
+ peak_data.peak_height_packets = inter_arrival_time;
+ peak_history_.push_back(peak_data);
+ while (peak_history_.size() > kMaxNumPeaks) {
+ // Delete the oldest data point.
+ peak_history_.pop_front();
+ }
+ peak_period_stopwatch_ = tick_timer_->GetNewStopwatch();
+ } else if (peak_period_stopwatch_->ElapsedMs() <= 2 * kMaxPeakPeriodMs) {
+ // Invalid peak due to too long period. Reset period counter and start
+ // looking for next peak.
+ peak_period_stopwatch_ = tick_timer_->GetNewStopwatch();
+ } else {
+ // More than 2 times the maximum period has elapsed since the last peak
+ // was registered. It seams that the network conditions have changed.
+ // Reset the peak statistics.
+ Reset();
}
- peak_period_stopwatch_ = tick_timer_->GetNewStopwatch();
- } else if (peak_period_stopwatch_->ElapsedMs() <= 2 * kMaxPeakPeriodMs) {
- // Invalid peak due to too long period. Reset period counter and start
- // looking for next peak.
- peak_period_stopwatch_ = tick_timer_->GetNewStopwatch();
- } else {
- // More than 2 times the maximum period has elapsed since the last peak
- // was registered. It seams that the network conditions have changed.
- // Reset the peak statistics.
- Reset();
}
}
return CheckPeakConditions();
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/neteq/delay_peak_detector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698