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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "media/base/audio_bus.h" | 9 #include "media/base/audio_bus.h" |
10 #include "media/base/audio_hash.h" | 10 #include "media/base/audio_hash.h" |
11 #include "media/base/fake_audio_render_callback.h" | 11 #include "media/base/fake_audio_render_callback.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace media { | 14 namespace media { |
15 | 15 |
16 static const int kChannelCount = 2; | 16 static const int kChannelCount = 2; |
17 static const int kFrameCount = 1024; | 17 static const int kFrameCount = 1024; |
| 18 static const int kSampleRate = 48000; |
18 | 19 |
19 class AudioHashTest : public testing::Test { | 20 class AudioHashTest : public testing::Test { |
20 public: | 21 public: |
21 AudioHashTest() | 22 AudioHashTest() |
22 : bus_one_(AudioBus::Create(kChannelCount, kFrameCount)), | 23 : bus_one_(AudioBus::Create(kChannelCount, kFrameCount)), |
23 bus_two_(AudioBus::Create(kChannelCount, kFrameCount)), | 24 bus_two_(AudioBus::Create(kChannelCount, kFrameCount)), |
24 fake_callback_(0.01) { | 25 fake_callback_(0.01, kSampleRate) { |
25 | |
26 // Fill each channel in each bus with unique data. | 26 // Fill each channel in each bus with unique data. |
27 GenerateUniqueChannels(bus_one_.get()); | 27 GenerateUniqueChannels(bus_one_.get()); |
28 GenerateUniqueChannels(bus_two_.get()); | 28 GenerateUniqueChannels(bus_two_.get()); |
29 } | 29 } |
30 | 30 |
31 void GenerateUniqueChannels(AudioBus* audio_bus) { | 31 void GenerateUniqueChannels(AudioBus* audio_bus) { |
32 // Use an AudioBus wrapper to avoid an extra memcpy when filling channels. | 32 // Use an AudioBus wrapper to avoid an extra memcpy when filling channels. |
33 std::unique_ptr<AudioBus> wrapped_bus = AudioBus::CreateWrapper(1); | 33 std::unique_ptr<AudioBus> wrapped_bus = AudioBus::CreateWrapper(1); |
34 wrapped_bus->set_frames(audio_bus->frames()); | 34 wrapped_bus->set_frames(audio_bus->frames()); |
35 | 35 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 // Twiddle the values too much... | 162 // Twiddle the values too much... |
163 for (int i = 0; i < bus_one_->frames(); ++i) | 163 for (int i = 0; i < bus_one_->frames(); ++i) |
164 channel[i] += 0.0001f; | 164 channel[i] += 0.0001f; |
165 | 165 |
166 AudioHash hash_three; | 166 AudioHash hash_three; |
167 hash_three.Update(bus_one_.get(), bus_one_->frames()); | 167 hash_three.Update(bus_one_.get(), bus_one_->frames()); |
168 EXPECT_NE(hash_one.ToString(), hash_three.ToString()); | 168 EXPECT_NE(hash_one.ToString(), hash_three.ToString()); |
169 } | 169 } |
170 | 170 |
171 } // namespace media | 171 } // namespace media |
OLD | NEW |