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

Unified Diff: media/base/audio_latency.cc

Issue 2750543003: Support AudioContextOptions latencyHint as double. (Closed)
Patch Set: Update TODO with userid and crbug. Created 3 years, 8 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..5de67096db2cb51018baae64b01ede28efc7f01c 100644
--- a/media/base/audio_latency.cc
+++ b/media/base/audio_latency.cc
@@ -9,6 +9,7 @@
#include <algorithm>
#include "base/logging.h"
+#include "base/time/time.h"
#include "build/build_config.h"
namespace media {
@@ -126,4 +127,17 @@ int AudioLatency::GetInteractiveBufferSize(int hardware_buffer_size) {
return hardware_buffer_size;
}
+int AudioLatency::GetExactBufferSize(base::TimeDelta duration,
+ int sample_rate,
+ int hardware_buffer_size) {
+ const double requested_buffer_size = duration.InSecondsF() * sample_rate;
+
+ // Round the requested size to the nearest multiple of the hardware size
+ const int buffer_size =
+ std::round(std::max(requested_buffer_size, 1.0) / hardware_buffer_size) *
o1ka 2017/04/06 16:02:30 DCHECK_NE(0, hardware_buffer_size) at l.134?
Andrew MacPherson 2017/04/07 06:59:03 Done.
+ hardware_buffer_size;
+
+ return std::max(buffer_size, hardware_buffer_size);
+}
+
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698