OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/base_paths.h" | 8 #include "base/base_paths.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "media/audio/audio_output.h" | 10 #include "media/audio/audio_output.h" |
11 #include "media/audio/simple_sources.h" | 11 #include "media/audio/simple_sources.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 EXPECT_TRUE(oas->Open(512)); | 278 EXPECT_TRUE(oas->Open(512)); |
279 oas->Start(&test_double_buffer); | 279 oas->Start(&test_double_buffer); |
280 ::Sleep(300); | 280 ::Sleep(300); |
281 EXPECT_GT(test_double_buffer.callback_count(), 2); | 281 EXPECT_GT(test_double_buffer.callback_count(), 2); |
282 EXPECT_FALSE(test_double_buffer.had_error()); | 282 EXPECT_FALSE(test_double_buffer.had_error()); |
283 oas->Stop(); | 283 oas->Stop(); |
284 ::Sleep(1000); | 284 ::Sleep(1000); |
285 oas->Close(); | 285 oas->Close(); |
286 } | 286 } |
287 | 287 |
288 // Test potential deadlock situations if the source is slow or blocks for some | 288 // Test potential deadlock situation if the source is slow or blocks for some |
289 // time. The actual EXPECT_GT are mostly meaningless and the real test is that | 289 // time. The actual EXPECT_GT are mostly meaningless and the real test is that |
290 // the test completes in reasonable time. | 290 // the test completes in reasonable time. |
291 TEST(WinAudioTest, PCMWaveSlowSource) { | 291 TEST(WinAudioTest, PCMWaveSlowSource) { |
292 if (IsRunningHeadless()) | 292 if (IsRunningHeadless()) |
293 return; | 293 return; |
294 AudioManager* audio_man = AudioManager::GetAudioManager(); | 294 AudioManager* audio_man = AudioManager::GetAudioManager(); |
295 ASSERT_TRUE(NULL != audio_man); | 295 ASSERT_TRUE(NULL != audio_man); |
296 if (!audio_man->HasAudioDevices()) | 296 if (!audio_man->HasAudioDevices()) |
297 return; | 297 return; |
298 AudioOutputStream* oas = | 298 AudioOutputStream* oas = |
299 audio_man->MakeAudioStream(AudioManager::AUDIO_PCM_LINEAR, 1, 16000, 16); | 299 audio_man->MakeAudioStream(AudioManager::AUDIO_PCM_LINEAR, 1, 16000, 16); |
300 ASSERT_TRUE(NULL != oas); | 300 ASSERT_TRUE(NULL != oas); |
301 TestSourceLaggy test_laggy(2, 90); | 301 TestSourceLaggy test_laggy(2, 90); |
302 EXPECT_TRUE(oas->Open(512)); | 302 EXPECT_TRUE(oas->Open(512)); |
303 // The test parameters cause a callback every 32 ms and the source is | 303 // The test parameters cause a callback every 32 ms and the source is |
304 // sleeping for 90 ms, so it is guaranteed that we run out of ready buffers. | 304 // sleeping for 90 ms, so it is guaranteed that we run out of ready buffers. |
305 oas->Start(&test_laggy); | 305 oas->Start(&test_laggy); |
306 ::Sleep(1000); | 306 ::Sleep(1000); |
307 EXPECT_GT(test_laggy.callback_count(), 2); | 307 EXPECT_GT(test_laggy.callback_count(), 2); |
308 EXPECT_FALSE(test_laggy.had_error()); | 308 EXPECT_FALSE(test_laggy.had_error()); |
309 oas->Stop(); | 309 oas->Stop(); |
310 ::Sleep(1000); | 310 ::Sleep(1000); |
311 oas->Close(); | 311 oas->Close(); |
312 } | 312 } |
313 | 313 |
| 314 // Test another potential deadlock situation if the thread that calls Start() |
| 315 // gets paused. This test is best when run over RDP with audio enabled. See |
| 316 // bug 19276 for more details. |
| 317 TEST(WinAudioTest, PCMWaveStreamPlaySlowLoop) { |
| 318 if (IsRunningHeadless()) |
| 319 return; |
| 320 AudioManager* audio_man = AudioManager::GetAudioManager(); |
| 321 ASSERT_TRUE(NULL != audio_man); |
| 322 if (!audio_man->HasAudioDevices()) |
| 323 return; |
| 324 AudioOutputStream* oas = |
| 325 audio_man->MakeAudioStream(AudioManager::AUDIO_PCM_LINEAR, 1, |
| 326 AudioManager::kAudioCDSampleRate, 16); |
| 327 ASSERT_TRUE(NULL != oas); |
| 328 |
| 329 SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1, |
| 330 200.0, AudioManager::kAudioCDSampleRate); |
| 331 size_t bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2; |
| 332 |
| 333 EXPECT_TRUE(oas->Open(bytes_100_ms)); |
| 334 oas->SetVolume(1.0, 1.0); |
| 335 |
| 336 for (int ix = 0; ix != 25; ++ix) { |
| 337 oas->Start(&source); |
| 338 ::Sleep(10); |
| 339 oas->Stop(); |
| 340 } |
| 341 oas->Close(); |
| 342 } |
| 343 |
| 344 |
314 // This test produces actual audio for 1.5 seconds on the default wave | 345 // This test produces actual audio for 1.5 seconds on the default wave |
315 // device at 44.1K s/sec. Parameters have been chosen carefully so you should | 346 // device at 44.1K s/sec. Parameters have been chosen carefully so you should |
316 // not hear pops or noises while the sound is playing. | 347 // not hear pops or noises while the sound is playing. |
317 TEST(WinAudioTest, PCMWaveStreamPlay200HzTone44Kss) { | 348 TEST(WinAudioTest, PCMWaveStreamPlay200HzTone44Kss) { |
318 if (IsRunningHeadless()) | 349 if (IsRunningHeadless()) |
319 return; | 350 return; |
320 AudioManager* audio_man = AudioManager::GetAudioManager(); | 351 AudioManager* audio_man = AudioManager::GetAudioManager(); |
321 ASSERT_TRUE(NULL != audio_man); | 352 ASSERT_TRUE(NULL != audio_man); |
322 if (!audio_man->HasAudioDevices()) | 353 if (!audio_man->HasAudioDevices()) |
323 return; | 354 return; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 ::Sleep(500); | 494 ::Sleep(500); |
464 | 495 |
465 // Start again and play for 1.5 seconds. | 496 // Start again and play for 1.5 seconds. |
466 oas->Start(&source); | 497 oas->Start(&source); |
467 ::Sleep(1500); | 498 ::Sleep(1500); |
468 oas->Stop(); | 499 oas->Stop(); |
469 | 500 |
470 oas->Close(); | 501 oas->Close(); |
471 } | 502 } |
472 | 503 |
OLD | NEW |