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

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

Issue 506683002: Remove implicit conversions from scoped_refptr to T* in media/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 #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_splicer.h" 8 #include "media/base/audio_splicer.h"
9 #include "media/base/audio_timestamp_helper.h" 9 #include "media/base/audio_timestamp_helper.h"
10 #include "media/base/buffers.h" 10 #include "media/base/buffers.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // Verify the actual crossfade. 108 // Verify the actual crossfade.
109 const int frames = crossfade_output->frame_count(); 109 const int frames = crossfade_output->frame_count();
110 float overlapped_value = GetValue(overlapped_buffer_1); 110 float overlapped_value = GetValue(overlapped_buffer_1);
111 const float overlapping_value = GetValue(overlapping_buffer); 111 const float overlapping_value = GetValue(overlapping_buffer);
112 scoped_ptr<AudioBus> bus = AudioBus::Create(kChannels, frames); 112 scoped_ptr<AudioBus> bus = AudioBus::Create(kChannels, frames);
113 crossfade_output->ReadFrames(frames, 0, 0, bus.get()); 113 crossfade_output->ReadFrames(frames, 0, 0, bus.get());
114 for (int ch = 0; ch < crossfade_output->channel_count(); ++ch) { 114 for (int ch = 0; ch < crossfade_output->channel_count(); ++ch) {
115 float cf_ratio = 0; 115 float cf_ratio = 0;
116 const float cf_increment = 1.0f / frames; 116 const float cf_increment = 1.0f / frames;
117 for (int i = 0; i < frames; ++i, cf_ratio += cf_increment) { 117 for (int i = 0; i < frames; ++i, cf_ratio += cf_increment) {
118 if (overlapped_buffer_2 && i >= second_overlap_index) 118 if (overlapped_buffer_2.get() && i >= second_overlap_index)
119 overlapped_value = GetValue(overlapped_buffer_2); 119 overlapped_value = GetValue(overlapped_buffer_2);
120 const float actual = bus->channel(ch)[i]; 120 const float actual = bus->channel(ch)[i];
121 const float expected = 121 const float expected =
122 (1.0f - cf_ratio) * overlapped_value + cf_ratio * overlapping_value; 122 (1.0f - cf_ratio) * overlapped_value + cf_ratio * overlapping_value;
123 ASSERT_FLOAT_EQ(expected, actual) << "i=" << i; 123 ASSERT_FLOAT_EQ(expected, actual) << "i=" << i;
124 } 124 }
125 } 125 }
126 } 126 }
127 127
128 bool AddInput(const scoped_refptr<AudioBuffer>& input) { 128 bool AddInput(const scoped_refptr<AudioBuffer>& input) {
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 second_buffer->timestamp() + second_buffer->duration(); 758 second_buffer->timestamp() + second_buffer->duration();
759 scoped_refptr<AudioBuffer> output = splicer_.GetNextBuffer(); 759 scoped_refptr<AudioBuffer> output = splicer_.GetNextBuffer();
760 EXPECT_EQ(second_buffer_end_ts, output->timestamp()); 760 EXPECT_EQ(second_buffer_end_ts, output->timestamp());
761 EXPECT_EQ(third_buffer->duration() - 761 EXPECT_EQ(third_buffer->duration() -
762 (second_buffer_end_ts - third_buffer->timestamp()), 762 (second_buffer_end_ts - third_buffer->timestamp()),
763 output->duration()); 763 output->duration());
764 EXPECT_TRUE(VerifyData(output, GetValue(third_buffer))); 764 EXPECT_TRUE(VerifyData(output, GetValue(third_buffer)));
765 } 765 }
766 766
767 } // namespace media 767 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698