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

Side by Side Diff: components/audio_modem/audio_recorder_unittest.cc

Issue 1892433002: Moving device description utils from AudioManager[Base] into AudioDeviceDescription; to be shared b… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase Created 4 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/audio_modem/audio_recorder.h" 5 #include "components/audio_modem/audio_recorder.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/aligned_memory.h" 14 #include "base/memory/aligned_memory.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "components/audio_modem/audio_recorder_impl.h" 18 #include "components/audio_modem/audio_recorder_impl.h"
19 #include "components/audio_modem/public/audio_modem_types.h" 19 #include "components/audio_modem/public/audio_modem_types.h"
20 #include "components/audio_modem/test/random_samples.h" 20 #include "components/audio_modem/test/random_samples.h"
21 #include "content/public/test/test_browser_thread_bundle.h" 21 #include "content/public/test/test_browser_thread_bundle.h"
22 #include "media/audio/audio_device_description.h"
22 #include "media/audio/audio_manager.h" 23 #include "media/audio/audio_manager.h"
23 #include "media/audio/audio_manager_base.h"
24 #include "media/base/audio_bus.h" 24 #include "media/base/audio_bus.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 26
27 namespace { 27 namespace {
28 28
29 const size_t kSomeNumber = 0x9999; 29 const size_t kSomeNumber = 0x9999;
30 30
31 class TestAudioInputStream : public media::AudioInputStream { 31 class TestAudioInputStream : public media::AudioInputStream {
32 public: 32 public:
33 TestAudioInputStream(const media::AudioParameters& params, 33 TestAudioInputStream(const media::AudioParameters& params,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 base::RunLoop().RunUntilIdle(); 107 base::RunLoop().RunUntilIdle();
108 } else { 108 } else {
109 CreateRecorder(kSomeNumber); 109 CreateRecorder(kSomeNumber);
110 } 110 }
111 } 111 }
112 112
113 void CreateRecorder(size_t samples) { 113 void CreateRecorder(size_t samples) {
114 DeleteRecorder(); 114 DeleteRecorder();
115 115
116 params_ = media::AudioManager::Get()->GetInputStreamParameters( 116 params_ = media::AudioManager::Get()->GetInputStreamParameters(
117 media::AudioManagerBase::kDefaultDeviceId); 117 media::AudioDeviceDescription::kDefaultDeviceId);
118 118
119 channel_data_.clear(); 119 channel_data_.clear();
120 channel_data_.push_back(GenerateSamples(0x1337, samples)); 120 channel_data_.push_back(GenerateSamples(0x1337, samples));
121 channel_data_.push_back(GenerateSamples(0x7331, samples)); 121 channel_data_.push_back(GenerateSamples(0x7331, samples));
122 122
123 total_samples_ = samples; 123 total_samples_ = samples;
124 124
125 recorder_ = new AudioRecorderImpl(); 125 recorder_ = new AudioRecorderImpl();
126 recorder_->set_input_stream_for_testing( 126 recorder_->set_input_stream_for_testing(
127 new TestAudioInputStream(params_, channel_data_, samples)); 127 new TestAudioInputStream(params_, channel_data_, samples));
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 CreateRecorder(kNumSamples); 273 CreateRecorder(kNumSamples);
274 274
275 RecordAndVerifySamples(); 275 RecordAndVerifySamples();
276 276
277 DeleteRecorder(); 277 DeleteRecorder();
278 } 278 }
279 279
280 // TODO(rkc): Add tests with recording different sample rates. 280 // TODO(rkc): Add tests with recording different sample rates.
281 281
282 } // namespace audio_modem 282 } // namespace audio_modem
OLDNEW
« no previous file with comments | « components/audio_modem/audio_recorder_impl.cc ('k') | content/browser/renderer_host/media/audio_input_renderer_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698