Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Unified Diff: media/audio/win/audio_output_win_unittest.cc

Issue 10540034: Use 2 buffers on presumable good Windows boxes. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« media/audio/audio_util.cc ('K') | « media/audio/win/audio_manager_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/win/audio_output_win_unittest.cc
===================================================================
--- media/audio/win/audio_output_win_unittest.cc (revision 140416)
+++ media/audio/win/audio_output_win_unittest.cc (working copy)
@@ -76,7 +76,7 @@
int had_error_;
};
-const int kNumBuffers = 3;
+const int kMaxNumBuffers = 3;
// Specializes TestSourceBasic to detect that the AudioStream is using
// triple buffering correctly.
class TestSourceTripleBuffer : public TestSourceBasic {
@@ -92,14 +92,14 @@
AudioBuffersState buffers_state) {
// Call the base, which increments the callback_count_.
TestSourceBasic::OnMoreData(dest, max_size, buffers_state);
- if (callback_count() % kNumBuffers == 2) {
+ if (callback_count() % NumberOfWaveOutBuffers() == 2) {
set_error(!CompareExistingIfNotNULL(2, dest));
- } else if (callback_count() % kNumBuffers == 1) {
+ } else if (callback_count() % NumberOfWaveOutBuffers() == 1) {
set_error(!CompareExistingIfNotNULL(1, dest));
} else {
set_error(!CompareExistingIfNotNULL(0, dest));
}
- if (callback_count() > kNumBuffers) {
+ if (callback_count() > kMaxNumBuffers) {
set_error(buffer_address_[0] == buffer_address_[1]);
set_error(buffer_address_[1] == buffer_address_[2]);
}
@@ -114,7 +114,7 @@
return (entry == address);
}
- void* buffer_address_[kNumBuffers];
+ void* buffer_address_[kMaxNumBuffers];
};
// Specializes TestSourceBasic to simulate a source that blocks for some time
@@ -129,7 +129,7 @@
AudioBuffersState buffers_state) {
// Call the base, which increments the callback_count_.
TestSourceBasic::OnMoreData(dest, max_size, buffers_state);
- if (callback_count() > kNumBuffers) {
+ if (callback_count() > kMaxNumBuffers) {
::Sleep(lag_in_ms_);
}
return max_size;
@@ -312,7 +312,7 @@
EXPECT_TRUE(oas->Open());
oas->Start(&test_triple_buffer);
::Sleep(300);
- EXPECT_GT(test_triple_buffer.callback_count(), kNumBuffers);
+ EXPECT_GT(test_triple_buffer.callback_count(), kMaxNumBuffers);
EXPECT_FALSE(test_triple_buffer.had_error());
oas->Stop();
::Sleep(500);
@@ -606,28 +606,41 @@
// new one. And then we will try to provide zero data so the amount of
// pending bytes will go down and eventually read zero.
InSequence s;
+
EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms,
Field(&AudioBuffersState::pending_bytes, 0)))
.WillOnce(Return(bytes_100_ms));
+ switch (NumberOfWaveOutBuffers()) {
+ case 2:
+ EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms,
+ Field(&AudioBuffersState::pending_bytes,
+ bytes_100_ms)))
+ .Times(AnyNumber())
+ .WillRepeatedly(Return(0));
+ break;
+ case 3:
+ EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms,
+ Field(&AudioBuffersState::pending_bytes,
+ bytes_100_ms)))
+ .WillOnce(Return(bytes_100_ms));
+ EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms,
+ Field(&AudioBuffersState::pending_bytes,
+ 2 * bytes_100_ms)))
+ .WillOnce(Return(bytes_100_ms));
+ EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms,
+ Field(&AudioBuffersState::pending_bytes,
+ 2 * bytes_100_ms)))
+ .Times(AnyNumber())
+ .WillRepeatedly(Return(0));
+ EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms,
+ Field(&AudioBuffersState::pending_bytes,
+ bytes_100_ms)))
+ .Times(AnyNumber())
+ .WillRepeatedly(Return(0));
+ default:
+ ASSERT_TRUE(false) << "Unexpected number of buffers";
+ }
EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms,
- Field(&AudioBuffersState::pending_bytes,
- bytes_100_ms)))
- .WillOnce(Return(bytes_100_ms));
- EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms,
- Field(&AudioBuffersState::pending_bytes,
- 2 * bytes_100_ms)))
- .WillOnce(Return(bytes_100_ms));
- EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms,
- Field(&AudioBuffersState::pending_bytes,
- 2 * bytes_100_ms)))
- .Times(AnyNumber())
- .WillRepeatedly(Return(0));
- EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms,
- Field(&AudioBuffersState::pending_bytes,
- bytes_100_ms)))
- .Times(AnyNumber())
- .WillRepeatedly(Return(0));
- EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms,
Field(&AudioBuffersState::pending_bytes, 0)))
.Times(AnyNumber())
.WillRepeatedly(Return(0));
« media/audio/audio_util.cc ('K') | « media/audio/win/audio_manager_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698