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

Side by Side Diff: content/shell/renderer/layout_test/layout_test_content_renderer_client.cc

Issue 2750543003: Support AudioContextOptions latencyHint as double. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/shell/renderer/layout_test/layout_test_content_renderer_client .h" 5 #include "content/shell/renderer/layout_test/layout_test_content_renderer_client .h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/debugger.h" 9 #include "base/debug/debugger.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 14 matching lines...) Expand all
25 #include "content/shell/renderer/layout_test/test_media_stream_renderer_factory. h" 25 #include "content/shell/renderer/layout_test/test_media_stream_renderer_factory. h"
26 #include "content/shell/renderer/shell_render_view_observer.h" 26 #include "content/shell/renderer/shell_render_view_observer.h"
27 #include "content/shell/test_runner/mock_credential_manager_client.h" 27 #include "content/shell/test_runner/mock_credential_manager_client.h"
28 #include "content/shell/test_runner/web_frame_test_proxy.h" 28 #include "content/shell/test_runner/web_frame_test_proxy.h"
29 #include "content/shell/test_runner/web_test_interfaces.h" 29 #include "content/shell/test_runner/web_test_interfaces.h"
30 #include "content/shell/test_runner/web_test_runner.h" 30 #include "content/shell/test_runner/web_test_runner.h"
31 #include "content/shell/test_runner/web_view_test_proxy.h" 31 #include "content/shell/test_runner/web_view_test_proxy.h"
32 #include "content/test/mock_webclipboard_impl.h" 32 #include "content/test/mock_webclipboard_impl.h"
33 #include "gin/modules/module_registry.h" 33 #include "gin/modules/module_registry.h"
34 #include "media/media_features.h" 34 #include "media/media_features.h"
35 #include "third_party/WebKit/public/platform/WebAudioLatencyHint.h"
35 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" 36 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h"
36 #include "third_party/WebKit/public/web/WebFrameWidget.h" 37 #include "third_party/WebKit/public/web/WebFrameWidget.h"
37 #include "third_party/WebKit/public/web/WebKit.h" 38 #include "third_party/WebKit/public/web/WebKit.h"
38 #include "third_party/WebKit/public/web/WebPluginParams.h" 39 #include "third_party/WebKit/public/web/WebPluginParams.h"
39 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 40 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
40 #include "third_party/WebKit/public/web/WebTestingSupport.h" 41 #include "third_party/WebKit/public/web/WebTestingSupport.h"
41 #include "third_party/WebKit/public/web/WebView.h" 42 #include "third_party/WebKit/public/web/WebView.h"
42 #include "ui/gfx/icc_profile.h" 43 #include "ui/gfx/icc_profile.h"
43 #include "v8/include/v8.h" 44 #include "v8/include/v8.h"
44 45
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 188 }
188 189
189 WebMIDIAccessor* 190 WebMIDIAccessor*
190 LayoutTestContentRendererClient::OverrideCreateMIDIAccessor( 191 LayoutTestContentRendererClient::OverrideCreateMIDIAccessor(
191 WebMIDIAccessorClient* client) { 192 WebMIDIAccessorClient* client) {
192 test_runner::WebTestInterfaces* interfaces = 193 test_runner::WebTestInterfaces* interfaces =
193 LayoutTestRenderThreadObserver::GetInstance()->test_interfaces(); 194 LayoutTestRenderThreadObserver::GetInstance()->test_interfaces();
194 return interfaces->CreateMIDIAccessor(client); 195 return interfaces->CreateMIDIAccessor(client);
195 } 196 }
196 197
197 WebAudioDevice* LayoutTestContentRendererClient::OverrideCreateAudioDevice() { 198 WebAudioDevice* LayoutTestContentRendererClient::OverrideCreateAudioDevice(
199 const blink::WebAudioLatencyHint& latency_hint) {
200 const double hw_buffer_size = 128;
201 const double hw_sample_rate = 44100;
Raymond Toy 2017/03/14 15:19:39 Where do these numbers come from? And why these p
Andrew MacPherson 2017/03/15 15:08:17 These are completely arbitrary, my understanding i
202 double buffer_size = 0;
203 switch (latency_hint.category()) {
204 case blink::WebAudioLatencyHint::kCategoryInteractive:
205 buffer_size = hw_buffer_size;
206 break;
207 case blink::WebAudioLatencyHint::kCategoryBalanced:
208 buffer_size = hw_buffer_size * 2;
209 break;
210 case blink::WebAudioLatencyHint::kCategoryPlayback:
211 buffer_size = hw_buffer_size * 4;
212 break;
213 case blink::WebAudioLatencyHint::kCategoryExact:
214 buffer_size = std::max(hw_buffer_size,
215 std::min(latency_hint.seconds() * hw_sample_rate,
216 hw_buffer_size * 4));
217 break;
218 default:
219 NOTREACHED();
220 break;
221 }
198 test_runner::WebTestInterfaces* interfaces = 222 test_runner::WebTestInterfaces* interfaces =
199 LayoutTestRenderThreadObserver::GetInstance()->test_interfaces(); 223 LayoutTestRenderThreadObserver::GetInstance()->test_interfaces();
200 return interfaces->CreateAudioDevice(44100, 128); 224 return interfaces->CreateAudioDevice(hw_sample_rate, buffer_size);
201 } 225 }
202 226
203 WebClipboard* LayoutTestContentRendererClient::OverrideWebClipboard() { 227 WebClipboard* LayoutTestContentRendererClient::OverrideWebClipboard() {
204 if (!clipboard_) 228 if (!clipboard_)
205 clipboard_.reset(new MockWebClipboardImpl); 229 clipboard_.reset(new MockWebClipboardImpl);
206 return clipboard_.get(); 230 return clipboard_.get();
207 } 231 }
208 232
209 WebThemeEngine* LayoutTestContentRendererClient::OverrideThemeEngine() { 233 WebThemeEngine* LayoutTestContentRendererClient::OverrideThemeEngine() {
210 return LayoutTestRenderThreadObserver::GetInstance() 234 return LayoutTestRenderThreadObserver::GetInstance()
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 switches::kStableReleaseMode)) { 302 switches::kStableReleaseMode)) {
279 blink::WebRuntimeFeatures::enableTestOnlyFeatures(true); 303 blink::WebRuntimeFeatures::enableTestOnlyFeatures(true);
280 } 304 }
281 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 305 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
282 switches::kEnableFontAntialiasing)) { 306 switches::kEnableFontAntialiasing)) {
283 blink::setFontAntialiasingEnabledForTest(true); 307 blink::setFontAntialiasingEnabledForTest(true);
284 } 308 }
285 } 309 }
286 310
287 } // namespace content 311 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698