Chromium Code Reviews| Index: media/base/audio_latency.cc |
| diff --git a/media/base/audio_latency.cc b/media/base/audio_latency.cc |
| index 5d37edf415213ff72aeb6e9753927abf1dfb8894..7c185ef2cd4ab966f09e75354f0be896f9f7a2b4 100644 |
| --- a/media/base/audio_latency.cc |
| +++ b/media/base/audio_latency.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/logging.h" |
| #include "build/build_config.h" |
| +#include "media/base/audio_parameters.h" |
| namespace media { |
| @@ -126,4 +127,19 @@ int AudioLatency::GetInteractiveBufferSize(int hardware_buffer_size) { |
| return hardware_buffer_size; |
| } |
| +int AudioLatency::GetExactBufferSize(double duration_in_seconds, |
|
DaleCurtis
2017/03/28 17:34:07
This should take TimeDelta since it's a chromium c
Andrew MacPherson
2017/03/29 08:34:09
Done.
|
| + const AudioParameters& hardware_params) { |
| + const double requested_buffer_size = |
| + duration_in_seconds * hardware_params.sample_rate(); |
| + |
| + // Round up the requested size to the nearest multiple of the hardware size |
| + const int buffer_size = std::ceil(std::max(requested_buffer_size, 1.0) / |
| + hardware_params.frames_per_buffer()) * |
| + hardware_params.frames_per_buffer(); |
| + |
| + return std::max(std::min(buffer_size, GetHighLatencyBufferSize( |
|
DaleCurtis
2017/03/28 17:34:07
Hmm, I don't think these methods should call each
Andrew MacPherson
2017/03/29 08:34:09
Ok, I've modified this as you suggest to just use
|
| + hardware_params.sample_rate(), 0)), |
| + static_cast<int>(hardware_params.frames_per_buffer())); |
| +} |
| + |
| } // namespace media |