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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // The maximum size in frames that guarantees Resample() will only make a | 50 // The maximum size in frames that guarantees Resample() will only make a |
51 // single call to |read_cb_| for more data. | 51 // single call to |read_cb_| for more data. |
52 int ChunkSize() const; | 52 int ChunkSize() const; |
53 | 53 |
54 // See SincResampler::BufferedFrames. | 54 // See SincResampler::BufferedFrames. |
55 double BufferedFrames() const; | 55 double BufferedFrames() const; |
56 | 56 |
| 57 // See SincResampler::PrimeWithSilence. |
| 58 void PrimeWithSilence(); |
| 59 |
57 private: | 60 private: |
58 // SincResampler::ReadCB implementation. ProvideInput() will be called for | 61 // SincResampler::ReadCB implementation. ProvideInput() will be called for |
59 // each channel (in channel order) as SincResampler needs more data. | 62 // each channel (in channel order) as SincResampler needs more data. |
60 void ProvideInput(int channel, int frames, float* destination); | 63 void ProvideInput(int channel, int frames, float* destination); |
61 | 64 |
62 // Source of data for resampling. | 65 // Source of data for resampling. |
63 ReadCB read_cb_; | 66 ReadCB read_cb_; |
64 | 67 |
65 // Each channel has its own high quality resampler. | 68 // Each channel has its own high quality resampler. |
66 ScopedVector<SincResampler> resamplers_; | 69 ScopedVector<SincResampler> resamplers_; |
67 | 70 |
68 // Buffers for audio data going into SincResampler from ReadCB. | 71 // Buffers for audio data going into SincResampler from ReadCB. |
69 scoped_ptr<AudioBus> resampler_audio_bus_; | 72 scoped_ptr<AudioBus> resampler_audio_bus_; |
70 | 73 |
71 // To avoid a memcpy() on the first channel we create a wrapped AudioBus where | 74 // To avoid a memcpy() on the first channel we create a wrapped AudioBus where |
72 // the first channel points to the |destination| provided to ProvideInput(). | 75 // the first channel points to the |destination| provided to ProvideInput(). |
73 scoped_ptr<AudioBus> wrapped_resampler_audio_bus_; | 76 scoped_ptr<AudioBus> wrapped_resampler_audio_bus_; |
74 | 77 |
75 // The number of output frames that have successfully been processed during | 78 // The number of output frames that have successfully been processed during |
76 // the current Resample() call. | 79 // the current Resample() call. |
77 int output_frames_ready_; | 80 int output_frames_ready_; |
78 | 81 |
79 DISALLOW_COPY_AND_ASSIGN(MultiChannelResampler); | 82 DISALLOW_COPY_AND_ASSIGN(MultiChannelResampler); |
80 }; | 83 }; |
81 | 84 |
82 } // namespace media | 85 } // namespace media |
83 | 86 |
84 #endif // MEDIA_BASE_MULTI_CHANNEL_RESAMPLER_H_ | 87 #endif // MEDIA_BASE_MULTI_CHANNEL_RESAMPLER_H_ |
OLD | NEW |