Index: media/base/test_helpers.cc |
diff --git a/media/base/test_helpers.cc b/media/base/test_helpers.cc |
index 929b2f3c725c70ee4fa26fc770ee0e9e827112d6..98d4971795a05291c96a31a7ae600fb681acfee6 100644 |
--- a/media/base/test_helpers.cc |
+++ b/media/base/test_helpers.cc |
@@ -151,25 +151,29 @@ |
template <class T> |
scoped_refptr<AudioBuffer> MakeAudioBuffer(SampleFormat format, |
ChannelLayout channel_layout, |
- size_t channel_count, |
+ int channel_count, |
int sample_rate, |
T start, |
T increment, |
- size_t frames, |
- base::TimeDelta timestamp) { |
- const size_t channels = ChannelLayoutToChannelCount(channel_layout); |
- scoped_refptr<AudioBuffer> output = |
- AudioBuffer::CreateBuffer(format, |
- channel_layout, |
- static_cast<int>(channel_count), |
- sample_rate, |
- static_cast<int>(frames)); |
+ int frames, |
+ base::TimeDelta timestamp, |
+ base::TimeDelta duration) { |
+ int channels = ChannelLayoutToChannelCount(channel_layout); |
+ scoped_refptr<AudioBuffer> output = AudioBuffer::CreateBuffer( |
+ format, channel_layout, channel_count, sample_rate, frames); |
output->set_timestamp(timestamp); |
- |
- const bool is_planar = |
- format == kSampleFormatPlanarS16 || format == kSampleFormatPlanarF32; |
- |
- // Values in channel 0 will be: |
+ output->set_duration(duration); |
+ |
+ // Create a block of memory with values: |
+ // start |
+ // start + increment |
+ // start + 2 * increment, ... |
+ // For interleaved data, raw data will be: |
+ // start |
+ // start + channels * increment |
+ // start + 2 * channels * increment, ... |
+ // |
+ // For planar data, values in channel 0 will be: |
// start |
// start + increment |
// start + 2 * increment, ... |
@@ -177,13 +181,13 @@ |
// start + frames * increment |
// start + (frames + 1) * increment |
// start + (frames + 2) * increment, ... |
- for (size_t ch = 0; ch < channels; ++ch) { |
- T* buffer = |
- reinterpret_cast<T*>(output->channel_data()[is_planar ? ch : 0]); |
- const T v = static_cast<T>(start + ch * frames * increment); |
- for (size_t i = 0; i < frames; ++i) { |
- buffer[is_planar ? i : ch + i * channels] = |
- static_cast<T>(v + i * increment); |
+ const size_t output_size = |
+ output->channel_data().size() == 1 ? frames * channels : frames; |
+ for (size_t ch = 0; ch < output->channel_data().size(); ++ch) { |
+ T* buffer = reinterpret_cast<T*>(output->channel_data()[ch]); |
+ const T v = static_cast<T>(start + ch * output_size * increment); |
+ for (size_t i = 0; i < output_size; ++i) { |
+ buffer[i] = static_cast<T>(v + i * increment); |
} |
} |
return output; |
@@ -195,12 +199,13 @@ |
template scoped_refptr<AudioBuffer> MakeAudioBuffer<type>( \ |
SampleFormat format, \ |
ChannelLayout channel_layout, \ |
- size_t channel_count, \ |
+ int channel_count, \ |
int sample_rate, \ |
type start, \ |
type increment, \ |
- size_t frames, \ |
- base::TimeDelta start_time) |
+ int frames, \ |
+ base::TimeDelta start_time, \ |
+ base::TimeDelta duration) |
DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(uint8); |
DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(int16); |
DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(int32); |