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

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: Created 5 years, 11 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/logging.h" 10 #include "base/logging.h"
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 const blink::WebString& input_device_id) { 694 const blink::WebString& input_device_id) {
695 // Use a mock for testing. 695 // Use a mock for testing.
696 blink::WebAudioDevice* mock_device = 696 blink::WebAudioDevice* mock_device =
697 GetContentClient()->renderer()->OverrideCreateAudioDevice(sample_rate); 697 GetContentClient()->renderer()->OverrideCreateAudioDevice(sample_rate);
698 if (mock_device) 698 if (mock_device)
699 return mock_device; 699 return mock_device;
700 700
701 // The |channels| does not exactly identify the channel layout of the 701 // The |channels| does not exactly identify the channel layout of the
702 // device. The switch statement below assigns a best guess to the channel 702 // device. The switch statement below assigns a best guess to the channel
703 // layout based on number of channels. 703 // layout based on number of channels.
704 // TODO(crogers): WebKit should give the channel layout instead of the hard
Raymond Toy 2015/01/08 21:55:54 This TODO is still true isn't it? WebKit does sti
hongchan 2015/01/08 21:58:33 Still true for WebKit, but here at Blink we have t
Raymond Toy 2015/01/08 22:02:57 But creatAudioDevice still takes unsigned channels
705 // channel count.
706 media::ChannelLayout layout = media::CHANNEL_LAYOUT_UNSUPPORTED; 704 media::ChannelLayout layout = media::CHANNEL_LAYOUT_UNSUPPORTED;
707 switch (channels) { 705 switch (channels) {
708 case 1: 706 case 1:
709 layout = media::CHANNEL_LAYOUT_MONO; 707 layout = media::CHANNEL_LAYOUT_MONO;
710 break; 708 break;
711 case 2: 709 case 2:
712 layout = media::CHANNEL_LAYOUT_STEREO; 710 layout = media::CHANNEL_LAYOUT_STEREO;
713 break; 711 break;
714 case 3: 712 case 3:
715 layout = media::CHANNEL_LAYOUT_2_1; 713 layout = media::CHANNEL_LAYOUT_2_1;
716 break; 714 break;
717 case 4: 715 case 4:
718 layout = media::CHANNEL_LAYOUT_4_0; 716 layout = media::CHANNEL_LAYOUT_4_0;
719 break; 717 break;
720 case 5: 718 case 5:
721 layout = media::CHANNEL_LAYOUT_5_0; 719 layout = media::CHANNEL_LAYOUT_5_0;
722 break; 720 break;
723 case 6: 721 case 6:
724 layout = media::CHANNEL_LAYOUT_5_1; 722 layout = media::CHANNEL_LAYOUT_5_1;
725 break; 723 break;
726 case 7: 724 case 7:
727 layout = media::CHANNEL_LAYOUT_7_0; 725 layout = media::CHANNEL_LAYOUT_7_0;
728 break; 726 break;
729 case 8: 727 case 8:
730 layout = media::CHANNEL_LAYOUT_7_1; 728 layout = media::CHANNEL_LAYOUT_7_1;
731 break; 729 break;
732 default: 730 default:
733 layout = media::CHANNEL_LAYOUT_STEREO; 731 // If the layout is not supported (more than 9 channels), falls back to
732 // discrete mode.
733 layout = media::CHANNEL_LAYOUT_DISCRETE;
734 } 734 }
735 735
736 int session_id = 0; 736 int session_id = 0;
737 if (input_device_id.isNull() || 737 if (input_device_id.isNull() ||
738 !base::StringToInt(base::UTF16ToUTF8(input_device_id), &session_id)) { 738 !base::StringToInt(base::UTF16ToUTF8(input_device_id), &session_id)) {
739 if (input_channels > 0) 739 if (input_channels > 0)
740 DLOG(WARNING) << "createAudioDevice(): request for audio input ignored"; 740 DLOG(WARNING) << "createAudioDevice(): request for audio input ignored";
741 741
742 input_channels = 0; 742 input_channels = 0;
743 } 743 }
744 744
745 // For CHANNEL_LAYOUT_DISCRETE, pass the explicit channel count along with
746 // the channel layout when creating an |AudioParameters| object.
745 media::AudioParameters params( 747 media::AudioParameters params(
746 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 748 media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
747 layout, static_cast<int>(sample_rate), 16, buffer_size, 749 layout, channels, static_cast<int>(sample_rate), 16, buffer_size,
748 media::AudioParameters::NO_EFFECTS); 750 media::AudioParameters::NO_EFFECTS);
749 751
750 return new RendererWebAudioDeviceImpl(params, callback, session_id); 752 return new RendererWebAudioDeviceImpl(params, callback, session_id);
751 } 753 }
752 754
753 #if defined(OS_ANDROID) 755 #if defined(OS_ANDROID)
754 bool RendererBlinkPlatformImpl::loadAudioResource( 756 bool RendererBlinkPlatformImpl::loadAudioResource(
755 blink::WebAudioBus* destination_bus, 757 blink::WebAudioBus* destination_bus,
756 const char* audio_file_data, 758 const char* audio_file_data,
757 size_t data_size) { 759 size_t data_size) {
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 //------------------------------------------------------------------------------ 1226 //------------------------------------------------------------------------------
1225 1227
1226 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting( 1228 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting(
1227 const blink::WebBatteryStatus& status) { 1229 const blink::WebBatteryStatus& status) {
1228 if (!g_test_battery_status_listener) 1230 if (!g_test_battery_status_listener)
1229 return; 1231 return;
1230 g_test_battery_status_listener->updateBatteryStatus(status); 1232 g_test_battery_status_listener->updateBatteryStatus(status);
1231 } 1233 }
1232 1234
1233 } // namespace content 1235 } // 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