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_io.h" | 25 #include "media/audio/audio_io.h" |
25 #include "media/audio/audio_manager.h" | 26 #include "media/audio/audio_manager.h" |
26 #include "media/audio/audio_unittest_util.h" | 27 #include "media/audio/audio_unittest_util.h" |
27 #include "media/audio/mock_audio_source_callback.h" | 28 #include "media/audio/mock_audio_source_callback.h" |
| 29 #include "media/audio/test_audio_thread.h" |
28 #include "media/audio/win/core_audio_util_win.h" | 30 #include "media/audio/win/core_audio_util_win.h" |
29 #include "media/base/decoder_buffer.h" | 31 #include "media/base/decoder_buffer.h" |
30 #include "media/base/seekable_buffer.h" | 32 #include "media/base/seekable_buffer.h" |
31 #include "media/base/test_data_util.h" | 33 #include "media/base/test_data_util.h" |
32 #include "testing/gmock/include/gmock/gmock.h" | 34 #include "testing/gmock/include/gmock/gmock.h" |
33 #include "testing/gmock_mutant.h" | 35 #include "testing/gmock_mutant.h" |
34 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
35 | 37 |
36 using ::testing::_; | 38 using ::testing::_; |
37 using ::testing::AnyNumber; | 39 using ::testing::AnyNumber; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 AudioManager* audio_manager) { | 230 AudioManager* audio_manager) { |
229 AudioOutputStreamWrapper aosw(audio_manager); | 231 AudioOutputStreamWrapper aosw(audio_manager); |
230 AudioOutputStream* aos = aosw.Create(); | 232 AudioOutputStream* aos = aosw.Create(); |
231 return aos; | 233 return aos; |
232 } | 234 } |
233 | 235 |
234 class WASAPIAudioOutputStreamTest : public ::testing::Test { | 236 class WASAPIAudioOutputStreamTest : public ::testing::Test { |
235 public: | 237 public: |
236 WASAPIAudioOutputStreamTest() { | 238 WASAPIAudioOutputStreamTest() { |
237 audio_manager_ = | 239 audio_manager_ = |
238 AudioManager::CreateForTesting(message_loop_.task_runner()); | 240 AudioManager::CreateForTesting(base::MakeUnique<TestAudioThread>()); |
239 base::RunLoop().RunUntilIdle(); | 241 base::RunLoop().RunUntilIdle(); |
240 } | 242 } |
241 ~WASAPIAudioOutputStreamTest() override { | 243 ~WASAPIAudioOutputStreamTest() override { audio_manager_->Shutdown(); } |
242 audio_manager_.reset(); | |
243 base::RunLoop().RunUntilIdle(); | |
244 } | |
245 | 244 |
246 protected: | 245 protected: |
247 base::MessageLoopForUI message_loop_; | 246 base::MessageLoopForUI message_loop_; |
248 ScopedAudioManagerPtr audio_manager_; | 247 std::unique_ptr<AudioManager> audio_manager_; |
249 }; | 248 }; |
250 | 249 |
251 // Test Create(), Close() calling sequence. | 250 // Test Create(), Close() calling sequence. |
252 TEST_F(WASAPIAudioOutputStreamTest, CreateAndClose) { | 251 TEST_F(WASAPIAudioOutputStreamTest, CreateAndClose) { |
253 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager_.get())); | 252 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager_.get())); |
254 AudioOutputStream* aos = CreateDefaultAudioOutputStream(audio_manager_.get()); | 253 AudioOutputStream* aos = CreateDefaultAudioOutputStream(audio_manager_.get()); |
255 aos->Close(); | 254 aos->Close(); |
256 } | 255 } |
257 | 256 |
258 // Test Open(), Close() calling sequence. | 257 // Test Open(), Close() calling sequence. |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 aos->Start(&source); | 611 aos->Start(&source); |
613 message_loop_.task_runner()->PostDelayedTask( | 612 message_loop_.task_runner()->PostDelayedTask( |
614 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 613 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
615 TestTimeouts::action_timeout()); | 614 TestTimeouts::action_timeout()); |
616 base::RunLoop().Run(); | 615 base::RunLoop().Run(); |
617 aos->Stop(); | 616 aos->Stop(); |
618 aos->Close(); | 617 aos->Close(); |
619 } | 618 } |
620 | 619 |
621 } // namespace media | 620 } // namespace media |
OLD | NEW |