OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 }; | 93 }; |
94 | 94 |
95 } // namespace | 95 } // namespace |
96 | 96 |
97 MultiChannelResampler::MultiChannelResampler(double scaleFactor, | 97 MultiChannelResampler::MultiChannelResampler(double scaleFactor, |
98 unsigned numberOfChannels) | 98 unsigned numberOfChannels) |
99 : m_numberOfChannels(numberOfChannels) { | 99 : m_numberOfChannels(numberOfChannels) { |
100 // Create each channel's resampler. | 100 // Create each channel's resampler. |
101 for (unsigned channelIndex = 0; channelIndex < numberOfChannels; | 101 for (unsigned channelIndex = 0; channelIndex < numberOfChannels; |
102 ++channelIndex) | 102 ++channelIndex) |
103 m_kernels.append(WTF::makeUnique<SincResampler>(scaleFactor)); | 103 m_kernels.push_back(WTF::makeUnique<SincResampler>(scaleFactor)); |
104 } | 104 } |
105 | 105 |
106 void MultiChannelResampler::process(AudioSourceProvider* provider, | 106 void MultiChannelResampler::process(AudioSourceProvider* provider, |
107 AudioBus* destination, | 107 AudioBus* destination, |
108 size_t framesToProcess) { | 108 size_t framesToProcess) { |
109 // The provider can provide us with multi-channel audio data. But each of our | 109 // The provider can provide us with multi-channel audio data. But each of our |
110 // single-channel resamplers (kernels) below requires a provider which | 110 // single-channel resamplers (kernels) below requires a provider which |
111 // provides a single unique channel of data. channelProvider wraps the | 111 // provides a single unique channel of data. channelProvider wraps the |
112 // original multi-channel provider and dishes out one channel at a time. | 112 // original multi-channel provider and dishes out one channel at a time. |
113 ChannelProvider channelProvider(provider, m_numberOfChannels); | 113 ChannelProvider channelProvider(provider, m_numberOfChannels); |
114 | 114 |
115 for (unsigned channelIndex = 0; channelIndex < m_numberOfChannels; | 115 for (unsigned channelIndex = 0; channelIndex < m_numberOfChannels; |
116 ++channelIndex) { | 116 ++channelIndex) { |
117 // Depending on the sample-rate scale factor, and the internal buffering | 117 // Depending on the sample-rate scale factor, and the internal buffering |
118 // used in a SincResampler kernel, this call to process() will only | 118 // used in a SincResampler kernel, this call to process() will only |
119 // sometimes call provideInput() on the channelProvider. However, if it | 119 // sometimes call provideInput() on the channelProvider. However, if it |
120 // calls provideInput() for the first channel, then it will call it for the | 120 // calls provideInput() for the first channel, then it will call it for the |
121 // remaining channels, since they all buffer in the same way and are | 121 // remaining channels, since they all buffer in the same way and are |
122 // processing the same number of frames. | 122 // processing the same number of frames. |
123 m_kernels[channelIndex]->process( | 123 m_kernels[channelIndex]->process( |
124 &channelProvider, destination->channel(channelIndex)->mutableData(), | 124 &channelProvider, destination->channel(channelIndex)->mutableData(), |
125 framesToProcess); | 125 framesToProcess); |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 } // namespace blink | 129 } // namespace blink |
OLD | NEW |