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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 24 matching lines...) Expand all Loading... |
35 using namespace std; | 35 using namespace std; |
36 | 36 |
37 namespace WebCore { | 37 namespace WebCore { |
38 | 38 |
39 const double AudioResampler::MaxRate = 8.0; | 39 const double AudioResampler::MaxRate = 8.0; |
40 | 40 |
41 AudioResampler::AudioResampler() | 41 AudioResampler::AudioResampler() |
42 : m_rate(1.0) | 42 : m_rate(1.0) |
43 { | 43 { |
44 m_kernels.append(adoptPtr(new AudioResamplerKernel(this))); | 44 m_kernels.append(adoptPtr(new AudioResamplerKernel(this))); |
45 m_sourceBus = adoptRef(new AudioBus(1, 0, false)); | 45 m_sourceBus = AudioBus::create(1, 0, false); |
46 } | 46 } |
47 | 47 |
48 AudioResampler::AudioResampler(unsigned numberOfChannels) | 48 AudioResampler::AudioResampler(unsigned numberOfChannels) |
49 : m_rate(1.0) | 49 : m_rate(1.0) |
50 { | 50 { |
51 for (unsigned i = 0; i < numberOfChannels; ++i) | 51 for (unsigned i = 0; i < numberOfChannels; ++i) |
52 m_kernels.append(adoptPtr(new AudioResamplerKernel(this))); | 52 m_kernels.append(adoptPtr(new AudioResamplerKernel(this))); |
53 | 53 |
54 m_sourceBus = adoptRef(new AudioBus(numberOfChannels, 0, false)); | 54 m_sourceBus = AudioBus::create(numberOfChannels, 0, false); |
55 } | 55 } |
56 | 56 |
57 void AudioResampler::configureChannels(unsigned numberOfChannels) | 57 void AudioResampler::configureChannels(unsigned numberOfChannels) |
58 { | 58 { |
59 unsigned currentSize = m_kernels.size(); | 59 unsigned currentSize = m_kernels.size(); |
60 if (numberOfChannels == currentSize) | 60 if (numberOfChannels == currentSize) |
61 return; // already setup | 61 return; // already setup |
62 | 62 |
63 // First deal with adding or removing kernels. | 63 // First deal with adding or removing kernels. |
64 if (numberOfChannels > currentSize) { | 64 if (numberOfChannels > currentSize) { |
65 for (unsigned i = currentSize; i < numberOfChannels; ++i) | 65 for (unsigned i = currentSize; i < numberOfChannels; ++i) |
66 m_kernels.append(adoptPtr(new AudioResamplerKernel(this))); | 66 m_kernels.append(adoptPtr(new AudioResamplerKernel(this))); |
67 } else | 67 } else |
68 m_kernels.resize(numberOfChannels); | 68 m_kernels.resize(numberOfChannels); |
69 | 69 |
70 // Reconfigure our source bus to the new channel size. | 70 // Reconfigure our source bus to the new channel size. |
71 m_sourceBus = adoptRef(new AudioBus(numberOfChannels, 0, false)); | 71 m_sourceBus = AudioBus::create(numberOfChannels, 0, false); |
72 } | 72 } |
73 | 73 |
74 void AudioResampler::process(AudioSourceProvider* provider, AudioBus* destinatio
nBus, size_t framesToProcess) | 74 void AudioResampler::process(AudioSourceProvider* provider, AudioBus* destinatio
nBus, size_t framesToProcess) |
75 { | 75 { |
76 ASSERT(provider); | 76 ASSERT(provider); |
77 if (!provider) | 77 if (!provider) |
78 return; | 78 return; |
79 | 79 |
80 unsigned numberOfChannels = m_kernels.size(); | 80 unsigned numberOfChannels = m_kernels.size(); |
81 | 81 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 void AudioResampler::reset() | 119 void AudioResampler::reset() |
120 { | 120 { |
121 unsigned numberOfChannels = m_kernels.size(); | 121 unsigned numberOfChannels = m_kernels.size(); |
122 for (unsigned i = 0; i < numberOfChannels; ++i) | 122 for (unsigned i = 0; i < numberOfChannels; ++i) |
123 m_kernels[i]->reset(); | 123 m_kernels[i]->reset(); |
124 } | 124 } |
125 | 125 |
126 } // namespace WebCore | 126 } // namespace WebCore |
127 | 127 |
128 #endif // ENABLE(WEB_AUDIO) | 128 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |