Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: media/base/multi_channel_resampler.h

Issue 10918098: Introduce AudioOutputResampler for browser side resampling. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Unittests! Bugs! Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 16 matching lines...) Expand all
27 // Constructs a MultiChannelResampler with the specified |read_cb|, which is 27 // Constructs a MultiChannelResampler with the specified |read_cb|, which is
28 // used to acquire audio data for resampling. |io_sample_rate_ratio| is the 28 // used to acquire audio data for resampling. |io_sample_rate_ratio| is the
29 // ratio of input / output sample rates. 29 // ratio of input / output sample rates.
30 MultiChannelResampler(int channels, double io_sample_rate_ratio, 30 MultiChannelResampler(int channels, double io_sample_rate_ratio,
31 const ReadCB& read_cb); 31 const ReadCB& read_cb);
32 virtual ~MultiChannelResampler(); 32 virtual ~MultiChannelResampler();
33 33
34 // Resamples |frames| of data from |read_cb_| into AudioBus. 34 // Resamples |frames| of data from |read_cb_| into AudioBus.
35 void Resample(AudioBus* audio_bus, int frames); 35 void Resample(AudioBus* audio_bus, int frames);
36 36
37 // Flush all buffered data and reset internal indices.
38 void Flush();
39
37 private: 40 private:
38 // SincResampler::ReadCB implementation. ProvideInput() will be called for 41 // SincResampler::ReadCB implementation. ProvideInput() will be called for
39 // each channel (in channel order) as SincResampler needs more data. 42 // each channel (in channel order) as SincResampler needs more data.
40 void ProvideInput(int channel, float* destination, int frames); 43 void ProvideInput(int channel, float* destination, int frames);
41 44
42 // Sanity check to ensure that ProvideInput() retrieves the same number of 45 // Sanity check to ensure that ProvideInput() retrieves the same number of
43 // frames for every channel. 46 // frames for every channel.
44 int last_frame_count_; 47 int last_frame_count_;
45 48
46 // Source of data for resampling. 49 // Source of data for resampling.
47 ReadCB read_cb_; 50 ReadCB read_cb_;
48 51
49 // Each channel has its own high quality resampler. 52 // Each channel has its own high quality resampler.
50 ScopedVector<SincResampler> resamplers_; 53 ScopedVector<SincResampler> resamplers_;
51 54
52 // Buffers for audio data going into SincResampler from ReadCB. 55 // Buffers for audio data going into SincResampler from ReadCB.
53 scoped_ptr<AudioBus> resampler_audio_bus_; 56 scoped_ptr<AudioBus> resampler_audio_bus_;
54 scoped_ptr<AudioBus> wrapped_resampler_audio_bus_; 57 scoped_ptr<AudioBus> wrapped_resampler_audio_bus_;
55 std::vector<float*> resampler_audio_data_; 58 std::vector<float*> resampler_audio_data_;
56 }; 59 };
57 60
58 } // namespace media 61 } // namespace media
59 62
60 #endif // MEDIA_BASE_MULTI_CHANNEL_RESAMPLER_H_ 63 #endif // MEDIA_BASE_MULTI_CHANNEL_RESAMPLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698