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 <windows.h> | 5 #include <windows.h> |
6 #include <mmsystem.h> | 6 #include <mmsystem.h> |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/base_paths.h" | 12 #include "base/base_paths.h" |
13 #include "base/memory/aligned_memory.h" | 13 #include "base/memory/aligned_memory.h" |
14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
17 #include "base/sync_socket.h" | 17 #include "base/sync_socket.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "base/win/scoped_com_initializer.h" | 19 #include "base/win/scoped_com_initializer.h" |
20 #include "base/win/windows_version.h" | 20 #include "base/win/windows_version.h" |
21 #include "media/audio/audio_device_info_accessor_for_tests.h" | 21 #include "media/audio/audio_device_info_accessor_for_tests.h" |
22 #include "media/audio/audio_io.h" | 22 #include "media/audio/audio_io.h" |
23 #include "media/audio/audio_manager.h" | 23 #include "media/audio/audio_manager.h" |
24 #include "media/audio/audio_unittest_util.h" | 24 #include "media/audio/audio_unittest_util.h" |
25 #include "media/audio/mock_audio_source_callback.h" | 25 #include "media/audio/mock_audio_source_callback.h" |
26 #include "media/audio/simple_sources.h" | 26 #include "media/audio/simple_sources.h" |
| 27 #include "media/audio/test_audio_thread.h" |
27 #include "media/base/limits.h" | 28 #include "media/base/limits.h" |
28 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
30 | 31 |
31 using ::testing::_; | 32 using ::testing::_; |
32 using ::testing::AnyNumber; | 33 using ::testing::AnyNumber; |
33 using ::testing::DoAll; | 34 using ::testing::DoAll; |
34 using ::testing::Field; | 35 using ::testing::Field; |
35 using ::testing::Invoke; | 36 using ::testing::Invoke; |
36 using ::testing::InSequence; | 37 using ::testing::InSequence; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 private: | 150 private: |
150 HANDLE fmap_; | 151 HANDLE fmap_; |
151 char* start_; | 152 char* start_; |
152 uint32_t size_; | 153 uint32_t size_; |
153 }; | 154 }; |
154 | 155 |
155 class WinAudioTest : public ::testing::Test { | 156 class WinAudioTest : public ::testing::Test { |
156 public: | 157 public: |
157 WinAudioTest() { | 158 WinAudioTest() { |
158 audio_manager_ = | 159 audio_manager_ = |
159 AudioManager::CreateForTesting(message_loop_.task_runner()); | 160 AudioManager::CreateForTesting(base::MakeUnique<TestAudioThread>()); |
160 audio_manager_device_info_ = | 161 audio_manager_device_info_ = |
161 base::MakeUnique<AudioDeviceInfoAccessorForTests>(audio_manager_.get()); | 162 base::MakeUnique<AudioDeviceInfoAccessorForTests>(audio_manager_.get()); |
162 base::RunLoop().RunUntilIdle(); | 163 base::RunLoop().RunUntilIdle(); |
163 } | 164 } |
164 ~WinAudioTest() override { | 165 ~WinAudioTest() override { audio_manager_->Shutdown(); } |
165 audio_manager_device_info_.reset(); | |
166 audio_manager_.reset(); | |
167 base::RunLoop().RunUntilIdle(); | |
168 } | |
169 | 166 |
170 protected: | 167 protected: |
171 base::MessageLoop message_loop_; | 168 base::MessageLoop message_loop_; |
172 ScopedAudioManagerPtr audio_manager_; | 169 std::unique_ptr<AudioManager> audio_manager_; |
173 std::unique_ptr<AudioDeviceInfoAccessorForTests> audio_manager_device_info_; | 170 std::unique_ptr<AudioDeviceInfoAccessorForTests> audio_manager_device_info_; |
174 }; | 171 }; |
175 | 172 |
176 // =========================================================================== | 173 // =========================================================================== |
177 // Validation of AudioManager::AUDIO_PCM_LINEAR | 174 // Validation of AudioManager::AUDIO_PCM_LINEAR |
178 // | 175 // |
179 // NOTE: | 176 // NOTE: |
180 // The tests can fail on the build bots when somebody connects to them via | 177 // The tests can fail on the build bots when somebody connects to them via |
181 // remote-desktop and the rdp client installs an audio device that fails to open | 178 // remote-desktop and the rdp client installs an audio device that fails to open |
182 // at some point, possibly when the connection goes idle. | 179 // at some point, possibly when the connection goes idle. |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 oas->Start(&source); | 661 oas->Start(&source); |
665 | 662 |
666 ::WaitForSingleObject(thread, INFINITE); | 663 ::WaitForSingleObject(thread, INFINITE); |
667 ::CloseHandle(thread); | 664 ::CloseHandle(thread); |
668 | 665 |
669 oas->Stop(); | 666 oas->Stop(); |
670 oas->Close(); | 667 oas->Close(); |
671 } | 668 } |
672 | 669 |
673 } // namespace media | 670 } // namespace media |
OLD | NEW |