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

Unified Diff: third_party/WebKit/Source/modules/webaudio/AudioContextTest.cpp

Issue 2750543003: Support AudioContextOptions latencyHint as double. (Closed)
Patch Set: Refactor audiocontextoptions LayoutTest. 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
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/AudioContextOptions.idl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webaudio/AudioContextTest.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioContextTest.cpp b/third_party/WebKit/Source/modules/webaudio/AudioContextTest.cpp
index 0f2d7fca718cfac611db728e51e8b5c23206b3be..9389f7f20b2fd1c824e7c1164629dd3da8eb1df3 100644
--- a/third_party/WebKit/Source/modules/webaudio/AudioContextTest.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/AudioContextTest.cpp
@@ -40,15 +40,24 @@ class AudioContextTestPlatform : public TestingPlatformSupport {
const WebString& device_id,
const WebSecurityOrigin&) override {
double buffer_size = 0;
+ const double interactive_size = AudioHardwareBufferSize();
+ const double balanced_size = AudioHardwareBufferSize() * 2;
+ const double playback_size = AudioHardwareBufferSize() * 4;
switch (latency_hint.Category()) {
case WebAudioLatencyHint::kCategoryInteractive:
- buffer_size = AudioHardwareBufferSize();
+ buffer_size = interactive_size;
break;
case WebAudioLatencyHint::kCategoryBalanced:
- buffer_size = AudioHardwareBufferSize() * 2;
+ buffer_size = balanced_size;
break;
case WebAudioLatencyHint::kCategoryPlayback:
- buffer_size = AudioHardwareBufferSize() * 4;
+ buffer_size = playback_size;
+ break;
+ case WebAudioLatencyHint::kCategoryExact:
+ buffer_size =
+ clampTo(latency_hint.Seconds() * AudioHardwareSampleRate(),
+ static_cast<double>(AudioHardwareBufferSize()),
+ static_cast<double>(playback_size));
break;
default:
NOTREACHED();
@@ -100,6 +109,34 @@ TEST_F(AudioContextTest, AudioContextOptions_WebAudioLatencyHint) {
AudioContext* playback_context = AudioContext::Create(
GetDocument(), playback_options, ASSERT_NO_EXCEPTION);
EXPECT_GT(playback_context->baseLatency(), balanced_context->baseLatency());
+
+ AudioContextOptions exact_too_small_options;
+ exact_too_small_options.setLatencyHint(
+ AudioContextLatencyCategoryOrDouble::fromDouble(
+ interactive_context->baseLatency() / 2));
+ AudioContext* exact_too_small_context = AudioContext::Create(
+ GetDocument(), exact_too_small_options, ASSERT_NO_EXCEPTION);
+ EXPECT_EQ(exact_too_small_context->baseLatency(),
+ interactive_context->baseLatency());
+
+ const double exact_latency_sec =
+ (interactive_context->baseLatency() + playback_context->baseLatency()) /
+ 2;
+ AudioContextOptions exact_ok_options;
+ exact_ok_options.setLatencyHint(
+ AudioContextLatencyCategoryOrDouble::fromDouble(exact_latency_sec));
+ AudioContext* exact_ok_context = AudioContext::Create(
+ GetDocument(), exact_ok_options, ASSERT_NO_EXCEPTION);
+ EXPECT_EQ(exact_ok_context->baseLatency(), exact_latency_sec);
+
+ AudioContextOptions exact_too_big_options;
+ exact_too_big_options.setLatencyHint(
+ AudioContextLatencyCategoryOrDouble::fromDouble(
+ playback_context->baseLatency() * 2));
+ AudioContext* exact_too_big_context = AudioContext::Create(
+ GetDocument(), exact_too_big_options, ASSERT_NO_EXCEPTION);
+ EXPECT_EQ(exact_too_big_context->baseLatency(),
+ playback_context->baseLatency());
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/AudioContextOptions.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698