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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // Update ratio for all SincResamplers. SetRatio() will cause reconstruction | 45 // Update ratio for all SincResamplers. SetRatio() will cause reconstruction |
46 // of the kernels used for resampling. Not thread safe, do not call while | 46 // of the kernels used for resampling. Not thread safe, do not call while |
47 // Resample() is in progress. | 47 // Resample() is in progress. |
48 void SetRatio(double io_sample_rate_ratio); | 48 void SetRatio(double io_sample_rate_ratio); |
49 | 49 |
50 private: | 50 private: |
51 // SincResampler::ReadCB implementation. ProvideInput() will be called for | 51 // SincResampler::ReadCB implementation. ProvideInput() will be called for |
52 // each channel (in channel order) as SincResampler needs more data. | 52 // each channel (in channel order) as SincResampler needs more data. |
53 void ProvideInput(int channel, int frames, float* destination); | 53 void ProvideInput(int channel, int frames, float* destination); |
54 | 54 |
55 // Sanity check to ensure that ProvideInput() retrieves the same number of | |
56 // frames for every channel. | |
57 int last_frame_count_; | |
58 | |
59 // Source of data for resampling. | 55 // Source of data for resampling. |
60 ReadCB read_cb_; | 56 ReadCB read_cb_; |
61 | 57 |
62 // Each channel has its own high quality resampler. | 58 // Each channel has its own high quality resampler. |
63 ScopedVector<SincResampler> resamplers_; | 59 ScopedVector<SincResampler> resamplers_; |
64 | 60 |
65 // Buffers for audio data going into SincResampler from ReadCB. | 61 // Buffers for audio data going into SincResampler from ReadCB. |
66 scoped_ptr<AudioBus> resampler_audio_bus_; | 62 scoped_ptr<AudioBus> resampler_audio_bus_; |
| 63 |
| 64 // To avoid a memcpy() on the first channel we create a wrapped AudioBus where |
| 65 // the first channel points to the |destination| provided to ProvideInput(). |
67 scoped_ptr<AudioBus> wrapped_resampler_audio_bus_; | 66 scoped_ptr<AudioBus> wrapped_resampler_audio_bus_; |
68 std::vector<float*> resampler_audio_data_; | |
69 | 67 |
70 // The number of output frames that have successfully been processed during | 68 // The number of output frames that have successfully been processed during |
71 // the current Resample() call. | 69 // the current Resample() call. |
72 int output_frames_ready_; | 70 int output_frames_ready_; |
73 | 71 |
74 DISALLOW_COPY_AND_ASSIGN(MultiChannelResampler); | 72 DISALLOW_COPY_AND_ASSIGN(MultiChannelResampler); |
75 }; | 73 }; |
76 | 74 |
77 } // namespace media | 75 } // namespace media |
78 | 76 |
79 #endif // MEDIA_BASE_MULTI_CHANNEL_RESAMPLER_H_ | 77 #endif // MEDIA_BASE_MULTI_CHANNEL_RESAMPLER_H_ |
OLD | NEW |