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

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

Issue 2865113007: Remove ScopedVector from media/base/ (Closed)
Patch Set: added header file in text_renderer_unittest.cc Created 3 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
« no previous file with comments | « media/base/audio_converter_unittest.cc ('k') | media/base/multi_channel_resampler.h » ('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 (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 // MSVC++ requires this to be set before any other includes to get M_PI. 5 // MSVC++ requires this to be set before any other includes to get M_PI.
6 #define _USE_MATH_DEFINES 6 #define _USE_MATH_DEFINES
7 7
8 #include "media/base/audio_renderer_mixer.h" 8 #include "media/base/audio_renderer_mixer.h"
9 9
10 #include <stddef.h> 10 #include <stddef.h>
11 11
12 #include <cmath> 12 #include <cmath>
13 #include <memory> 13 #include <memory>
14 14
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/bind_helpers.h" 16 #include "base/bind_helpers.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/scoped_vector.h" 18 #include "base/memory/ptr_util.h"
19 #include "base/synchronization/waitable_event.h" 19 #include "base/synchronization/waitable_event.h"
20 #include "base/threading/platform_thread.h" 20 #include "base/threading/platform_thread.h"
21 #include "media/base/audio_renderer_mixer_input.h" 21 #include "media/base/audio_renderer_mixer_input.h"
22 #include "media/base/audio_renderer_mixer_pool.h" 22 #include "media/base/audio_renderer_mixer_pool.h"
23 #include "media/base/fake_audio_render_callback.h" 23 #include "media/base/fake_audio_render_callback.h"
24 #include "media/base/mock_audio_renderer_sink.h" 24 #include "media/base/mock_audio_renderer_sink.h"
25 #include "testing/gmock/include/gmock/gmock.h" 25 #include "testing/gmock/include/gmock/gmock.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
27 27
28 namespace { 28 namespace {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // Setup FakeAudioRenderCallback step to compensate for resampling. 115 // Setup FakeAudioRenderCallback step to compensate for resampling.
116 double scale_factor = 116 double scale_factor =
117 input_parameters_[i].sample_rate() / 117 input_parameters_[i].sample_rate() /
118 static_cast<double>(output_parameters_.sample_rate()); 118 static_cast<double>(output_parameters_.sample_rate());
119 double step = 119 double step =
120 kSineCycles / 120 kSineCycles /
121 (scale_factor * 121 (scale_factor *
122 static_cast<double>(output_parameters_.frames_per_buffer())); 122 static_cast<double>(output_parameters_.frames_per_buffer()));
123 123
124 for (int j = 0; j < inputs_per_sample_rate; ++j, ++input) { 124 for (int j = 0; j < inputs_per_sample_rate; ++j, ++input) {
125 fake_callbacks_.push_back(new FakeAudioRenderCallback( 125 fake_callbacks_.push_back(base::MakeUnique<FakeAudioRenderCallback>(
126 step, output_parameters_.sample_rate())); 126 step, output_parameters_.sample_rate()));
127 mixer_inputs_.push_back(CreateMixerInput()); 127 mixer_inputs_.push_back(CreateMixerInput());
128 mixer_inputs_[input]->Initialize(input_parameters_[i], 128 mixer_inputs_[input]->Initialize(input_parameters_[i],
129 fake_callbacks_[input]); 129 fake_callbacks_[input].get());
130 mixer_inputs_[input]->SetVolume(1.0f); 130 mixer_inputs_[input]->SetVolume(1.0f);
131 } 131 }
132 } 132 }
133 } 133 }
134 134
135 bool ValidateAudioData(int index, int frames, float scale, double epsilon) { 135 bool ValidateAudioData(int index, int frames, float scale, double epsilon) {
136 for (int i = 0; i < audio_bus_->channels(); ++i) { 136 for (int i = 0; i < audio_bus_->channels(); ++i) {
137 for (int j = index; j < frames; j++) { 137 for (int j = index; j < frames; j++) {
138 double error = fabs(audio_bus_->channel(i)[j] - 138 double error = fabs(audio_bus_->channel(i)[j] -
139 expected_audio_bus_->channel(i)[j] * scale); 139 expected_audio_bus_->channel(i)[j] * scale);
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 virtual ~AudioRendererMixerTest() {} 346 virtual ~AudioRendererMixerTest() {}
347 347
348 scoped_refptr<MockAudioRendererSink> sink_; 348 scoped_refptr<MockAudioRendererSink> sink_;
349 std::unique_ptr<AudioRendererMixer> mixer_; 349 std::unique_ptr<AudioRendererMixer> mixer_;
350 AudioRendererSink::RenderCallback* mixer_callback_; 350 AudioRendererSink::RenderCallback* mixer_callback_;
351 std::vector<AudioParameters> input_parameters_; 351 std::vector<AudioParameters> input_parameters_;
352 AudioParameters output_parameters_; 352 AudioParameters output_parameters_;
353 std::unique_ptr<AudioBus> audio_bus_; 353 std::unique_ptr<AudioBus> audio_bus_;
354 std::unique_ptr<AudioBus> expected_audio_bus_; 354 std::unique_ptr<AudioBus> expected_audio_bus_;
355 std::vector< scoped_refptr<AudioRendererMixerInput> > mixer_inputs_; 355 std::vector< scoped_refptr<AudioRendererMixerInput> > mixer_inputs_;
356 ScopedVector<FakeAudioRenderCallback> fake_callbacks_; 356 std::vector<std::unique_ptr<FakeAudioRenderCallback>> fake_callbacks_;
357 std::unique_ptr<FakeAudioRenderCallback> expected_callback_; 357 std::unique_ptr<FakeAudioRenderCallback> expected_callback_;
358 double epsilon_; 358 double epsilon_;
359 bool half_fill_; 359 bool half_fill_;
360 360
361 private: 361 private:
362 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerTest); 362 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerTest);
363 }; 363 };
364 364
365 class AudioRendererMixerBehavioralTest : public AudioRendererMixerTest {}; 365 class AudioRendererMixerBehavioralTest : public AudioRendererMixerTest {};
366 366
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 INSTANTIATE_TEST_CASE_P( 555 INSTANTIATE_TEST_CASE_P(
556 /* no prefix */, 556 /* no prefix */,
557 AudioRendererMixerBehavioralTest, 557 AudioRendererMixerBehavioralTest,
558 testing::ValuesIn(std::vector<AudioRendererMixerTestData>( 558 testing::ValuesIn(std::vector<AudioRendererMixerTestData>(
559 1, 559 1,
560 std::tr1::make_tuple(&kTestInputLower, 560 std::tr1::make_tuple(&kTestInputLower,
561 1, 561 1,
562 kTestInputLower, 562 kTestInputLower,
563 0.00000048)))); 563 0.00000048))));
564 } // namespace media 564 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_converter_unittest.cc ('k') | media/base/multi_channel_resampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698