OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/renderer_blink_platform_impl.h" | 5 #include "content/renderer/renderer_blink_platform_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 #include "media/filters/stream_parser_factory.h" | 80 #include "media/filters/stream_parser_factory.h" |
81 #include "mojo/common/common_type_converters.h" | 81 #include "mojo/common/common_type_converters.h" |
82 #include "mojo/public/cpp/bindings/associated_group.h" | 82 #include "mojo/public/cpp/bindings/associated_group.h" |
83 #include "ppapi/features/features.h" | 83 #include "ppapi/features/features.h" |
84 #include "services/service_manager/public/cpp/interface_provider.h" | 84 #include "services/service_manager/public/cpp/interface_provider.h" |
85 #include "storage/common/database/database_identifier.h" | 85 #include "storage/common/database/database_identifier.h" |
86 #include "storage/common/quota/quota_types.h" | 86 #include "storage/common/quota/quota_types.h" |
87 #include "third_party/WebKit/public/platform/BlameContext.h" | 87 #include "third_party/WebKit/public/platform/BlameContext.h" |
88 #include "third_party/WebKit/public/platform/FilePathConversion.h" | 88 #include "third_party/WebKit/public/platform/FilePathConversion.h" |
89 #include "third_party/WebKit/public/platform/URLConversion.h" | 89 #include "third_party/WebKit/public/platform/URLConversion.h" |
| 90 #include "third_party/WebKit/public/platform/WebAudioLatencyHint.h" |
90 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" | 91 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" |
91 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" | 92 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" |
92 #include "third_party/WebKit/public/platform/WebFileInfo.h" | 93 #include "third_party/WebKit/public/platform/WebFileInfo.h" |
93 #include "third_party/WebKit/public/platform/WebGamepads.h" | 94 #include "third_party/WebKit/public/platform/WebGamepads.h" |
94 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" | 95 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" |
95 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" | 96 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" |
96 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" | 97 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" |
97 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 98 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
98 #include "third_party/WebKit/public/platform/WebURL.h" | 99 #include "third_party/WebKit/public/platform/WebURL.h" |
99 #include "third_party/WebKit/public/platform/WebVector.h" | 100 #include "third_party/WebKit/public/platform/WebVector.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 #define WebScrollbarBehaviorImpl blink::WebScrollbarBehavior | 136 #define WebScrollbarBehaviorImpl blink::WebScrollbarBehavior |
136 #endif | 137 #endif |
137 | 138 |
138 #if BUILDFLAG(ENABLE_WEBRTC) | 139 #if BUILDFLAG(ENABLE_WEBRTC) |
139 #include "content/renderer/media/rtc_certificate_generator.h" | 140 #include "content/renderer/media/rtc_certificate_generator.h" |
140 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" | 141 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
141 #endif | 142 #endif |
142 | 143 |
143 using blink::Platform; | 144 using blink::Platform; |
144 using blink::WebAudioDevice; | 145 using blink::WebAudioDevice; |
| 146 using blink::WebAudioLatencyHint; |
145 using blink::WebBlobRegistry; | 147 using blink::WebBlobRegistry; |
146 using blink::WebCanvasCaptureHandler; | 148 using blink::WebCanvasCaptureHandler; |
147 using blink::WebDatabaseObserver; | 149 using blink::WebDatabaseObserver; |
148 using blink::WebFileInfo; | 150 using blink::WebFileInfo; |
149 using blink::WebFileSystem; | 151 using blink::WebFileSystem; |
150 using blink::WebGamepad; | 152 using blink::WebGamepad; |
151 using blink::WebGamepads; | 153 using blink::WebGamepads; |
152 using blink::WebIDBFactory; | 154 using blink::WebIDBFactory; |
153 using blink::WebImageCaptureFrameGrabber; | 155 using blink::WebImageCaptureFrameGrabber; |
154 using blink::WebMIDIAccessor; | 156 using blink::WebMIDIAccessor; |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 | 652 |
651 unsigned RendererBlinkPlatformImpl::audioHardwareOutputChannels() { | 653 unsigned RendererBlinkPlatformImpl::audioHardwareOutputChannels() { |
652 return GetAudioHardwareParams().channels(); | 654 return GetAudioHardwareParams().channels(); |
653 } | 655 } |
654 | 656 |
655 WebDatabaseObserver* RendererBlinkPlatformImpl::databaseObserver() { | 657 WebDatabaseObserver* RendererBlinkPlatformImpl::databaseObserver() { |
656 return web_database_observer_impl_.get(); | 658 return web_database_observer_impl_.get(); |
657 } | 659 } |
658 | 660 |
659 WebAudioDevice* RendererBlinkPlatformImpl::createAudioDevice( | 661 WebAudioDevice* RendererBlinkPlatformImpl::createAudioDevice( |
660 size_t buffer_size, | |
661 unsigned input_channels, | 662 unsigned input_channels, |
662 unsigned channels, | 663 unsigned channels, |
663 double sample_rate, | 664 const blink::WebAudioLatencyHint& latency_hint, |
664 WebAudioDevice::RenderCallback* callback, | 665 WebAudioDevice::RenderCallback* callback, |
665 const blink::WebString& input_device_id, | 666 const blink::WebString& input_device_id, |
666 const blink::WebSecurityOrigin& security_origin) { | 667 const blink::WebSecurityOrigin& security_origin) { |
667 // Use a mock for testing. | 668 // Use a mock for testing. |
668 blink::WebAudioDevice* mock_device = | 669 blink::WebAudioDevice* mock_device = |
669 GetContentClient()->renderer()->OverrideCreateAudioDevice(sample_rate); | 670 GetContentClient()->renderer()->OverrideCreateAudioDevice(); |
670 if (mock_device) | 671 if (mock_device) |
671 return mock_device; | 672 return mock_device; |
672 | 673 |
673 // The |channels| does not exactly identify the channel layout of the | 674 // The |channels| does not exactly identify the channel layout of the |
674 // device. The switch statement below assigns a best guess to the channel | 675 // device. The switch statement below assigns a best guess to the channel |
675 // layout based on number of channels. | 676 // layout based on number of channels. |
676 media::ChannelLayout layout = media::CHANNEL_LAYOUT_UNSUPPORTED; | 677 media::ChannelLayout layout = media::CHANNEL_LAYOUT_UNSUPPORTED; |
677 switch (channels) { | 678 switch (channels) { |
678 case 1: | 679 case 1: |
679 layout = media::CHANNEL_LAYOUT_MONO; | 680 layout = media::CHANNEL_LAYOUT_MONO; |
(...skipping 13 matching lines...) Expand all Loading... |
693 case 6: | 694 case 6: |
694 layout = media::CHANNEL_LAYOUT_5_1; | 695 layout = media::CHANNEL_LAYOUT_5_1; |
695 break; | 696 break; |
696 case 7: | 697 case 7: |
697 layout = media::CHANNEL_LAYOUT_7_0; | 698 layout = media::CHANNEL_LAYOUT_7_0; |
698 break; | 699 break; |
699 case 8: | 700 case 8: |
700 layout = media::CHANNEL_LAYOUT_7_1; | 701 layout = media::CHANNEL_LAYOUT_7_1; |
701 break; | 702 break; |
702 default: | 703 default: |
703 // If the layout is not supported (more than 9 channels), falls back to | 704 // TODO need to also pass 'channels' into RendererWebAudioDeviceImpl for |
704 // discrete mode. | 705 // CHANNEL_LAYOUT_DISCRETE |
705 layout = media::CHANNEL_LAYOUT_DISCRETE; | 706 NOTREACHED(); |
706 } | 707 } |
707 | 708 |
708 int session_id = 0; | 709 int session_id = 0; |
709 if (input_device_id.isNull() || | 710 if (input_device_id.isNull() || |
710 !base::StringToInt(base::UTF16ToUTF8( | 711 !base::StringToInt(base::UTF16ToUTF8( |
711 base::StringPiece16(input_device_id)), &session_id)) { | 712 base::StringPiece16(input_device_id)), &session_id)) { |
712 if (input_channels > 0) | 713 if (input_channels > 0) |
713 DLOG(WARNING) << "createAudioDevice(): request for audio input ignored"; | 714 DLOG(WARNING) << "createAudioDevice(): request for audio input ignored"; |
714 | 715 |
715 input_channels = 0; | 716 input_channels = 0; |
716 } | 717 } |
717 | 718 |
718 // For CHANNEL_LAYOUT_DISCRETE, pass the explicit channel count along with | |
719 // the channel layout when creating an |AudioParameters| object. | |
720 media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | |
721 layout, static_cast<int>(sample_rate), 16, | |
722 buffer_size); | |
723 params.set_channels_for_discrete(channels); | |
724 | |
725 return new RendererWebAudioDeviceImpl( | 719 return new RendererWebAudioDeviceImpl( |
726 params, callback, session_id, static_cast<url::Origin>(security_origin)); | 720 layout, latency_hint, callback, session_id, |
| 721 static_cast<url::Origin>(security_origin)); |
727 } | 722 } |
728 | 723 |
729 bool RendererBlinkPlatformImpl::loadAudioResource( | 724 bool RendererBlinkPlatformImpl::loadAudioResource( |
730 blink::WebAudioBus* destination_bus, | 725 blink::WebAudioBus* destination_bus, |
731 const char* audio_file_data, | 726 const char* audio_file_data, |
732 size_t data_size) { | 727 size_t data_size) { |
733 return DecodeAudioFileData( | 728 return DecodeAudioFileData( |
734 destination_bus, audio_file_data, data_size); | 729 destination_bus, audio_file_data, data_size); |
735 } | 730 } |
736 | 731 |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 return &trial_token_validator_; | 1291 return &trial_token_validator_; |
1297 } | 1292 } |
1298 | 1293 |
1299 void RendererBlinkPlatformImpl::workerContextCreated( | 1294 void RendererBlinkPlatformImpl::workerContextCreated( |
1300 const v8::Local<v8::Context>& worker) { | 1295 const v8::Local<v8::Context>& worker) { |
1301 GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread( | 1296 GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread( |
1302 worker); | 1297 worker); |
1303 } | 1298 } |
1304 | 1299 |
1305 } // namespace content | 1300 } // namespace content |
OLD | NEW |