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

Unified Diff: media/filters/audio_clock.cc

Issue 1230583010: Add stronger DCHECK for front and back timestamp calculations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/audio_clock.cc
diff --git a/media/filters/audio_clock.cc b/media/filters/audio_clock.cc
index 03af719bcb2348bb30c022f3de87d35f20483534..d4fea149e0c2b228a60252b5517aa93d0839c564 100644
--- a/media/filters/audio_clock.cc
+++ b/media/filters/audio_clock.cc
@@ -42,6 +42,7 @@ void AudioClock::WroteAudio(int frames_written,
//
// The ordering of compute -> push -> pop eliminates unnecessary memory
// reallocations in cases where |buffered_| gets emptied.
+ const int64_t original_buffered_frames = total_buffered_frames_;
jrummell 2015/07/10 00:32:57 Since this is only used in the DCHECK, will a rele
DaleCurtis 2015/07/10 00:34:22 Nope, the DCHECK still counts as usage.
int64_t frames_played =
std::max(INT64_C(0), total_buffered_frames_ - delay_frames);
front_timestamp_ += ComputeBufferedMediaTime(frames_played);
@@ -52,6 +53,16 @@ void AudioClock::WroteAudio(int frames_written,
back_timestamp_ += base::TimeDelta::FromMicroseconds(
frames_written * playback_rate * microseconds_per_frame_);
+ // Ensure something crazy hasn't happened to desync the front and back values.
+ DCHECK_LE(front_timestamp_.InMicroseconds(), back_timestamp_.InMicroseconds())
+ << "frames_written=" << frames_written
+ << ", frames_requested=" << frames_requested
+ << ", delay_frames=" << delay_frames
+ << ", playback_rate=" << playback_rate
+ << ", frames_played=" << frames_played
+ << ", original_buffered_frames=" << original_buffered_frames
+ << ", total_buffered_frames_=" << total_buffered_frames_;
+
// Update cached values.
double scaled_frames = 0;
double scaled_frames_at_same_rate = 0;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698