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

Side by Side Diff: content/renderer/renderer_blink_platform_impl.cc

Issue 810763006: Support more than 8 channels for AudioContext.destination node on OSX (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bring ToT Created 5 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 const blink::WebString& input_device_id) { 680 const blink::WebString& input_device_id) {
681 // Use a mock for testing. 681 // Use a mock for testing.
682 blink::WebAudioDevice* mock_device = 682 blink::WebAudioDevice* mock_device =
683 GetContentClient()->renderer()->OverrideCreateAudioDevice(sample_rate); 683 GetContentClient()->renderer()->OverrideCreateAudioDevice(sample_rate);
684 if (mock_device) 684 if (mock_device)
685 return mock_device; 685 return mock_device;
686 686
687 // The |channels| does not exactly identify the channel layout of the 687 // The |channels| does not exactly identify the channel layout of the
688 // device. The switch statement below assigns a best guess to the channel 688 // device. The switch statement below assigns a best guess to the channel
689 // layout based on number of channels. 689 // layout based on number of channels.
690 // TODO(crogers): WebKit should give the channel layout instead of the hard
691 // channel count.
692 media::ChannelLayout layout = media::CHANNEL_LAYOUT_UNSUPPORTED; 690 media::ChannelLayout layout = media::CHANNEL_LAYOUT_UNSUPPORTED;
693 switch (channels) { 691 switch (channels) {
694 case 1: 692 case 1:
695 layout = media::CHANNEL_LAYOUT_MONO; 693 layout = media::CHANNEL_LAYOUT_MONO;
696 break; 694 break;
697 case 2: 695 case 2:
698 layout = media::CHANNEL_LAYOUT_STEREO; 696 layout = media::CHANNEL_LAYOUT_STEREO;
699 break; 697 break;
700 case 3: 698 case 3:
701 layout = media::CHANNEL_LAYOUT_2_1; 699 layout = media::CHANNEL_LAYOUT_2_1;
702 break; 700 break;
703 case 4: 701 case 4:
704 layout = media::CHANNEL_LAYOUT_4_0; 702 layout = media::CHANNEL_LAYOUT_4_0;
705 break; 703 break;
706 case 5: 704 case 5:
707 layout = media::CHANNEL_LAYOUT_5_0; 705 layout = media::CHANNEL_LAYOUT_5_0;
708 break; 706 break;
709 case 6: 707 case 6:
710 layout = media::CHANNEL_LAYOUT_5_1; 708 layout = media::CHANNEL_LAYOUT_5_1;
711 break; 709 break;
712 case 7: 710 case 7:
713 layout = media::CHANNEL_LAYOUT_7_0; 711 layout = media::CHANNEL_LAYOUT_7_0;
714 break; 712 break;
715 case 8: 713 case 8:
716 layout = media::CHANNEL_LAYOUT_7_1; 714 layout = media::CHANNEL_LAYOUT_7_1;
717 break; 715 break;
718 default: 716 default:
719 layout = media::CHANNEL_LAYOUT_STEREO; 717 // If the layout is not supported (more than 9 channels), falls back to
718 // discrete mode.
719 layout = media::CHANNEL_LAYOUT_DISCRETE;
720 } 720 }
721 721
722 int session_id = 0; 722 int session_id = 0;
723 if (input_device_id.isNull() || 723 if (input_device_id.isNull() ||
724 !base::StringToInt(base::UTF16ToUTF8(input_device_id), &session_id)) { 724 !base::StringToInt(base::UTF16ToUTF8(input_device_id), &session_id)) {
725 if (input_channels > 0) 725 if (input_channels > 0)
726 DLOG(WARNING) << "createAudioDevice(): request for audio input ignored"; 726 DLOG(WARNING) << "createAudioDevice(): request for audio input ignored";
727 727
728 input_channels = 0; 728 input_channels = 0;
729 } 729 }
730 730
731 // For CHANNEL_LAYOUT_DISCRETE, pass the explicit channel count along with
732 // the channel layout when creating an |AudioParameters| object.
731 media::AudioParameters params( 733 media::AudioParameters params(
732 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 734 media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
733 layout, static_cast<int>(sample_rate), 16, buffer_size, 735 layout, channels, static_cast<int>(sample_rate), 16, buffer_size,
734 media::AudioParameters::NO_EFFECTS); 736 media::AudioParameters::NO_EFFECTS);
735 737
736 return new RendererWebAudioDeviceImpl(params, callback, session_id); 738 return new RendererWebAudioDeviceImpl(params, callback, session_id);
737 } 739 }
738 740
739 #if defined(OS_ANDROID) 741 #if defined(OS_ANDROID)
740 bool RendererBlinkPlatformImpl::loadAudioResource( 742 bool RendererBlinkPlatformImpl::loadAudioResource(
741 blink::WebAudioBus* destination_bus, 743 blink::WebAudioBus* destination_bus,
742 const char* audio_file_data, 744 const char* audio_file_data,
743 size_t data_size) { 745 size_t data_size) {
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 //------------------------------------------------------------------------------ 1239 //------------------------------------------------------------------------------
1238 1240
1239 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting( 1241 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting(
1240 const blink::WebBatteryStatus& status) { 1242 const blink::WebBatteryStatus& status) {
1241 if (!g_test_battery_status_listener) 1243 if (!g_test_battery_status_listener)
1242 return; 1244 return;
1243 g_test_battery_status_listener->updateBatteryStatus(status); 1245 g_test_battery_status_listener->updateBatteryStatus(status);
1244 } 1246 }
1245 1247
1246 } // namespace content 1248 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698