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

Unified Diff: media/base/audio_latency.cc

Issue 2750543003: Support AudioContextOptions latencyHint as double. (Closed)
Patch Set: Fix audiocontextoptions LayoutTest. Created 3 years, 9 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
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

Powered by Google App Engine
This is Rietveld 408576698