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

Side by Side Diff: chromecast/media/cma/backend/alsa/post_processors/governor_unittest.cc

Issue 2958393002: Add a simple, safe gain PostProcessor. (Closed)
Patch Set: Unrelated cleanup Created 3 years, 5 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 <cmath> 5 #include <cmath>
6 #include <cstdint> 6 #include <cstdint>
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "chromecast/media/cma/backend/alsa/post_processor_factory.h"
14 #include "chromecast/media/cma/backend/alsa/post_processors/governor.h" 15 #include "chromecast/media/cma/backend/alsa/post_processors/governor.h"
15 #include "chromecast/media/cma/backend/alsa/post_processors/post_processor_unitt est.h" 16 #include "chromecast/media/cma/backend/alsa/post_processors/post_processor_unitt est.h"
16 #include "media/base/audio_bus.h"
17 #include "media/base/audio_sample_types.h"
18 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
19 18
20 namespace chromecast { 19 namespace chromecast {
21 namespace media { 20 namespace media {
22 namespace post_processor_test { 21 namespace post_processor_test {
23 22
24 namespace { 23 namespace {
25 24
26 const char* kConfigTemplate = 25 const char* kConfigTemplate =
27 R"config({"onset_volume": %f, "clamp_multiplier": %f})config"; 26 R"config({"onset_volume": %f, "clamp_multiplier": %f})config";
28 27
28 const char kLibraryPath[] = "libcast_governor_1.0.so";
29 const float kDefaultClamp = 0.6f; 29 const float kDefaultClamp = 0.6f;
30 const int kNumFrames = 100; 30 const int kNumFrames = 100;
31 const int kFrequency = 2000; 31 const int kFrequency = 2000;
32 const int kSampleRate = 44100; 32 const int kSampleRate = 44100;
33 33
34 std::string MakeConfigString(float onset_volume, float clamp_multiplier) { 34 std::string MakeConfigString(float onset_volume, float clamp_multiplier) {
35 return base::StringPrintf(kConfigTemplate, onset_volume, clamp_multiplier); 35 return base::StringPrintf(kConfigTemplate, onset_volume, clamp_multiplier);
36 } 36 }
37 37
38 void ScaleData(float* data, int frames, float scale) { 38 void ScaleData(float* data, int frames, float scale) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 ScaleData(expected_.data(), kNumFrames * kNumChannels, clamp_); 104 ScaleData(expected_.data(), kNumFrames * kNumChannels, clamp_);
105 } 105 }
106 CompareBuffers(); 106 CompareBuffers();
107 } 107 }
108 108
109 INSTANTIATE_TEST_CASE_P(GovernorClampVolumeTest, 109 INSTANTIATE_TEST_CASE_P(GovernorClampVolumeTest,
110 GovernorTest, 110 GovernorTest,
111 ::testing::Values(0.0f, 0.1f, 0.5f, 0.9f, 1.0f, 1.1f)); 111 ::testing::Values(0.0f, 0.1f, 0.5f, 0.9f, 1.0f, 1.1f));
112 112
113 // Default tests from post_processor_test 113 // Default tests from post_processor_test
114 TEST_P(PostProcessorTest, TestDelay) { 114 TEST_P(PostProcessorTest, GovernorDelay) {
115 std::string config = MakeConfigString(1.0, 1.0); 115 std::string config = MakeConfigString(1.0, 1.0);
116 auto pp = 116 PostProcessorFactory factory;
117 base::WrapUnique(AudioPostProcessorShlib_Create(config, kNumChannels)); 117 auto pp = factory.CreatePostProcessor(kLibraryPath, config, kNumChannels);
118 TestDelay(pp.get(), sample_rate_); 118 TestDelay(pp.get(), sample_rate_);
119 } 119 }
120 120
121 TEST_P(PostProcessorTest, TestRinging) { 121 TEST_P(PostProcessorTest, GovernorRinging) {
122 std::string config = MakeConfigString(1.0, 1.0); 122 std::string config = MakeConfigString(1.0, 1.0);
123 auto pp = 123 PostProcessorFactory factory;
124 base::WrapUnique(AudioPostProcessorShlib_Create(config, kNumChannels)); 124 auto pp = factory.CreatePostProcessor(kLibraryPath, config, kNumChannels);
125 TestRingingTime(pp.get(), sample_rate_); 125 TestRingingTime(pp.get(), sample_rate_);
126 } 126 }
127 127
128 TEST_P(PostProcessorTest, TestPassthrough) { 128 TEST_P(PostProcessorTest, GovernorPassthrough) {
129 std::string config = MakeConfigString(1.0, 1.0); 129 std::string config = MakeConfigString(1.0, 1.0);
130 auto pp = 130 PostProcessorFactory factory;
131 base::WrapUnique(AudioPostProcessorShlib_Create(config, kNumChannels)); 131 auto pp = factory.CreatePostProcessor(kLibraryPath, config, kNumChannels);
132 TestPassthrough(pp.get(), sample_rate_); 132 TestPassthrough(pp.get(), sample_rate_);
133 } 133 }
134 134
135 } // namespace post_processor_test 135 } // namespace post_processor_test
136 } // namespace media 136 } // namespace media
137 } // namespace chromecast 137 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698