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_output_win.h" | 5 #include "media/audio/win/audio_low_latency_output_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <mmsystem.h> | 8 #include <mmsystem.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.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/memory/ptr_util.h" |
16 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
17 #include "base/path_service.h" | 18 #include "base/path_service.h" |
18 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
19 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
20 #include "base/test/test_timeouts.h" | 21 #include "base/test/test_timeouts.h" |
21 #include "base/time/time.h" | 22 #include "base/time/time.h" |
22 #include "base/win/scoped_com_initializer.h" | 23 #include "base/win/scoped_com_initializer.h" |
23 #include "media/audio/audio_device_description.h" | 24 #include "media/audio/audio_device_description.h" |
24 #include "media/audio/audio_device_info_accessor_for_tests.h" | 25 #include "media/audio/audio_device_info_accessor_for_tests.h" |
25 #include "media/audio/audio_io.h" | 26 #include "media/audio/audio_io.h" |
26 #include "media/audio/audio_manager.h" | 27 #include "media/audio/audio_manager.h" |
27 #include "media/audio/audio_unittest_util.h" | 28 #include "media/audio/audio_unittest_util.h" |
28 #include "media/audio/mock_audio_source_callback.h" | 29 #include "media/audio/mock_audio_source_callback.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/decoder_buffer.h" | 32 #include "media/base/decoder_buffer.h" |
31 #include "media/base/seekable_buffer.h" | 33 #include "media/base/seekable_buffer.h" |
32 #include "media/base/test_data_util.h" | 34 #include "media/base/test_data_util.h" |
33 #include "testing/gmock/include/gmock/gmock.h" | 35 #include "testing/gmock/include/gmock/gmock.h" |
34 #include "testing/gmock_mutant.h" | 36 #include "testing/gmock_mutant.h" |
35 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
36 | 38 |
37 using ::testing::_; | 39 using ::testing::_; |
38 using ::testing::AnyNumber; | 40 using ::testing::AnyNumber; |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 AudioManager* audio_manager) { | 232 AudioManager* audio_manager) { |
231 AudioOutputStreamWrapper aosw(audio_manager); | 233 AudioOutputStreamWrapper aosw(audio_manager); |
232 AudioOutputStream* aos = aosw.Create(); | 234 AudioOutputStream* aos = aosw.Create(); |
233 return aos; | 235 return aos; |
234 } | 236 } |
235 | 237 |
236 class WASAPIAudioOutputStreamTest : public ::testing::Test { | 238 class WASAPIAudioOutputStreamTest : public ::testing::Test { |
237 public: | 239 public: |
238 WASAPIAudioOutputStreamTest() { | 240 WASAPIAudioOutputStreamTest() { |
239 audio_manager_ = | 241 audio_manager_ = |
240 AudioManager::CreateForTesting(message_loop_.task_runner()); | 242 AudioManager::CreateForTesting(base::MakeUnique<TestAudioThread>()); |
241 base::RunLoop().RunUntilIdle(); | 243 base::RunLoop().RunUntilIdle(); |
242 } | 244 } |
243 ~WASAPIAudioOutputStreamTest() override { | 245 ~WASAPIAudioOutputStreamTest() override { audio_manager_->Shutdown(); } |
244 audio_manager_.reset(); | |
245 base::RunLoop().RunUntilIdle(); | |
246 } | |
247 | 246 |
248 protected: | 247 protected: |
249 base::MessageLoopForUI message_loop_; | 248 base::MessageLoopForUI message_loop_; |
250 ScopedAudioManagerPtr audio_manager_; | 249 std::unique_ptr<AudioManager> audio_manager_; |
251 }; | 250 }; |
252 | 251 |
253 // Test Create(), Close() calling sequence. | 252 // Test Create(), Close() calling sequence. |
254 TEST_F(WASAPIAudioOutputStreamTest, CreateAndClose) { | 253 TEST_F(WASAPIAudioOutputStreamTest, CreateAndClose) { |
255 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager_.get())); | 254 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager_.get())); |
256 AudioOutputStream* aos = CreateDefaultAudioOutputStream(audio_manager_.get()); | 255 AudioOutputStream* aos = CreateDefaultAudioOutputStream(audio_manager_.get()); |
257 aos->Close(); | 256 aos->Close(); |
258 } | 257 } |
259 | 258 |
260 // Test Open(), Close() calling sequence. | 259 // Test Open(), Close() calling sequence. |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 aos->Start(&source); | 613 aos->Start(&source); |
615 message_loop_.task_runner()->PostDelayedTask( | 614 message_loop_.task_runner()->PostDelayedTask( |
616 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 615 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
617 TestTimeouts::action_timeout()); | 616 TestTimeouts::action_timeout()); |
618 base::RunLoop().Run(); | 617 base::RunLoop().Run(); |
619 aos->Stop(); | 618 aos->Stop(); |
620 aos->Close(); | 619 aos->Close(); |
621 } | 620 } |
622 | 621 |
623 } // namespace media | 622 } // namespace media |
OLD | NEW |