| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/environment.h" | 9 #include "base/environment.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/test/test_timeouts.h" | 13 #include "base/test/test_timeouts.h" |
| 14 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
| 15 #include "media/audio/audio_device_description.h" | 15 #include "media/audio/audio_device_description.h" |
| 16 #include "media/audio/audio_device_info_accessor_for_tests.h" |
| 16 #include "media/audio/audio_io.h" | 17 #include "media/audio/audio_io.h" |
| 17 #include "media/audio/audio_manager_base.h" | 18 #include "media/audio/audio_manager_base.h" |
| 18 #include "media/audio/audio_unittest_util.h" | 19 #include "media/audio/audio_unittest_util.h" |
| 19 #include "media/audio/mac/audio_low_latency_input_mac.h" | 20 #include "media/audio/mac/audio_low_latency_input_mac.h" |
| 20 #include "media/base/seekable_buffer.h" | 21 #include "media/base/seekable_buffer.h" |
| 21 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 23 | 24 |
| 24 using ::testing::_; | 25 using ::testing::_; |
| 25 using ::testing::AnyNumber; | 26 using ::testing::AnyNumber; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // Wait for the AudioManager to finish any initialization on the audio loop. | 117 // Wait for the AudioManager to finish any initialization on the audio loop. |
| 117 base::RunLoop().RunUntilIdle(); | 118 base::RunLoop().RunUntilIdle(); |
| 118 } | 119 } |
| 119 | 120 |
| 120 ~MacAudioInputTest() override { | 121 ~MacAudioInputTest() override { |
| 121 audio_manager_.reset(); | 122 audio_manager_.reset(); |
| 122 base::RunLoop().RunUntilIdle(); | 123 base::RunLoop().RunUntilIdle(); |
| 123 } | 124 } |
| 124 | 125 |
| 125 bool InputDevicesAvailable() { | 126 bool InputDevicesAvailable() { |
| 126 return audio_manager_->HasAudioInputDevices(); | 127 return AudioDeviceInfoAccessorForTests(audio_manager_.get()) |
| 128 .HasAudioInputDevices(); |
| 127 } | 129 } |
| 128 | 130 |
| 129 // Convenience method which creates a default AudioInputStream object using | 131 // Convenience method which creates a default AudioInputStream object using |
| 130 // a 10ms frame size and a sample rate which is set to the hardware sample | 132 // a 10ms frame size and a sample rate which is set to the hardware sample |
| 131 // rate. | 133 // rate. |
| 132 AudioInputStream* CreateDefaultAudioInputStream() { | 134 AudioInputStream* CreateDefaultAudioInputStream() { |
| 133 int fs = static_cast<int>(AUAudioInputStream::HardwareSampleRate()); | 135 int fs = static_cast<int>(AUAudioInputStream::HardwareSampleRate()); |
| 134 int samples_per_packet = fs / 100; | 136 int samples_per_packet = fs / 100; |
| 135 AudioInputStream* ais = audio_manager_->MakeAudioInputStream( | 137 AudioInputStream* ais = audio_manager_->MakeAudioInputStream( |
| 136 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, | 138 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 WriteToFileAudioSink file_sink(file_name); | 282 WriteToFileAudioSink file_sink(file_name); |
| 281 fprintf(stderr, " >> Speak into the mic while recording...\n"); | 283 fprintf(stderr, " >> Speak into the mic while recording...\n"); |
| 282 ais->Start(&file_sink); | 284 ais->Start(&file_sink); |
| 283 base::PlatformThread::Sleep(TestTimeouts::action_timeout()); | 285 base::PlatformThread::Sleep(TestTimeouts::action_timeout()); |
| 284 ais->Stop(); | 286 ais->Stop(); |
| 285 fprintf(stderr, " >> Recording has stopped.\n"); | 287 fprintf(stderr, " >> Recording has stopped.\n"); |
| 286 ais->Close(); | 288 ais->Close(); |
| 287 } | 289 } |
| 288 | 290 |
| 289 } // namespace media | 291 } // namespace media |
| OLD | NEW |