OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/audio/audio_power_monitor.h" | 5 #include "media/audio/audio_power_monitor.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 sizeof(float) * num_to_copy); | 75 sizeof(float) * num_to_copy); |
76 } | 76 } |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 float expected_power_; | 80 float expected_power_; |
81 bool expected_clipped_; | 81 bool expected_clipped_; |
82 scoped_ptr<AudioBus> bus_; | 82 scoped_ptr<AudioBus> bus_; |
83 }; | 83 }; |
84 | 84 |
| 85 // Value printer for TestScenario. Required to prevent Valgrind "access to |
| 86 // uninitialized memory" errors (http://crbug.com/263315). |
| 87 ::std::ostream& operator<<(::std::ostream& os, const TestScenario& ts) { |
| 88 return os << "{" << ts.data().channels() << "-channel signal} --> {" |
| 89 << ts.expected_power() << " dBFS, " |
| 90 << (ts.expected_clipped() ? "clipped" : "not clipped") |
| 91 << "}"; |
| 92 } |
| 93 |
85 // An observer that receives power measurements. Each power measurement should | 94 // An observer that receives power measurements. Each power measurement should |
86 // should make progress towards the goal value. | 95 // should make progress towards the goal value. |
87 class MeasurementObserver { | 96 class MeasurementObserver { |
88 public: | 97 public: |
89 MeasurementObserver(float goal_power_measurement, bool goal_clipped) | 98 MeasurementObserver(float goal_power_measurement, bool goal_clipped) |
90 : goal_power_measurement_(goal_power_measurement), | 99 : goal_power_measurement_(goal_power_measurement), |
91 goal_clipped_(goal_clipped), measurement_count_(0), | 100 goal_clipped_(goal_clipped), measurement_count_(0), |
92 last_power_measurement_(AudioPowerMonitor::zero_power()), | 101 last_power_measurement_(AudioPowerMonitor::zero_power()), |
93 last_clipped_(false) {} | 102 last_clipped_(false) {} |
94 | 103 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 WithABadSample(std::numeric_limits<float>::quiet_NaN()), | 310 WithABadSample(std::numeric_limits<float>::quiet_NaN()), |
302 TestScenario(kStereoSilentNoise, 2, 2, -46, false), | 311 TestScenario(kStereoSilentNoise, 2, 2, -46, false), |
303 TestScenario(kStereoMaxAmplitude, 2, 2, | 312 TestScenario(kStereoMaxAmplitude, 2, 2, |
304 AudioPowerMonitor::max_power(), false), | 313 AudioPowerMonitor::max_power(), false), |
305 TestScenario(kRightChannelMaxAmplitude, 2, 4, -3, false), | 314 TestScenario(kRightChannelMaxAmplitude, 2, 4, -3, false), |
306 TestScenario(kLeftChannelHalfMaxAmplitude, 2, 4, -9, false), | 315 TestScenario(kLeftChannelHalfMaxAmplitude, 2, 4, -9, false), |
307 TestScenario(kStereoMixed, 2, 4, -2, false), | 316 TestScenario(kStereoMixed, 2, 4, -2, false), |
308 TestScenario(kStereoMixed2, 2, 8, -3, false))); | 317 TestScenario(kStereoMixed2, 2, 8, -3, false))); |
309 | 318 |
310 } // namespace media | 319 } // namespace media |
OLD | NEW |