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

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: Feedback 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 23 matching lines...) Expand all
34 34
35 static int ClearData(AudioBus* audio_bus, uint32 total_bytes_delay) { 35 static int ClearData(AudioBus* audio_bus, uint32 total_bytes_delay) {
36 audio_bus->Zero(); 36 audio_bus->Zero();
37 return audio_bus->frames(); 37 return audio_bus->frames();
38 } 38 }
39 39
40 // This class allows to find out if the callbacks are occurring as 40 // This class allows to find out if the callbacks are occurring as
41 // expected and if any error has been reported. 41 // expected and if any error has been reported.
42 class TestSourceBasic : public AudioOutputStream::AudioSourceCallback { 42 class TestSourceBasic : public AudioOutputStream::AudioSourceCallback {
43 public: 43 public:
44 explicit TestSourceBasic() 44 TestSourceBasic()
45 : callback_count_(0), 45 : callback_count_(0),
46 had_error_(0) { 46 had_error_(0) {
47 } 47 }
48 // AudioSourceCallback::OnMoreData implementation: 48 // AudioSourceCallback::OnMoreData implementation:
49 int OnMoreData(AudioBus* audio_bus, uint32 total_bytes_delay) override { 49 int OnMoreData(AudioBus* audio_bus, uint32 total_bytes_delay) override {
50 ++callback_count_; 50 ++callback_count_;
51 // Touch the channel memory value to make sure memory is good. 51 // Touch the channel memory value to make sure memory is good.
52 audio_bus->Zero(); 52 audio_bus->Zero();
53 return audio_bus->frames(); 53 return audio_bus->frames();
54 } 54 }
(...skipping 15 matching lines...) Expand all
70 private: 70 private:
71 int callback_count_; 71 int callback_count_;
72 int had_error_; 72 int had_error_;
73 }; 73 };
74 74
75 const int kMaxNumBuffers = 3; 75 const int kMaxNumBuffers = 3;
76 // Specializes TestSourceBasic to simulate a source that blocks for some time 76 // Specializes TestSourceBasic to simulate a source that blocks for some time
77 // in the OnMoreData callback. 77 // in the OnMoreData callback.
78 class TestSourceLaggy : public TestSourceBasic { 78 class TestSourceLaggy : public TestSourceBasic {
79 public: 79 public:
80 TestSourceLaggy(int laggy_after_buffer, int lag_in_ms) 80 explicit TestSourceLaggy(int lag_in_ms)
81 : laggy_after_buffer_(laggy_after_buffer), lag_in_ms_(lag_in_ms) { 81 : lag_in_ms_(lag_in_ms) {
82 } 82 }
83 int OnMoreData(AudioBus* audio_bus, uint32 total_bytes_delay) override { 83 int OnMoreData(AudioBus* audio_bus, uint32 total_bytes_delay) override {
84 // Call the base, which increments the callback_count_. 84 // Call the base, which increments the callback_count_.
85 TestSourceBasic::OnMoreData(audio_bus, total_bytes_delay); 85 TestSourceBasic::OnMoreData(audio_bus, total_bytes_delay);
86 if (callback_count() > kMaxNumBuffers) { 86 if (callback_count() > kMaxNumBuffers) {
87 ::Sleep(lag_in_ms_); 87 ::Sleep(lag_in_ms_);
88 } 88 }
89 return audio_bus->frames(); 89 return audio_bus->frames();
90 } 90 }
91 private: 91 private:
92 int laggy_after_buffer_;
93 int lag_in_ms_; 92 int lag_in_ms_;
94 }; 93 };
95 94
96 // Helper class to memory map an entire file. The mapping is read-only. Don't 95 // Helper class to memory map an entire file. The mapping is read-only. Don't
97 // use for gigabyte-sized files. Attempts to write to this memory generate 96 // use for gigabyte-sized files. Attempts to write to this memory generate
98 // memory access violations. 97 // memory access violations.
99 class ReadOnlyMappedFile { 98 class ReadOnlyMappedFile {
100 public: 99 public:
101 explicit ReadOnlyMappedFile(const wchar_t* file_name) 100 explicit ReadOnlyMappedFile(const wchar_t* file_name)
102 : fmap_(NULL), start_(NULL), size_(0) { 101 : fmap_(NULL), start_(NULL), size_(0) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // the test completes in reasonable time. 227 // the test completes in reasonable time.
229 TEST(WinAudioTest, PCMWaveSlowSource) { 228 TEST(WinAudioTest, PCMWaveSlowSource) {
230 scoped_ptr<AudioManager> audio_man(AudioManager::CreateForTesting()); 229 scoped_ptr<AudioManager> audio_man(AudioManager::CreateForTesting());
231 ABORT_AUDIO_TEST_IF_NOT(audio_man->HasAudioOutputDevices()); 230 ABORT_AUDIO_TEST_IF_NOT(audio_man->HasAudioOutputDevices());
232 231
233 AudioOutputStream* oas = audio_man->MakeAudioOutputStream( 232 AudioOutputStream* oas = audio_man->MakeAudioOutputStream(
234 AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_MONO, 233 AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_MONO,
235 16000, 16, 256), 234 16000, 16, 256),
236 std::string()); 235 std::string());
237 ASSERT_TRUE(NULL != oas); 236 ASSERT_TRUE(NULL != oas);
238 TestSourceLaggy test_laggy(2, 90); 237 TestSourceLaggy test_laggy(90);
239 EXPECT_TRUE(oas->Open()); 238 EXPECT_TRUE(oas->Open());
240 // The test parameters cause a callback every 32 ms and the source is 239 // The test parameters cause a callback every 32 ms and the source is
241 // sleeping for 90 ms, so it is guaranteed that we run out of ready buffers. 240 // sleeping for 90 ms, so it is guaranteed that we run out of ready buffers.
242 oas->Start(&test_laggy); 241 oas->Start(&test_laggy);
243 ::Sleep(500); 242 ::Sleep(500);
244 EXPECT_GT(test_laggy.callback_count(), 2); 243 EXPECT_GT(test_laggy.callback_count(), 2);
245 EXPECT_FALSE(test_laggy.had_error()); 244 EXPECT_FALSE(test_laggy.had_error());
246 oas->Stop(); 245 oas->Stop();
247 ::Sleep(500); 246 ::Sleep(500);
248 oas->Close(); 247 oas->Close();
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 oas->Start(&source); 616 oas->Start(&source);
618 617
619 ::WaitForSingleObject(thread, INFINITE); 618 ::WaitForSingleObject(thread, INFINITE);
620 ::CloseHandle(thread); 619 ::CloseHandle(thread);
621 620
622 oas->Stop(); 621 oas->Stop();
623 oas->Close(); 622 oas->Close();
624 } 623 }
625 624
626 } // namespace media 625 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698