diff options
author | fbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-20 18:58:58 +0000 |
---|---|---|
committer | fbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-20 18:58:58 +0000 |
commit | d033a6c9e41f59e9985bb8c86ddd819cc5a5cc03 (patch) | |
tree | 987415bc3ab724435c72984023d7bd2289eee908 /media/audio | |
parent | b6ab96da13cdfe15f38fbebcd22e0a1db5a50381 (diff) | |
download | chromium_src-d033a6c9e41f59e9985bb8c86ddd819cc5a5cc03.zip chromium_src-d033a6c9e41f59e9985bb8c86ddd819cc5a5cc03.tar.gz chromium_src-d033a6c9e41f59e9985bb8c86ddd819cc5a5cc03.tar.bz2 |
Bump kNumBuffers to 3
BUG=17940
TEST=This vid should not stutter http://fbarchard-v64.ad.corp.google.com/testmatrix/color/color2.mp4
Review URL: http://codereview.chromium.org/174134
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23849 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio')
-rw-r--r-- | media/audio/win/audio_output_win_unittest.cc | 33 | ||||
-rw-r--r-- | media/audio/win/waveout_output_win.cc | 5 |
2 files changed, 22 insertions, 16 deletions
diff --git a/media/audio/win/audio_output_win_unittest.cc b/media/audio/win/audio_output_win_unittest.cc index bc5b61a..2393957 100644 --- a/media/audio/win/audio_output_win_unittest.cc +++ b/media/audio/win/audio_output_win_unittest.cc @@ -71,26 +71,31 @@ bool IsRunningHeadless() { } // namespace. +const int kNumBuffers = 3; // Specializes TestSourceBasic to detect that the AudioStream is using -// double buffering correctly. -class TestSourceDoubleBuffer : public TestSourceBasic { +// triple buffering correctly. +class TestSourceTripleBuffer : public TestSourceBasic { public: - TestSourceDoubleBuffer() { + TestSourceTripleBuffer() { buffer_address_[0] = NULL; buffer_address_[1] = NULL; + buffer_address_[2] = NULL; } // Override of TestSourceBasic::OnMoreData. virtual size_t OnMoreData(AudioOutputStream* stream, void* dest, size_t max_size) { // Call the base, which increments the callback_count_. TestSourceBasic::OnMoreData(stream, dest, max_size); - if (callback_count() % 2) { + if (callback_count() % kNumBuffers == 2) { + set_error(!CompareExistingIfNotNULL(2, dest)); + } else if (callback_count() % kNumBuffers == 1) { set_error(!CompareExistingIfNotNULL(1, dest)); } else { set_error(!CompareExistingIfNotNULL(0, dest)); } - if (callback_count() > 2) { + if (callback_count() > kNumBuffers) { set_error(buffer_address_[0] == buffer_address_[1]); + set_error(buffer_address_[1] == buffer_address_[2]); } return max_size; } @@ -103,7 +108,7 @@ class TestSourceDoubleBuffer : public TestSourceBasic { return (entry == address); } - void* buffer_address_[2]; + void* buffer_address_[kNumBuffers]; }; // Specializes TestSourceBasic to simulate a source that blocks for some time @@ -117,7 +122,7 @@ class TestSourceLaggy : public TestSourceBasic { void* dest, size_t max_size) { // Call the base, which increments the callback_count_. TestSourceBasic::OnMoreData(stream, dest, max_size); - if (callback_count() > 2) { + if (callback_count() > kNumBuffers) { ::Sleep(lag_in_ms_); } return max_size; @@ -132,7 +137,7 @@ class TestSourceLaggy : public TestSourceBasic { // memory access violations. class ReadOnlyMappedFile { public: - ReadOnlyMappedFile(const wchar_t* file_name) + explicit ReadOnlyMappedFile(const wchar_t* file_name) : fmap_(NULL), start_(NULL), size_(0) { HANDLE file = ::CreateFileW(file_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); @@ -262,9 +267,9 @@ TEST(WinAudioTest, PCMWaveStreamOpenLimit) { oas->Close(); } -// Test that it uses the double buffers correctly. Because it uses the actual +// Test that it uses the triple buffers correctly. Because it uses the actual // audio device, you might hear a short pop noise for a short time. -TEST(WinAudioTest, PCMWaveStreamDoubleBuffer) { +TEST(WinAudioTest, PCMWaveStreamTripleBuffer) { if (IsRunningHeadless()) return; AudioManager* audio_man = AudioManager::GetAudioManager(); @@ -274,12 +279,12 @@ TEST(WinAudioTest, PCMWaveStreamDoubleBuffer) { AudioOutputStream* oas = audio_man->MakeAudioStream(AudioManager::AUDIO_PCM_LINEAR, 1, 16000, 16); ASSERT_TRUE(NULL != oas); - TestSourceDoubleBuffer test_double_buffer; + TestSourceTripleBuffer test_triple_buffer; EXPECT_TRUE(oas->Open(512)); - oas->Start(&test_double_buffer); + oas->Start(&test_triple_buffer); ::Sleep(300); - EXPECT_GT(test_double_buffer.callback_count(), 2); - EXPECT_FALSE(test_double_buffer.had_error()); + EXPECT_GT(test_triple_buffer.callback_count(), kNumBuffers); + EXPECT_FALSE(test_triple_buffer.had_error()); oas->Stop(); ::Sleep(1000); oas->Close(); diff --git a/media/audio/win/waveout_output_win.cc b/media/audio/win/waveout_output_win.cc index 44bfb73..e4d34dc 100644 --- a/media/audio/win/waveout_output_win.cc +++ b/media/audio/win/waveout_output_win.cc @@ -34,9 +34,10 @@ namespace { -// We settled for a double buffering scheme. It seems to strike a good balance +// We settled for a triple buffering scheme. It seems to strike a good balance // between how fast data needs to be provided versus memory usage. -const size_t kNumBuffers = 2; +// Double buffering is insufficient for Vista and produces stutter. +const size_t kNumBuffers = 3; // Sixty four MB is the maximum buffer size per AudioOutputStream. const size_t kMaxOpenBufferSize = 1024 * 1024 * 64; |