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

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: 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 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 13 matching lines...) Expand all
24 #include "content/shell/renderer/layout_test/layout_test_render_thread_observer. h" 24 #include "content/shell/renderer/layout_test/layout_test_render_thread_observer. h"
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/base/audio_latency.h"
34 #include "media/media_features.h" 35 #include "media/media_features.h"
36 #include "third_party/WebKit/public/platform/WebAudioLatencyHint.h"
35 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" 37 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h"
36 #include "third_party/WebKit/public/web/WebFrameWidget.h" 38 #include "third_party/WebKit/public/web/WebFrameWidget.h"
37 #include "third_party/WebKit/public/web/WebKit.h" 39 #include "third_party/WebKit/public/web/WebKit.h"
38 #include "third_party/WebKit/public/web/WebPluginParams.h" 40 #include "third_party/WebKit/public/web/WebPluginParams.h"
39 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 41 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
40 #include "third_party/WebKit/public/web/WebTestingSupport.h" 42 #include "third_party/WebKit/public/web/WebTestingSupport.h"
41 #include "third_party/WebKit/public/web/WebView.h" 43 #include "third_party/WebKit/public/web/WebView.h"
42 #include "ui/gfx/icc_profile.h" 44 #include "ui/gfx/icc_profile.h"
43 #include "v8/include/v8.h" 45 #include "v8/include/v8.h"
44 46
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 189 }
188 190
189 WebMIDIAccessor* 191 WebMIDIAccessor*
190 LayoutTestContentRendererClient::OverrideCreateMIDIAccessor( 192 LayoutTestContentRendererClient::OverrideCreateMIDIAccessor(
191 WebMIDIAccessorClient* client) { 193 WebMIDIAccessorClient* client) {
192 test_runner::WebTestInterfaces* interfaces = 194 test_runner::WebTestInterfaces* interfaces =
193 LayoutTestRenderThreadObserver::GetInstance()->test_interfaces(); 195 LayoutTestRenderThreadObserver::GetInstance()->test_interfaces();
194 return interfaces->CreateMIDIAccessor(client); 196 return interfaces->CreateMIDIAccessor(client);
195 } 197 }
196 198
197 WebAudioDevice* LayoutTestContentRendererClient::OverrideCreateAudioDevice() { 199 WebAudioDevice* LayoutTestContentRendererClient::OverrideCreateAudioDevice(
200 const blink::WebAudioLatencyHint& latency_hint) {
201 const double hw_buffer_size = 128;
202 const double hw_sample_rate = 44100;
203 double buffer_size = 0;
204 switch (latency_hint.Category()) {
205 case blink::WebAudioLatencyHint::kCategoryInteractive:
206 buffer_size =
207 media::AudioLatency::GetInteractiveBufferSize(hw_buffer_size);
208 break;
209 case blink::WebAudioLatencyHint::kCategoryBalanced:
210 buffer_size =
211 media::AudioLatency::GetRtcBufferSize(hw_sample_rate, hw_buffer_size);
212 break;
213 case blink::WebAudioLatencyHint::kCategoryPlayback:
214 buffer_size =
215 media::AudioLatency::GetHighLatencyBufferSize(hw_sample_rate, 0);
216 break;
217 case blink::WebAudioLatencyHint::kCategoryExact:
218 // TODO(andrew.macpherson@soundtrap.com): http://crbug.com/708917
219 buffer_size = std::min(
220 4096, media::AudioLatency::GetExactBufferSize(
221 base::TimeDelta::FromSecondsD(latency_hint.Seconds()),
222 hw_sample_rate, hw_buffer_size));
223 break;
224 default:
225 NOTREACHED();
226 break;
227 }
198 test_runner::WebTestInterfaces* interfaces = 228 test_runner::WebTestInterfaces* interfaces =
199 LayoutTestRenderThreadObserver::GetInstance()->test_interfaces(); 229 LayoutTestRenderThreadObserver::GetInstance()->test_interfaces();
200 return interfaces->CreateAudioDevice(44100, 128); 230 return interfaces->CreateAudioDevice(hw_sample_rate, buffer_size);
201 } 231 }
202 232
203 WebClipboard* LayoutTestContentRendererClient::OverrideWebClipboard() { 233 WebClipboard* LayoutTestContentRendererClient::OverrideWebClipboard() {
204 if (!clipboard_) 234 if (!clipboard_)
205 clipboard_.reset(new MockWebClipboardImpl); 235 clipboard_.reset(new MockWebClipboardImpl);
206 return clipboard_.get(); 236 return clipboard_.get();
207 } 237 }
208 238
209 WebThemeEngine* LayoutTestContentRendererClient::OverrideThemeEngine() { 239 WebThemeEngine* LayoutTestContentRendererClient::OverrideThemeEngine() {
210 return LayoutTestRenderThreadObserver::GetInstance() 240 return LayoutTestRenderThreadObserver::GetInstance()
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 switches::kStableReleaseMode)) { 308 switches::kStableReleaseMode)) {
279 blink::WebRuntimeFeatures::EnableTestOnlyFeatures(true); 309 blink::WebRuntimeFeatures::EnableTestOnlyFeatures(true);
280 } 310 }
281 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 311 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
282 switches::kEnableFontAntialiasing)) { 312 switches::kEnableFontAntialiasing)) {
283 blink::SetFontAntialiasingEnabledForTest(true); 313 blink::SetFontAntialiasingEnabledForTest(true);
284 } 314 }
285 } 315 }
286 316
287 } // namespace content 317 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/layout_test/layout_test_content_renderer_client.h ('k') | media/base/audio_latency.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698