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

Side by Side Diff: media/audio/win/audio_output_win_unittest.cc

Issue 1215643003: Remove -Wno-unused-private-field clang warning suppression. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up GN Created 5 years, 5 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 unified diff | Download patch
OLDNEW
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" 8 #include "base/basictypes.h"
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/memory/aligned_memory.h" 10 #include "base/memory/aligned_memory.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 private: 73 private:
74 int callback_count_; 74 int callback_count_;
75 int had_error_; 75 int had_error_;
76 }; 76 };
77 77
78 const int kMaxNumBuffers = 3; 78 const int kMaxNumBuffers = 3;
79 // Specializes TestSourceBasic to simulate a source that blocks for some time 79 // Specializes TestSourceBasic to simulate a source that blocks for some time
80 // in the OnMoreData callback. 80 // in the OnMoreData callback.
81 class TestSourceLaggy : public TestSourceBasic { 81 class TestSourceLaggy : public TestSourceBasic {
82 public: 82 public:
83 TestSourceLaggy(int laggy_after_buffer, int lag_in_ms) 83 TestSourceLaggy(int lag_in_ms)
Nico 2015/07/09 01:58:16 explicit
benwells 2015/07/09 11:43:02 Done.
84 : laggy_after_buffer_(laggy_after_buffer), lag_in_ms_(lag_in_ms) { 84 : lag_in_ms_(lag_in_ms) {
85 } 85 }
86 int OnMoreData(AudioBus* audio_bus, uint32 total_bytes_delay) override { 86 int OnMoreData(AudioBus* audio_bus, uint32 total_bytes_delay) override {
87 // Call the base, which increments the callback_count_. 87 // Call the base, which increments the callback_count_.
88 TestSourceBasic::OnMoreData(audio_bus, total_bytes_delay); 88 TestSourceBasic::OnMoreData(audio_bus, total_bytes_delay);
89 if (callback_count() > kMaxNumBuffers) { 89 if (callback_count() > kMaxNumBuffers) {
90 ::Sleep(lag_in_ms_); 90 ::Sleep(lag_in_ms_);
91 } 91 }
92 return audio_bus->frames(); 92 return audio_bus->frames();
93 } 93 }
94 private: 94 private:
95 int laggy_after_buffer_;
96 int lag_in_ms_; 95 int lag_in_ms_;
97 }; 96 };
98 97
99 // Helper class to memory map an entire file. The mapping is read-only. Don't 98 // Helper class to memory map an entire file. The mapping is read-only. Don't
100 // use for gigabyte-sized files. Attempts to write to this memory generate 99 // use for gigabyte-sized files. Attempts to write to this memory generate
101 // memory access violations. 100 // memory access violations.
102 class ReadOnlyMappedFile { 101 class ReadOnlyMappedFile {
103 public: 102 public:
104 explicit ReadOnlyMappedFile(const wchar_t* file_name) 103 explicit ReadOnlyMappedFile(const wchar_t* file_name)
105 : fmap_(NULL), start_(NULL), size_(0) { 104 : fmap_(NULL), start_(NULL), size_(0) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // the test completes in reasonable time. 230 // the test completes in reasonable time.
232 TEST(WinAudioTest, PCMWaveSlowSource) { 231 TEST(WinAudioTest, PCMWaveSlowSource) {
233 scoped_ptr<AudioManager> audio_man(AudioManager::CreateForTesting()); 232 scoped_ptr<AudioManager> audio_man(AudioManager::CreateForTesting());
234 ABORT_AUDIO_TEST_IF_NOT(audio_man->HasAudioOutputDevices()); 233 ABORT_AUDIO_TEST_IF_NOT(audio_man->HasAudioOutputDevices());
235 234
236 AudioOutputStream* oas = audio_man->MakeAudioOutputStream( 235 AudioOutputStream* oas = audio_man->MakeAudioOutputStream(
237 AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_MONO, 236 AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_MONO,
238 16000, 16, 256), 237 16000, 16, 256),
239 std::string()); 238 std::string());
240 ASSERT_TRUE(NULL != oas); 239 ASSERT_TRUE(NULL != oas);
241 TestSourceLaggy test_laggy(2, 90); 240 TestSourceLaggy test_laggy(90);
242 EXPECT_TRUE(oas->Open()); 241 EXPECT_TRUE(oas->Open());
243 // The test parameters cause a callback every 32 ms and the source is 242 // The test parameters cause a callback every 32 ms and the source is
244 // sleeping for 90 ms, so it is guaranteed that we run out of ready buffers. 243 // sleeping for 90 ms, so it is guaranteed that we run out of ready buffers.
245 oas->Start(&test_laggy); 244 oas->Start(&test_laggy);
246 ::Sleep(500); 245 ::Sleep(500);
247 EXPECT_GT(test_laggy.callback_count(), 2); 246 EXPECT_GT(test_laggy.callback_count(), 2);
248 EXPECT_FALSE(test_laggy.had_error()); 247 EXPECT_FALSE(test_laggy.had_error());
249 oas->Stop(); 248 oas->Stop();
250 ::Sleep(500); 249 ::Sleep(500);
251 oas->Close(); 250 oas->Close();
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 oas->Start(&source); 619 oas->Start(&source);
621 620
622 ::WaitForSingleObject(thread, INFINITE); 621 ::WaitForSingleObject(thread, INFINITE);
623 ::CloseHandle(thread); 622 ::CloseHandle(thread);
624 623
625 oas->Stop(); 624 oas->Stop();
626 oas->Close(); 625 oas->Close();
627 } 626 }
628 627
629 } // namespace media 628 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698