Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: media/base/audio_hash_unittest.cc

Issue 2567143002: media::SilentSinkSuspender should simulate |delay| and |delay_timestamp| (Closed)
Patch Set: build fix content_unittets & media_blink_unittsests Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
OLDNEW
« no previous file with comments | « media/base/audio_converter_unittest.cc ('k') | media/base/audio_renderer_mixer_input_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698