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

Unified Diff: media/filters/audio_renderer_algorithm.cc

Issue 2127413002: Check for bad floating point rounding in audio_renderer_algorithm. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify. Created 4 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_renderer_algorithm.cc
diff --git a/media/filters/audio_renderer_algorithm.cc b/media/filters/audio_renderer_algorithm.cc
index df2e53697a22a7a847405ef902b9c1aebda5063a..ebe334a0f1a0c76c1063ed1c79512cc36fd4c6bb 100644
--- a/media/filters/audio_renderer_algorithm.cc
+++ b/media/filters/audio_renderer_algorithm.cc
@@ -146,6 +146,7 @@ int AudioRendererAlgorithm::FillBuffer(AudioBus* dest,
if (playback_rate == 0)
return 0;
+ DCHECK_GT(playback_rate, 0);
DCHECK_EQ(channels_, dest->channels());
// Optimize the muted case to issue a single clear instead of performing
@@ -160,7 +161,10 @@ int AudioRendererAlgorithm::FillBuffer(AudioBus* dest,
// only skip over complete frames, so a partial frame may remain for next
// time.
muted_partial_frame_ += frames_to_render * playback_rate;
- int seek_frames = static_cast<int>(muted_partial_frame_);
+ // Handle the case where muted_partial_frame_ rounds up to
+ // audio_buffer_.frames()+1.
+ int seek_frames = std::min(static_cast<int>(muted_partial_frame_),
+ audio_buffer_.frames());
dest->ZeroFramesPartial(dest_offset, frames_to_render);
audio_buffer_.SeekFrames(seek_frames);
« 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