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

Unified Diff: media/base/audio_buffer_unittest.cc

Issue 261333002: Fix AudioBuffer verification tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/audio_buffer_queue_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_buffer_unittest.cc
diff --git a/media/base/audio_buffer_unittest.cc b/media/base/audio_buffer_unittest.cc
index c0fbf6b85befa1c79a3ed401363e44ced0d341bf..d28669f78c25bc9c77c737c33cdbe291af424692 100644
--- a/media/base/audio_buffer_unittest.cc
+++ b/media/base/audio_buffer_unittest.cc
@@ -11,23 +11,23 @@ namespace media {
static const int kSampleRate = 48000;
-
static void VerifyBusWithOffset(AudioBus* bus,
int offset,
int frames,
float start,
+ float start_offset,
wolenetz 2014/05/05 20:28:45 Is there really a difference between start and sta
DaleCurtis 2014/05/05 21:28:50 Yes. |start| is used to calculate a new |v| at th
wolenetz 2014/05/05 22:16:29 nit: Hmm. Then maybe lift the constant 'start_offs
DaleCurtis 2014/05/05 22:54:44 Done.
float increment) {
for (int ch = 0; ch < bus->channels(); ++ch) {
const float v = start + ch * bus->frames() * increment;
- for (int i = offset; i < frames; ++i) {
- ASSERT_FLOAT_EQ(v + i * increment, bus->channel(ch)[i]) << "i=" << i
- << ", ch=" << ch;
+ for (int i = offset; i < offset + frames; ++i) {
+ ASSERT_FLOAT_EQ(start_offset + v + i * increment, bus->channel(ch)[i])
+ << "i=" << i << ", ch=" << ch;
}
}
}
static void VerifyBus(AudioBus* bus, int frames, float start, float increment) {
- VerifyBusWithOffset(bus, 0, frames, start, increment);
+ VerifyBusWithOffset(bus, 0, frames, start, 0, increment);
}
static void TrimRangeTest(SampleFormat sample_format) {
@@ -65,8 +65,12 @@ static void TrimRangeTest(SampleFormat sample_format) {
bus->Zero();
buffer->ReadFrames(buffer->frame_count(), 0, 0, bus.get());
VerifyBus(bus.get(), trim_start, 0, 1);
- VerifyBusWithOffset(
- bus.get(), trim_start, buffer->frame_count() - trim_start, 0, 1);
+ VerifyBusWithOffset(bus.get(),
+ trim_start,
+ buffer->frame_count() - trim_start,
+ 0,
+ trim_length,
+ 1);
// Trim 10ms of frames from the start, which just adjusts the buffer's
// internal start offset.
@@ -78,8 +82,12 @@ static void TrimRangeTest(SampleFormat sample_format) {
bus->Zero();
buffer->ReadFrames(buffer->frame_count(), 0, 0, bus.get());
VerifyBus(bus.get(), trim_start, trim_length, 1);
- VerifyBusWithOffset(
- bus.get(), trim_start, buffer->frame_count() - trim_start, 0, 1);
+ VerifyBusWithOffset(bus.get(),
+ trim_start,
+ buffer->frame_count() - trim_start,
+ trim_length,
+ trim_length,
+ 1);
// Trim 10ms of frames from the end, which just adjusts the buffer's frame
// count.
@@ -90,8 +98,12 @@ static void TrimRangeTest(SampleFormat sample_format) {
bus->Zero();
buffer->ReadFrames(buffer->frame_count(), 0, 0, bus.get());
VerifyBus(bus.get(), trim_start, trim_length, 1);
- VerifyBusWithOffset(
- bus.get(), trim_start, buffer->frame_count() - trim_start, 0, 1);
+ VerifyBusWithOffset(bus.get(),
+ trim_start,
+ buffer->frame_count() - trim_start,
+ trim_length,
+ trim_length,
+ 1);
// Trim another 10ms from the inner portion of the buffer.
buffer->TrimRange(trim_start, trim_start + trim_length);
@@ -101,8 +113,12 @@ static void TrimRangeTest(SampleFormat sample_format) {
bus->Zero();
buffer->ReadFrames(buffer->frame_count(), 0, 0, bus.get());
VerifyBus(bus.get(), trim_start, trim_length, 1);
- VerifyBusWithOffset(
- bus.get(), trim_start, buffer->frame_count() - trim_start, 0, 1);
+ VerifyBusWithOffset(bus.get(),
+ trim_start,
+ buffer->frame_count() - trim_start,
+ trim_length,
+ trim_length * 2,
+ 1);
// Trim off the end using TrimRange() to ensure end index is exclusive.
buffer->TrimRange(buffer->frame_count() - trim_length, buffer->frame_count());
@@ -112,8 +128,12 @@ static void TrimRangeTest(SampleFormat sample_format) {
bus->Zero();
buffer->ReadFrames(buffer->frame_count(), 0, 0, bus.get());
VerifyBus(bus.get(), trim_start, trim_length, 1);
- VerifyBusWithOffset(
- bus.get(), trim_start, buffer->frame_count() - trim_start, 0, 1);
+ VerifyBusWithOffset(bus.get(),
+ trim_start,
+ buffer->frame_count() - trim_start,
+ trim_length,
+ trim_length * 2,
+ 1);
// Trim off the start using TrimRange() to ensure start index is inclusive.
buffer->TrimRange(0, trim_length);
@@ -124,8 +144,12 @@ static void TrimRangeTest(SampleFormat sample_format) {
bus->Zero();
buffer->ReadFrames(buffer->frame_count(), 0, 0, bus.get());
VerifyBus(bus.get(), trim_start, 2 * trim_length, 1);
- VerifyBusWithOffset(
- bus.get(), trim_start, buffer->frame_count() - trim_start, 0, 1);
+ VerifyBusWithOffset(bus.get(),
+ trim_start,
+ buffer->frame_count() - trim_start,
+ trim_length * 2,
+ trim_length * 2,
+ 1);
}
TEST(AudioBufferTest, CopyFrom) {
« no previous file with comments | « media/base/audio_buffer_queue_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698