| OLD | NEW |
| 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 <cmath> | 5 #include <cmath> |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "media/base/audio_bus.h" | 9 #include "media/base/audio_bus.h" |
| 10 #include "media/cast/test/utility/audio_utility.h" | 10 #include "media/cast/test/utility/audio_utility.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 volume_(volume), | 23 volume_(volume), |
| 24 source_(num_channels, sine_wave_frequency, sample_rate) { | 24 source_(num_channels, sine_wave_frequency, sample_rate) { |
| 25 CHECK_LT(0, num_channels); | 25 CHECK_LT(0, num_channels); |
| 26 CHECK_LT(0, sample_rate); | 26 CHECK_LT(0, sample_rate); |
| 27 CHECK_LE(0.0f, volume_); | 27 CHECK_LE(0.0f, volume_); |
| 28 CHECK_LE(volume_, 1.0f); | 28 CHECK_LE(volume_, 1.0f); |
| 29 } | 29 } |
| 30 | 30 |
| 31 TestAudioBusFactory::~TestAudioBusFactory() {} | 31 TestAudioBusFactory::~TestAudioBusFactory() {} |
| 32 | 32 |
| 33 scoped_ptr<AudioBus> TestAudioBusFactory::NextAudioBus( | 33 std::unique_ptr<AudioBus> TestAudioBusFactory::NextAudioBus( |
| 34 const base::TimeDelta& duration) { | 34 const base::TimeDelta& duration) { |
| 35 const int num_samples = static_cast<int>((sample_rate_ * duration) / | 35 const int num_samples = static_cast<int>((sample_rate_ * duration) / |
| 36 base::TimeDelta::FromSeconds(1)); | 36 base::TimeDelta::FromSeconds(1)); |
| 37 scoped_ptr<AudioBus> bus(AudioBus::Create(num_channels_, num_samples)); | 37 std::unique_ptr<AudioBus> bus(AudioBus::Create(num_channels_, num_samples)); |
| 38 source_.OnMoreData(bus.get(), 0, 0); | 38 source_.OnMoreData(bus.get(), 0, 0); |
| 39 bus->Scale(volume_); | 39 bus->Scale(volume_); |
| 40 return bus; | 40 return bus; |
| 41 } | 41 } |
| 42 | 42 |
| 43 int CountZeroCrossings(const float* samples, int length) { | 43 int CountZeroCrossings(const float* samples, int length) { |
| 44 // The sample values must pass beyond |kAmplitudeThreshold| on the opposite | 44 // The sample values must pass beyond |kAmplitudeThreshold| on the opposite |
| 45 // side of zero before a crossing will be counted. | 45 // side of zero before a crossing will be counted. |
| 46 const float kAmplitudeThreshold = 0.03f; // 3% of max amplitude. | 46 const float kAmplitudeThreshold = 0.03f; // 3% of max amplitude. |
| 47 | 47 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 } | 179 } |
| 180 *timestamp = gray_coded; | 180 *timestamp = gray_coded; |
| 181 return true; | 181 return true; |
| 182 } | 182 } |
| 183 } | 183 } |
| 184 return false; | 184 return false; |
| 185 } | 185 } |
| 186 | 186 |
| 187 } // namespace cast | 187 } // namespace cast |
| 188 } // namespace media | 188 } // namespace media |
| OLD | NEW |