OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" | 8 #include "base/basictypes.h" |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 AudioParameters::kAudioCDSampleRate, 16, samples_100_ms)); | 580 AudioParameters::kAudioCDSampleRate, 16, samples_100_ms)); |
581 ASSERT_TRUE(NULL != oas); | 581 ASSERT_TRUE(NULL != oas); |
582 | 582 |
583 NiceMock<MockAudioSource> source; | 583 NiceMock<MockAudioSource> source; |
584 EXPECT_TRUE(oas->Open()); | 584 EXPECT_TRUE(oas->Open()); |
585 | 585 |
586 uint32 bytes_100_ms = samples_100_ms * 2; | 586 uint32 bytes_100_ms = samples_100_ms * 2; |
587 | 587 |
588 // We expect the amount of pending bytes will reaching 2 times of | 588 // We expect the amount of pending bytes will reaching 2 times of |
589 // |bytes_100_ms| because the audio output stream has a triple buffer scheme. | 589 // |bytes_100_ms| because the audio output stream has a triple buffer scheme. |
590 // And then we will try to provide zero data so the amount of pending bytes | 590 // From that it would decrease as we are playing the data but not providing |
591 // will go down and eventually read zero. | 591 // new one. And then we will try to provide zero data so the amount of |
| 592 // pending bytes will go down and eventually read zero. |
592 InSequence s; | 593 InSequence s; |
593 EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, | 594 EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, |
594 Field(&AudioBuffersState::pending_bytes, 0))) | 595 Field(&AudioBuffersState::pending_bytes, 0))) |
595 .WillOnce(Return(bytes_100_ms)); | 596 .WillOnce(Return(bytes_100_ms)); |
596 EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, | 597 EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, |
597 Field(&AudioBuffersState::pending_bytes, | 598 Field(&AudioBuffersState::pending_bytes, |
598 bytes_100_ms))) | 599 bytes_100_ms))) |
599 .WillOnce(Return(bytes_100_ms)); | 600 .WillOnce(Return(bytes_100_ms)); |
600 EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, | 601 EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, |
601 Field(&AudioBuffersState::pending_bytes, | 602 Field(&AudioBuffersState::pending_bytes, |
602 2 * bytes_100_ms))) | 603 2 * bytes_100_ms))) |
603 .WillOnce(Return(bytes_100_ms)); | 604 .WillOnce(Return(bytes_100_ms)); |
604 EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, | 605 EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, |
605 Field(&AudioBuffersState::pending_bytes, | 606 Field(&AudioBuffersState::pending_bytes, |
606 2 * bytes_100_ms))) | 607 2 * bytes_100_ms))) |
607 .WillOnce(Return(0)); | 608 .Times(AnyNumber()) |
| 609 .WillRepeatedly(Return(0)); |
608 EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, | 610 EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, |
609 Field(&AudioBuffersState::pending_bytes, | 611 Field(&AudioBuffersState::pending_bytes, |
610 bytes_100_ms))) | 612 bytes_100_ms))) |
611 .WillOnce(Return(0)); | 613 .Times(AnyNumber()) |
| 614 .WillRepeatedly(Return(0)); |
612 EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, | 615 EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, |
613 Field(&AudioBuffersState::pending_bytes, 0))) | 616 Field(&AudioBuffersState::pending_bytes, 0))) |
614 .Times(AnyNumber()) | 617 .Times(AnyNumber()) |
615 .WillRepeatedly(Return(0)); | 618 .WillRepeatedly(Return(0)); |
616 | 619 |
617 oas->Start(&source); | 620 oas->Start(&source); |
618 ::Sleep(500); | 621 ::Sleep(500); |
619 oas->Stop(); | 622 oas->Stop(); |
620 oas->Close(); | 623 oas->Close(); |
621 } | 624 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 | 728 |
726 oas->Start(&source); | 729 oas->Start(&source); |
727 | 730 |
728 ::WaitForSingleObject(thread, INFINITE); | 731 ::WaitForSingleObject(thread, INFINITE); |
729 ::CloseHandle(thread); | 732 ::CloseHandle(thread); |
730 delete sockets[1]; | 733 delete sockets[1]; |
731 | 734 |
732 oas->Stop(); | 735 oas->Stop(); |
733 oas->Close(); | 736 oas->Close(); |
734 } | 737 } |
OLD | NEW |