| 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 | 7 |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/environment.h" | 8 #include "base/environment.h" |
| 10 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 11 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 13 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 14 #include "base/test/test_timeouts.h" | 13 #include "base/test/test_timeouts.h" |
| 15 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 16 #include "base/win/scoped_com_initializer.h" | 15 #include "base/win/scoped_com_initializer.h" |
| 17 #include "media/audio/audio_io.h" | 16 #include "media/audio/audio_io.h" |
| 18 #include "media/audio/audio_manager.h" | 17 #include "media/audio/audio_manager.h" |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 base::MessageLoopForUI loop; | 371 base::MessageLoopForUI loop; |
| 373 MockAudioSourceCallback source; | 372 MockAudioSourceCallback source; |
| 374 | 373 |
| 375 // Create default WASAPI output stream which plays out in stereo using | 374 // Create default WASAPI output stream which plays out in stereo using |
| 376 // the shared mixing rate. The default buffer size is 10ms. | 375 // the shared mixing rate. The default buffer size is 10ms. |
| 377 AudioOutputStreamWrapper aosw(audio_manager.get()); | 376 AudioOutputStreamWrapper aosw(audio_manager.get()); |
| 378 AudioOutputStream* aos = aosw.Create(); | 377 AudioOutputStream* aos = aosw.Create(); |
| 379 EXPECT_TRUE(aos->Open()); | 378 EXPECT_TRUE(aos->Open()); |
| 380 | 379 |
| 381 // Derive the expected size in bytes of each packet. | 380 // Derive the expected size in bytes of each packet. |
| 382 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * | 381 uint32_t bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * |
| 383 (aosw.bits_per_sample() / 8); | 382 (aosw.bits_per_sample() / 8); |
| 384 | 383 |
| 385 // Wait for the first callback and verify its parameters. Ignore any | 384 // Wait for the first callback and verify its parameters. Ignore any |
| 386 // subsequent callbacks that might arrive. | 385 // subsequent callbacks that might arrive. |
| 387 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0)) | 386 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0)) |
| 388 .WillOnce(DoAll(QuitLoop(loop.task_runner()), | 387 .WillOnce(DoAll(QuitLoop(loop.task_runner()), |
| 389 Return(aosw.samples_per_packet()))) | 388 Return(aosw.samples_per_packet()))) |
| 390 .WillRepeatedly(Return(0)); | 389 .WillRepeatedly(Return(0)); |
| 391 | 390 |
| 392 aos->Start(&source); | 391 aos->Start(&source); |
| 393 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 392 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 base::MessageLoopForUI loop; | 566 base::MessageLoopForUI loop; |
| 568 MockAudioSourceCallback source; | 567 MockAudioSourceCallback source; |
| 569 | 568 |
| 570 // Create exclusive-mode WASAPI output stream which plays out in stereo | 569 // Create exclusive-mode WASAPI output stream which plays out in stereo |
| 571 // using the minimum buffer size at 48kHz sample rate. | 570 // using the minimum buffer size at 48kHz sample rate. |
| 572 AudioOutputStreamWrapper aosw(audio_manager.get()); | 571 AudioOutputStreamWrapper aosw(audio_manager.get()); |
| 573 AudioOutputStream* aos = aosw.Create(48000, 160); | 572 AudioOutputStream* aos = aosw.Create(48000, 160); |
| 574 EXPECT_TRUE(aos->Open()); | 573 EXPECT_TRUE(aos->Open()); |
| 575 | 574 |
| 576 // Derive the expected size in bytes of each packet. | 575 // Derive the expected size in bytes of each packet. |
| 577 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * | 576 uint32_t bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * |
| 578 (aosw.bits_per_sample() / 8); | 577 (aosw.bits_per_sample() / 8); |
| 579 | 578 |
| 580 // Wait for the first callback and verify its parameters. | 579 // Wait for the first callback and verify its parameters. |
| 581 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0)) | 580 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0)) |
| 582 .WillOnce(DoAll(QuitLoop(loop.task_runner()), | 581 .WillOnce(DoAll(QuitLoop(loop.task_runner()), |
| 583 Return(aosw.samples_per_packet()))) | 582 Return(aosw.samples_per_packet()))) |
| 584 .WillRepeatedly(Return(aosw.samples_per_packet())); | 583 .WillRepeatedly(Return(aosw.samples_per_packet())); |
| 585 | 584 |
| 586 aos->Start(&source); | 585 aos->Start(&source); |
| 587 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 586 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 588 TestTimeouts::action_timeout()); | 587 TestTimeouts::action_timeout()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 601 base::MessageLoopForUI loop; | 600 base::MessageLoopForUI loop; |
| 602 MockAudioSourceCallback source; | 601 MockAudioSourceCallback source; |
| 603 | 602 |
| 604 // Create exclusive-mode WASAPI output stream which plays out in stereo | 603 // Create exclusive-mode WASAPI output stream which plays out in stereo |
| 605 // using the minimum buffer size at 44.1kHz sample rate. | 604 // using the minimum buffer size at 44.1kHz sample rate. |
| 606 AudioOutputStreamWrapper aosw(audio_manager.get()); | 605 AudioOutputStreamWrapper aosw(audio_manager.get()); |
| 607 AudioOutputStream* aos = aosw.Create(44100, 160); | 606 AudioOutputStream* aos = aosw.Create(44100, 160); |
| 608 EXPECT_TRUE(aos->Open()); | 607 EXPECT_TRUE(aos->Open()); |
| 609 | 608 |
| 610 // Derive the expected size in bytes of each packet. | 609 // Derive the expected size in bytes of each packet. |
| 611 uint32 bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * | 610 uint32_t bytes_per_packet = aosw.channels() * aosw.samples_per_packet() * |
| 612 (aosw.bits_per_sample() / 8); | 611 (aosw.bits_per_sample() / 8); |
| 613 | 612 |
| 614 // Wait for the first callback and verify its parameters. | 613 // Wait for the first callback and verify its parameters. |
| 615 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0)) | 614 EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0)) |
| 616 .WillOnce(DoAll(QuitLoop(loop.task_runner()), | 615 .WillOnce(DoAll(QuitLoop(loop.task_runner()), |
| 617 Return(aosw.samples_per_packet()))) | 616 Return(aosw.samples_per_packet()))) |
| 618 .WillRepeatedly(Return(aosw.samples_per_packet())); | 617 .WillRepeatedly(Return(aosw.samples_per_packet())); |
| 619 | 618 |
| 620 aos->Start(&source); | 619 aos->Start(&source); |
| 621 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 620 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 622 TestTimeouts::action_timeout()); | 621 TestTimeouts::action_timeout()); |
| 623 loop.Run(); | 622 loop.Run(); |
| 624 aos->Stop(); | 623 aos->Stop(); |
| 625 aos->Close(); | 624 aos->Close(); |
| 626 } | 625 } |
| 627 | 626 |
| 628 } // namespace media | 627 } // namespace media |
| OLD | NEW |