OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 void AudioBus::zero() | 96 void AudioBus::zero() |
97 { | 97 { |
98 for (unsigned i = 0; i < m_channels.size(); ++i) | 98 for (unsigned i = 0; i < m_channels.size(); ++i) |
99 m_channels[i]->zero(); | 99 m_channels[i]->zero(); |
100 } | 100 } |
101 | 101 |
102 AudioChannel* AudioBus::channelByType(unsigned channelType) | 102 AudioChannel* AudioBus::channelByType(unsigned channelType) |
103 { | 103 { |
104 // For now we only support canonical channel layouts... | 104 // For now we only support canonical channel layouts... |
105 if (m_layout != LayoutCanonical) | 105 if (m_layout != LayoutCanonical) |
106 return 0; | 106 return nullptr; |
107 | 107 |
108 switch (numberOfChannels()) { | 108 switch (numberOfChannels()) { |
109 case 1: // mono | 109 case 1: // mono |
110 if (channelType == ChannelMono || channelType == ChannelLeft) | 110 if (channelType == ChannelMono || channelType == ChannelLeft) |
111 return channel(0); | 111 return channel(0); |
112 return 0; | 112 return nullptr; |
113 | 113 |
114 case 2: // stereo | 114 case 2: // stereo |
115 switch (channelType) { | 115 switch (channelType) { |
116 case ChannelLeft: return channel(0); | 116 case ChannelLeft: return channel(0); |
117 case ChannelRight: return channel(1); | 117 case ChannelRight: return channel(1); |
118 default: return 0; | 118 default: return nullptr; |
119 } | 119 } |
120 | 120 |
121 case 4: // quad | 121 case 4: // quad |
122 switch (channelType) { | 122 switch (channelType) { |
123 case ChannelLeft: return channel(0); | 123 case ChannelLeft: return channel(0); |
124 case ChannelRight: return channel(1); | 124 case ChannelRight: return channel(1); |
125 case ChannelSurroundLeft: return channel(2); | 125 case ChannelSurroundLeft: return channel(2); |
126 case ChannelSurroundRight: return channel(3); | 126 case ChannelSurroundRight: return channel(3); |
127 default: return 0; | 127 default: return nullptr; |
128 } | 128 } |
129 | 129 |
130 case 5: // 5.0 | 130 case 5: // 5.0 |
131 switch (channelType) { | 131 switch (channelType) { |
132 case ChannelLeft: return channel(0); | 132 case ChannelLeft: return channel(0); |
133 case ChannelRight: return channel(1); | 133 case ChannelRight: return channel(1); |
134 case ChannelCenter: return channel(2); | 134 case ChannelCenter: return channel(2); |
135 case ChannelSurroundLeft: return channel(3); | 135 case ChannelSurroundLeft: return channel(3); |
136 case ChannelSurroundRight: return channel(4); | 136 case ChannelSurroundRight: return channel(4); |
137 default: return 0; | 137 default: return nullptr; |
138 } | 138 } |
139 | 139 |
140 case 6: // 5.1 | 140 case 6: // 5.1 |
141 switch (channelType) { | 141 switch (channelType) { |
142 case ChannelLeft: return channel(0); | 142 case ChannelLeft: return channel(0); |
143 case ChannelRight: return channel(1); | 143 case ChannelRight: return channel(1); |
144 case ChannelCenter: return channel(2); | 144 case ChannelCenter: return channel(2); |
145 case ChannelLFE: return channel(3); | 145 case ChannelLFE: return channel(3); |
146 case ChannelSurroundLeft: return channel(4); | 146 case ChannelSurroundLeft: return channel(4); |
147 case ChannelSurroundRight: return channel(5); | 147 case ChannelSurroundRight: return channel(5); |
148 default: return 0; | 148 default: return nullptr; |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
152 ASSERT_NOT_REACHED(); | 152 ASSERT_NOT_REACHED(); |
153 return 0; | 153 return nullptr; |
154 } | 154 } |
155 | 155 |
156 const AudioChannel* AudioBus::channelByType(unsigned type) const | 156 const AudioChannel* AudioBus::channelByType(unsigned type) const |
157 { | 157 { |
158 return const_cast<AudioBus*>(this)->channelByType(type); | 158 return const_cast<AudioBus*>(this)->channelByType(type); |
159 } | 159 } |
160 | 160 |
161 // Returns true if the channel count and frame-size match. | 161 // Returns true if the channel count and frame-size match. |
162 bool AudioBus::topologyMatches(const AudioBus& bus) const | 162 bool AudioBus::topologyMatches(const AudioBus& bus) const |
163 { | 163 { |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 // If the bus needs no conversion then return as is. | 670 // If the bus needs no conversion then return as is. |
671 if ((!mixToMono || audioBus->numberOfChannels() == 1) && audioBus->sampleRat
e() == sampleRate) | 671 if ((!mixToMono || audioBus->numberOfChannels() == 1) && audioBus->sampleRat
e() == sampleRate) |
672 return audioBus; | 672 return audioBus; |
673 | 673 |
674 return AudioBus::createBySampleRateConverting(audioBus.get(), mixToMono, sam
pleRate); | 674 return AudioBus::createBySampleRateConverting(audioBus.get(), mixToMono, sam
pleRate); |
675 } | 675 } |
676 | 676 |
677 } // namespace blink | 677 } // namespace blink |
678 | 678 |
679 #endif // ENABLE(WEB_AUDIO) | 679 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |