Chromium Code Reviews| Index: media/base/audio_buffer.cc |
| diff --git a/media/base/audio_buffer.cc b/media/base/audio_buffer.cc |
| index 0bf37209b2b66489ff568547e5a4b9f363415c76..f21772ad6729501f7a651894824b5d420e5f584c 100644 |
| --- a/media/base/audio_buffer.cc |
| +++ b/media/base/audio_buffer.cc |
| @@ -4,6 +4,8 @@ |
| #include "media/base/audio_buffer.h" |
| +#include <cmath> |
| + |
| #include "base/logging.h" |
| #include "media/base/audio_bus.h" |
| #include "media/base/buffers.h" |
| @@ -220,10 +222,9 @@ void AudioBuffer::TrimStart(int frames_to_trim) { |
| CHECK_LE(frames_to_trim, adjusted_frame_count_); |
| // Adjust timestamp_ and duration_ to reflect the smaller number of frames. |
| - double offset = static_cast<double>(duration_.InMicroseconds()) * |
| - frames_to_trim / adjusted_frame_count_; |
| - base::TimeDelta offset_as_time = |
| - base::TimeDelta::FromMicroseconds(static_cast<int64>(offset)); |
| + const base::TimeDelta offset_as_time = base::TimeDelta::FromMicroseconds( |
| + floor(static_cast<double>(duration_.InMicroseconds()) * frames_to_trim / |
|
acolwell GONE FROM CHROMIUM
2014/02/24 21:46:11
nit: Why can't you use (duration_ * frames_to_trim
DaleCurtis
2014/02/26 02:38:45
Removed in favor of using the AudioTimestampHelper
|
| + adjusted_frame_count_)); |
| timestamp_ += offset_as_time; |
| duration_ -= offset_as_time; |
| @@ -238,11 +239,9 @@ void AudioBuffer::TrimEnd(int frames_to_trim) { |
| CHECK_LE(frames_to_trim, adjusted_frame_count_); |
| // Adjust duration_ only to reflect the smaller number of frames. |
| - double offset = static_cast<double>(duration_.InMicroseconds()) * |
| - frames_to_trim / adjusted_frame_count_; |
| - base::TimeDelta offset_as_time = |
| - base::TimeDelta::FromMicroseconds(static_cast<int64>(offset)); |
| - duration_ -= offset_as_time; |
| + duration_ -= base::TimeDelta::FromMicroseconds( |
|
acolwell GONE FROM CHROMIUM
2014/02/24 21:46:11
Why does this computation differ from the one abov
DaleCurtis
2014/02/26 02:38:45
Ditto.
|
| + ceil(static_cast<double>(duration_.InMicroseconds()) * frames_to_trim / |
| + adjusted_frame_count_)); |
| // Finally adjust the number of frames in this buffer. |
| adjusted_frame_count_ -= frames_to_trim; |