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