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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
668 const blink::WebSecurityOrigin& security_origin) { | 668 const blink::WebSecurityOrigin& security_origin) { |
669 // Use a mock for testing. | 669 // Use a mock for testing. |
670 blink::WebAudioDevice* mock_device = | 670 blink::WebAudioDevice* mock_device = |
671 GetContentClient()->renderer()->OverrideCreateAudioDevice(); | 671 GetContentClient()->renderer()->OverrideCreateAudioDevice(); |
672 if (mock_device) | 672 if (mock_device) |
673 return mock_device; | 673 return mock_device; |
674 | 674 |
675 // The |channels| does not exactly identify the channel layout of the | 675 // The |channels| does not exactly identify the channel layout of the |
676 // device. The switch statement below assigns a best guess to the channel | 676 // device. The switch statement below assigns a best guess to the channel |
677 // layout based on number of channels. | 677 // layout based on number of channels. |
678 media::ChannelLayout layout = media::CHANNEL_LAYOUT_UNSUPPORTED; | 678 media::ChannelLayout layout = media::GuessChannelLayout(channels); |
679 switch (channels) { | 679 if (layout == media::CHANNEL_LAYOUT_UNSUPPORTED) |
680 case 1: | 680 layout = media::CHANNEL_LAYOUT_DISCRETE; |
681 layout = media::CHANNEL_LAYOUT_MONO; | |
682 break; | |
683 case 2: | |
684 layout = media::CHANNEL_LAYOUT_STEREO; | |
685 break; | |
686 case 3: | |
687 layout = media::CHANNEL_LAYOUT_2_1; | |
DaleCurtis
2017/02/21 22:22:44
New code will return SURROUND here:
Old: Front L,
| |
688 break; | |
689 case 4: | |
690 layout = media::CHANNEL_LAYOUT_4_0; | |
DaleCurtis
2017/02/21 22:22:44
New code will return QUAD here:
Old: Front L, Fro
| |
691 break; | |
692 case 5: | |
693 layout = media::CHANNEL_LAYOUT_5_0; | |
694 break; | |
695 case 6: | |
696 layout = media::CHANNEL_LAYOUT_5_1; | |
697 break; | |
698 case 7: | |
699 layout = media::CHANNEL_LAYOUT_7_0; | |
DaleCurtis
2017/02/21 22:22:44
New code will return 6.1 here:
Old: Front L, Fron
| |
700 break; | |
701 case 8: | |
702 layout = media::CHANNEL_LAYOUT_7_1; | |
703 break; | |
704 default: | |
705 // TODO need to also pass 'channels' into RendererWebAudioDeviceImpl for | |
706 // CHANNEL_LAYOUT_DISCRETE | |
707 NOTREACHED(); | |
708 } | |
709 | 681 |
710 int session_id = 0; | 682 int session_id; |
711 if (input_device_id.isNull() || | 683 if (input_device_id.isNull() || |
712 !base::StringToInt(input_device_id.utf8(), &session_id)) { | 684 !base::StringToInt(input_device_id.utf8(), &session_id)) { |
DaleCurtis
2017/02/21 22:22:44
Note: This method may write to |session_id| even w
| |
713 if (input_channels > 0) | 685 session_id = 0; |
714 DLOG(WARNING) << "createAudioDevice(): request for audio input ignored"; | |
715 | |
716 input_channels = 0; | |
717 } | 686 } |
718 | 687 |
719 return RendererWebAudioDeviceImpl::Create( | 688 return RendererWebAudioDeviceImpl::Create( |
720 layout, latency_hint, callback, session_id, | 689 layout, channels, latency_hint, callback, session_id, |
721 static_cast<url::Origin>(security_origin)); | 690 static_cast<url::Origin>(security_origin)); |
722 } | 691 } |
723 | 692 |
724 bool RendererBlinkPlatformImpl::loadAudioResource( | 693 bool RendererBlinkPlatformImpl::loadAudioResource( |
725 blink::WebAudioBus* destination_bus, | 694 blink::WebAudioBus* destination_bus, |
726 const char* audio_file_data, | 695 const char* audio_file_data, |
727 size_t data_size) { | 696 size_t data_size) { |
728 return DecodeAudioFileData( | 697 return DecodeAudioFileData( |
729 destination_bus, audio_file_data, data_size); | 698 destination_bus, audio_file_data, data_size); |
730 } | 699 } |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1294 //------------------------------------------------------------------------------ | 1263 //------------------------------------------------------------------------------ |
1295 void RendererBlinkPlatformImpl::requestPurgeMemory() { | 1264 void RendererBlinkPlatformImpl::requestPurgeMemory() { |
1296 // TODO(tasak|bashi): We should use ChildMemoryCoordinator here, but | 1265 // TODO(tasak|bashi): We should use ChildMemoryCoordinator here, but |
1297 // ChildMemoryCoordinator isn't always available as it's only initialized | 1266 // ChildMemoryCoordinator isn't always available as it's only initialized |
1298 // when kMemoryCoordinatorV0 is enabled. | 1267 // when kMemoryCoordinatorV0 is enabled. |
1299 // Use ChildMemoryCoordinator when memory coordinator is always enabled. | 1268 // Use ChildMemoryCoordinator when memory coordinator is always enabled. |
1300 base::MemoryCoordinatorClientRegistry::GetInstance()->PurgeMemory(); | 1269 base::MemoryCoordinatorClientRegistry::GetInstance()->PurgeMemory(); |
1301 } | 1270 } |
1302 | 1271 |
1303 } // namespace content | 1272 } // namespace content |
OLD | NEW |