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