| 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 "media/audio/win/audio_low_latency_input_win.h" | 5 #include "media/audio/win/audio_low_latency_input_win.h" | 
| 6 | 6 | 
| 7 #include <mmsystem.h> | 7 #include <mmsystem.h> | 
| 8 #include <stddef.h> | 8 #include <stddef.h> | 
| 9 #include <stdint.h> | 9 #include <stdint.h> | 
| 10 #include <windows.h> | 10 #include <windows.h> | 
| 11 | 11 | 
| 12 #include <memory> | 12 #include <memory> | 
| 13 | 13 | 
| 14 #include "base/environment.h" | 14 #include "base/environment.h" | 
| 15 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" | 
| 16 #include "base/macros.h" | 16 #include "base/macros.h" | 
|  | 17 #include "base/memory/ptr_util.h" | 
| 17 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" | 
| 18 #include "base/path_service.h" | 19 #include "base/path_service.h" | 
| 19 #include "base/run_loop.h" | 20 #include "base/run_loop.h" | 
| 20 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" | 
| 21 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" | 
| 22 #include "base/test/test_timeouts.h" | 23 #include "base/test/test_timeouts.h" | 
| 23 #include "base/win/scoped_com_initializer.h" | 24 #include "base/win/scoped_com_initializer.h" | 
| 24 #include "media/audio/audio_device_description.h" | 25 #include "media/audio/audio_device_description.h" | 
| 25 #include "media/audio/audio_device_info_accessor_for_tests.h" | 26 #include "media/audio/audio_device_info_accessor_for_tests.h" | 
| 26 #include "media/audio/audio_io.h" | 27 #include "media/audio/audio_io.h" | 
| 27 #include "media/audio/audio_manager.h" | 28 #include "media/audio/audio_manager.h" | 
| 28 #include "media/audio/audio_unittest_util.h" | 29 #include "media/audio/audio_unittest_util.h" | 
|  | 30 #include "media/audio/test_audio_thread.h" | 
| 29 #include "media/audio/win/core_audio_util_win.h" | 31 #include "media/audio/win/core_audio_util_win.h" | 
| 30 #include "media/base/seekable_buffer.h" | 32 #include "media/base/seekable_buffer.h" | 
| 31 #include "testing/gmock/include/gmock/gmock.h" | 33 #include "testing/gmock/include/gmock/gmock.h" | 
| 32 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" | 
| 33 | 35 | 
| 34 using ::testing::_; | 36 using ::testing::_; | 
| 35 using ::testing::AnyNumber; | 37 using ::testing::AnyNumber; | 
| 36 using ::testing::AtLeast; | 38 using ::testing::AtLeast; | 
| 37 using ::testing::Gt; | 39 using ::testing::Gt; | 
| 38 using ::testing::NotNull; | 40 using ::testing::NotNull; | 
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 254  private: | 256  private: | 
| 255   AudioInputStream* stream_; | 257   AudioInputStream* stream_; | 
| 256 | 258 | 
| 257   DISALLOW_COPY_AND_ASSIGN(ScopedAudioInputStream); | 259   DISALLOW_COPY_AND_ASSIGN(ScopedAudioInputStream); | 
| 258 }; | 260 }; | 
| 259 | 261 | 
| 260 class WinAudioInputTest : public ::testing::Test { | 262 class WinAudioInputTest : public ::testing::Test { | 
| 261  public: | 263  public: | 
| 262   WinAudioInputTest() { | 264   WinAudioInputTest() { | 
| 263     audio_manager_ = | 265     audio_manager_ = | 
| 264         AudioManager::CreateForTesting(message_loop_.task_runner()); | 266         AudioManager::CreateForTesting(base::MakeUnique<TestAudioThread>()); | 
| 265     base::RunLoop().RunUntilIdle(); | 267     base::RunLoop().RunUntilIdle(); | 
| 266   } | 268   } | 
| 267   ~WinAudioInputTest() override { | 269   ~WinAudioInputTest() override { audio_manager_->Shutdown(); } | 
| 268     audio_manager_.reset(); |  | 
| 269     base::RunLoop().RunUntilIdle(); |  | 
| 270   } |  | 
| 271 | 270 | 
| 272  protected: | 271  protected: | 
| 273   base::MessageLoop message_loop_; | 272   base::MessageLoop message_loop_; | 
| 274   ScopedAudioManagerPtr audio_manager_; | 273   std::unique_ptr<AudioManager> audio_manager_; | 
| 275 }; | 274 }; | 
| 276 | 275 | 
| 277 // Verify that we can retrieve the current hardware/mixing sample rate | 276 // Verify that we can retrieve the current hardware/mixing sample rate | 
| 278 // for all available input devices. | 277 // for all available input devices. | 
| 279 TEST_F(WinAudioInputTest, WASAPIAudioInputStreamHardwareSampleRate) { | 278 TEST_F(WinAudioInputTest, WASAPIAudioInputStreamHardwareSampleRate) { | 
| 280   ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndInputDevices(audio_manager_.get())); | 279   ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndInputDevices(audio_manager_.get())); | 
| 281 | 280 | 
| 282   // Retrieve a list of all available input devices. | 281   // Retrieve a list of all available input devices. | 
| 283   media::AudioDeviceDescriptions device_descriptions; | 282   media::AudioDeviceDescriptions device_descriptions; | 
| 284   AudioDeviceInfoAccessorForTests(audio_manager_.get()) | 283   AudioDeviceInfoAccessorForTests(audio_manager_.get()) | 
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 554     ais->Start(&file_sink); | 553     ais->Start(&file_sink); | 
| 555     base::PlatformThread::Sleep(TestTimeouts::action_timeout()); | 554     base::PlatformThread::Sleep(TestTimeouts::action_timeout()); | 
| 556     // base::PlatformThread::Sleep(base::TimeDelta::FromMinutes(10)); | 555     // base::PlatformThread::Sleep(base::TimeDelta::FromMinutes(10)); | 
| 557     ais->Stop(); | 556     ais->Stop(); | 
| 558     VLOG(0) << ">> Recording has stopped."; | 557     VLOG(0) << ">> Recording has stopped."; | 
| 559     ais.Close(); | 558     ais.Close(); | 
| 560   } | 559   } | 
| 561 } | 560 } | 
| 562 | 561 | 
| 563 }  // namespace media | 562 }  // namespace media | 
| OLD | NEW | 
|---|