Commit fecf6e98 authored by Raymond Toy's avatar Raymond Toy Committed by Commit Bot

[Code Health] Update Bind/Callback to Once/Repeating

Converting multi_channel_resmpler and sinc_resampler to use RepeatingCallback
and BindRepeating.

Bug: 1007799
Change-Id: Ic2d20e1d6880b47278b61e62ca5f3764a0feaba3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1907275Reviewed-by: default avatarChrome Cunningham <chcunningham@chromium.org>
Commit-Queue: Raymond Toy <rtoy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714984}
parent 260e4e44
......@@ -58,7 +58,8 @@ AudioConverter::AudioConverter(const AudioParameters& input_params,
resampler_.reset(new MultiChannelResampler(
downmix_early_ ? output_params.channels() : input_params.channels(),
io_sample_rate_ratio_, request_size,
base::Bind(&AudioConverter::ProvideInput, base::Unretained(this))));
base::BindRepeating(&AudioConverter::ProvideInput,
base::Unretained(this))));
}
// The resampler can be configured to work with a specific request size, so a
......@@ -76,7 +77,8 @@ AudioConverter::AudioConverter(const AudioParameters& input_params,
audio_fifo_.reset(new AudioPullFifo(
downmix_early_ ? output_params.channels() : input_params.channels(),
chunk_size_,
base::Bind(&AudioConverter::SourceCallback, base::Unretained(this))));
base::BindRepeating(&AudioConverter::SourceCallback,
base::Unretained(this))));
}
}
......
......@@ -17,8 +17,8 @@ namespace media {
MultiChannelResampler::MultiChannelResampler(int channels,
double io_sample_rate_ratio,
size_t request_size,
const ReadCB& read_cb)
: read_cb_(read_cb),
const ReadCB read_cb)
: read_cb_(std::move(read_cb)),
wrapped_resampler_audio_bus_(AudioBus::CreateWrapper(channels)),
output_frames_ready_(0) {
// Allocate each channel's resampler.
......
......@@ -25,7 +25,8 @@ class MEDIA_EXPORT MultiChannelResampler {
// to be completely filled with data upon return; zero padded if not enough
// frames are available to satisfy the request. |frame_delay| is the number
// of output frames already processed and can be used to estimate delay.
typedef base::Callback<void(int frame_delay, AudioBus* audio_bus)> ReadCB;
typedef base::RepeatingCallback<void(int frame_delay, AudioBus* audio_bus)>
ReadCB;
// Constructs a MultiChannelResampler with the specified |read_cb|, which is
// used to acquire audio data for resampling. |io_sample_rate_ratio| is the
......@@ -34,7 +35,7 @@ class MEDIA_EXPORT MultiChannelResampler {
MultiChannelResampler(int channels,
double io_sample_rate_ratio,
size_t request_frames,
const ReadCB& read_cb);
const ReadCB read_cb);
virtual ~MultiChannelResampler();
// Resamples |frames| of data from |read_cb_| into AudioBus.
......
......@@ -116,9 +116,9 @@ static int CalculateChunkSize(int block_size_, double io_ratio) {
SincResampler::SincResampler(double io_sample_rate_ratio,
int request_frames,
const ReadCB& read_cb)
const ReadCB read_cb)
: io_sample_rate_ratio_(io_sample_rate_ratio),
read_cb_(read_cb),
read_cb_(std::move(read_cb)),
request_frames_(request_frames),
input_buffer_size_(request_frames_ + kKernelSize),
// Create input buffers with a 16-byte alignment for SSE optimizations.
......
......@@ -39,7 +39,7 @@ class MEDIA_EXPORT SincResampler {
// Callback type for providing more data into the resampler. Expects |frames|
// of data to be rendered into |destination|; zero padded if not enough frames
// are available to satisfy the request.
typedef base::Callback<void(int frames, float* destination)> ReadCB;
typedef base::RepeatingCallback<void(int frames, float* destination)> ReadCB;
// Constructs a SincResampler with the specified |read_cb|, which is used to
// acquire audio data for resampling. |io_sample_rate_ratio| is the ratio
......@@ -49,7 +49,7 @@ class MEDIA_EXPORT SincResampler {
// request size constraints.
SincResampler(double io_sample_rate_ratio,
int request_frames,
const ReadCB& read_cb);
const ReadCB read_cb);
~SincResampler();
// Resample |frames| of data from |read_cb_| into |destination|.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment