| 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_io.h" | 16 #include "media/audio/audio_io.h" |
| 17 #include "media/audio/audio_manager_base.h" | 17 #include "media/audio/audio_manager_base.h" |
| 18 #include "media/audio/audio_unittest_util.h" | 18 #include "media/audio/audio_unittest_util.h" |
| 19 #include "media/audio/mac/audio_low_latency_input_mac.h" | 19 #include "media/audio/mac/audio_low_latency_input_mac.h" |
| 20 #include "media/audio/simple_sources.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; |
| 26 using ::testing::AtLeast; | 27 using ::testing::AtLeast; |
| 27 using ::testing::Ge; | 28 using ::testing::Ge; |
| 28 using ::testing::NotNull; | 29 using ::testing::NotNull; |
| 29 | 30 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 fprintf(stderr, " Sample rate: %d\n", fs); | 280 fprintf(stderr, " Sample rate: %d\n", fs); |
| 280 WriteToFileAudioSink file_sink(file_name); | 281 WriteToFileAudioSink file_sink(file_name); |
| 281 fprintf(stderr, " >> Speak into the mic while recording...\n"); | 282 fprintf(stderr, " >> Speak into the mic while recording...\n"); |
| 282 ais->Start(&file_sink); | 283 ais->Start(&file_sink); |
| 283 base::PlatformThread::Sleep(TestTimeouts::action_timeout()); | 284 base::PlatformThread::Sleep(TestTimeouts::action_timeout()); |
| 284 ais->Stop(); | 285 ais->Stop(); |
| 285 fprintf(stderr, " >> Recording has stopped.\n"); | 286 fprintf(stderr, " >> Recording has stopped.\n"); |
| 286 ais->Close(); | 287 ais->Close(); |
| 287 } | 288 } |
| 288 | 289 |
| 290 TEST_F(MacAudioInputTest, AudioOutputTest) { |
| 291 AudioParameters params = audio_manager_->GetDefaultOutputStreamParameters(); |
| 292 LOG(ERROR) << "Params: " << params.AsHumanReadableString(); |
| 293 |
| 294 SineWaveAudioSource source(params.channels(), 440, params.sample_rate()); |
| 295 AudioOutputStream* stream = |
| 296 audio_manager_->MakeAudioOutputStreamProxy(params, ""); |
| 297 ASSERT_TRUE(stream->Open()); |
| 298 stream->Start(&source); |
| 299 |
| 300 base::RunLoop run_loop; |
| 301 message_loop_.task_runner()->PostDelayedTask( |
| 302 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(5)); |
| 303 run_loop.Run(); |
| 304 stream->Stop(); |
| 305 stream->Close(); |
| 306 } |
| 307 |
| 289 } // namespace media | 308 } // namespace media |
| OLD | NEW |