| 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 "components/copresence/mediums/audio/audio_recorder.h" | 5 #include "components/copresence/mediums/audio/audio_recorder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/aligned_memory.h" | 8 #include "base/memory/aligned_memory.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "components/copresence/mediums/audio/audio_recorder_impl.h" | 10 #include "components/copresence/mediums/audio/audio_recorder_impl.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 namespace copresence { | 72 namespace copresence { |
| 73 | 73 |
| 74 class AudioRecorderTest : public testing::Test { | 74 class AudioRecorderTest : public testing::Test { |
| 75 public: | 75 public: |
| 76 AudioRecorderTest() : total_samples_(0), recorder_(NULL) { | 76 AudioRecorderTest() : total_samples_(0), recorder_(NULL) { |
| 77 if (!media::AudioManager::Get()) | 77 if (!media::AudioManager::Get()) |
| 78 media::AudioManager::CreateForTesting(); | 78 media::AudioManager::CreateForTesting(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 virtual ~AudioRecorderTest() { | 81 ~AudioRecorderTest() override { |
| 82 DeleteRecorder(); | 82 DeleteRecorder(); |
| 83 for (size_t i = 0; i < channel_data_.size(); ++i) | 83 for (size_t i = 0; i < channel_data_.size(); ++i) |
| 84 base::AlignedFree(channel_data_[i]); | 84 base::AlignedFree(channel_data_[i]); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void CreateSimpleRecorder() { | 87 void CreateSimpleRecorder() { |
| 88 DeleteRecorder(); | 88 DeleteRecorder(); |
| 89 recorder_ = new AudioRecorderImpl(); | 89 recorder_ = new AudioRecorderImpl(); |
| 90 recorder_->Initialize( | 90 recorder_->Initialize( |
| 91 base::Bind(&AudioRecorderTest::DecodeSamples, base::Unretained(this))); | 91 base::Bind(&AudioRecorderTest::DecodeSamples, base::Unretained(this))); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 kDefaultChannels, kDefaultSampleRate, kDefaultBitsPerSample, kNumSamples); | 246 kDefaultChannels, kDefaultSampleRate, kDefaultBitsPerSample, kNumSamples); |
| 247 | 247 |
| 248 RecordAndVerifySamples(); | 248 RecordAndVerifySamples(); |
| 249 | 249 |
| 250 DeleteRecorder(); | 250 DeleteRecorder(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 // TODO(rkc): Add tests with recording different sample rates. | 253 // TODO(rkc): Add tests with recording different sample rates. |
| 254 | 254 |
| 255 } // namespace copresence | 255 } // namespace copresence |
| OLD | NEW |