OLD | NEW |
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 #ifndef MEDIA_BASE_MULTI_CHANNEL_RESAMPLER_H_ | 5 #ifndef MEDIA_BASE_MULTI_CHANNEL_RESAMPLER_H_ |
6 #define MEDIA_BASE_MULTI_CHANNEL_RESAMPLER_H_ | 6 #define MEDIA_BASE_MULTI_CHANNEL_RESAMPLER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/scoped_vector.h" | |
16 #include "media/base/sinc_resampler.h" | 15 #include "media/base/sinc_resampler.h" |
17 | 16 |
18 namespace media { | 17 namespace media { |
19 class AudioBus; | 18 class AudioBus; |
20 | 19 |
21 // MultiChannelResampler is a multi channel wrapper for SincResampler; allowing | 20 // MultiChannelResampler is a multi channel wrapper for SincResampler; allowing |
22 // high quality sample rate conversion of multiple channels at once. | 21 // high quality sample rate conversion of multiple channels at once. |
23 class MEDIA_EXPORT MultiChannelResampler { | 22 class MEDIA_EXPORT MultiChannelResampler { |
24 public: | 23 public: |
25 // Callback type for providing more data into the resampler. Expects AudioBus | 24 // Callback type for providing more data into the resampler. Expects AudioBus |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 61 |
63 private: | 62 private: |
64 // SincResampler::ReadCB implementation. ProvideInput() will be called for | 63 // SincResampler::ReadCB implementation. ProvideInput() will be called for |
65 // each channel (in channel order) as SincResampler needs more data. | 64 // each channel (in channel order) as SincResampler needs more data. |
66 void ProvideInput(int channel, int frames, float* destination); | 65 void ProvideInput(int channel, int frames, float* destination); |
67 | 66 |
68 // Source of data for resampling. | 67 // Source of data for resampling. |
69 ReadCB read_cb_; | 68 ReadCB read_cb_; |
70 | 69 |
71 // Each channel has its own high quality resampler. | 70 // Each channel has its own high quality resampler. |
72 ScopedVector<SincResampler> resamplers_; | 71 std::vector<std::unique_ptr<SincResampler>> resamplers_; |
73 | 72 |
74 // Buffers for audio data going into SincResampler from ReadCB. | 73 // Buffers for audio data going into SincResampler from ReadCB. |
75 std::unique_ptr<AudioBus> resampler_audio_bus_; | 74 std::unique_ptr<AudioBus> resampler_audio_bus_; |
76 | 75 |
77 // To avoid a memcpy() on the first channel we create a wrapped AudioBus where | 76 // To avoid a memcpy() on the first channel we create a wrapped AudioBus where |
78 // the first channel points to the |destination| provided to ProvideInput(). | 77 // the first channel points to the |destination| provided to ProvideInput(). |
79 std::unique_ptr<AudioBus> wrapped_resampler_audio_bus_; | 78 std::unique_ptr<AudioBus> wrapped_resampler_audio_bus_; |
80 | 79 |
81 // The number of output frames that have successfully been processed during | 80 // The number of output frames that have successfully been processed during |
82 // the current Resample() call. | 81 // the current Resample() call. |
83 int output_frames_ready_; | 82 int output_frames_ready_; |
84 | 83 |
85 DISALLOW_COPY_AND_ASSIGN(MultiChannelResampler); | 84 DISALLOW_COPY_AND_ASSIGN(MultiChannelResampler); |
86 }; | 85 }; |
87 | 86 |
88 } // namespace media | 87 } // namespace media |
89 | 88 |
90 #endif // MEDIA_BASE_MULTI_CHANNEL_RESAMPLER_H_ | 89 #endif // MEDIA_BASE_MULTI_CHANNEL_RESAMPLER_H_ |
OLD | NEW |