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

Side by Side Diff: media/base/audio_discard_helper_unittest.cc

Issue 261533002: Remove AudioBuffer::set_duration(), instead base on frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix divide by zero case. 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/audio_discard_helper.cc ('k') | media/base/audio_splicer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "media/base/audio_buffer.h" 6 #include "media/base/audio_buffer.h"
7 #include "media/base/audio_bus.h" 7 #include "media/base/audio_bus.h"
8 #include "media/base/audio_discard_helper.h" 8 #include "media/base/audio_discard_helper.h"
9 #include "media/base/buffers.h" 9 #include "media/base/buffers.h"
10 #include "media/base/decoder_buffer.h" 10 #include "media/base/decoder_buffer.h"
(...skipping 15 matching lines...) Expand all
26 } 26 }
27 27
28 static scoped_refptr<AudioBuffer> CreateDecodedBuffer(int frames) { 28 static scoped_refptr<AudioBuffer> CreateDecodedBuffer(int frames) {
29 return MakeAudioBuffer(kSampleFormatPlanarF32, 29 return MakeAudioBuffer(kSampleFormatPlanarF32,
30 CHANNEL_LAYOUT_MONO, 30 CHANNEL_LAYOUT_MONO,
31 1, 31 1,
32 kSampleRate, 32 kSampleRate,
33 0.0f, 33 0.0f,
34 kDataStep, 34 kDataStep,
35 frames, 35 frames,
36 kNoTimestamp(),
37 kNoTimestamp()); 36 kNoTimestamp());
38 } 37 }
39 38
40 static float ExtractDecodedData(const scoped_refptr<AudioBuffer>& buffer, 39 static float ExtractDecodedData(const scoped_refptr<AudioBuffer>& buffer,
41 int index) { 40 int index) {
42 // This is really inefficient, but we can't access the raw AudioBuffer if any 41 // This is really inefficient, but we can't access the raw AudioBuffer if any
43 // start trimming has been applied. 42 // start trimming has been applied.
44 scoped_ptr<AudioBus> temp_bus = AudioBus::Create(buffer->channel_count(), 1); 43 scoped_ptr<AudioBus> temp_bus = AudioBus::Create(buffer->channel_count(), 1);
45 buffer->ReadFrames(1, index, 0, temp_bus.get()); 44 buffer->ReadFrames(1, index, 0, temp_bus.get());
46 return temp_bus->channel(0)[0]; 45 return temp_bus->channel(0)[0];
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 ASSERT_TRUE(discard_helper.ProcessBuffers(encoded_buffer, decoded_buffer)); 251 ASSERT_TRUE(discard_helper.ProcessBuffers(encoded_buffer, decoded_buffer));
253 ASSERT_TRUE(discard_helper.initialized()); 252 ASSERT_TRUE(discard_helper.initialized());
254 EXPECT_EQ(kTimestamp, decoded_buffer->timestamp()); 253 EXPECT_EQ(kTimestamp, decoded_buffer->timestamp());
255 EXPECT_EQ(kDuration / 2, decoded_buffer->duration()); 254 EXPECT_EQ(kDuration / 2, decoded_buffer->duration());
256 EXPECT_EQ(kTestFrames / 2, decoded_buffer->frame_count()); 255 EXPECT_EQ(kTestFrames / 2, decoded_buffer->frame_count());
257 ASSERT_FLOAT_EQ(kDiscardFrames * kDataStep, 256 ASSERT_FLOAT_EQ(kDiscardFrames * kDataStep,
258 ExtractDecodedData(decoded_buffer, 0)); 257 ExtractDecodedData(decoded_buffer, 0));
259 } 258 }
260 259
261 } // namespace media 260 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_discard_helper.cc ('k') | media/base/audio_splicer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698