| OLD | NEW |
| 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/environment.h" | 9 #include "base/environment.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 file_name = kSpeechFile_16b_s_44k; | 436 file_name = kSpeechFile_16b_s_44k; |
| 437 } else if (aosw.sample_rate() == 96000) { | 437 } else if (aosw.sample_rate() == 96000) { |
| 438 // Use 48kHz file at 96kHz as well. Will sound like Donald Duck. | 438 // Use 48kHz file at 96kHz as well. Will sound like Donald Duck. |
| 439 file_name = kSpeechFile_16b_s_48k; | 439 file_name = kSpeechFile_16b_s_48k; |
| 440 } else { | 440 } else { |
| 441 FAIL() << "This test supports 44.1, 48kHz and 96kHz only."; | 441 FAIL() << "This test supports 44.1, 48kHz and 96kHz only."; |
| 442 return; | 442 return; |
| 443 } | 443 } |
| 444 ReadFromFileAudioSource file_source(file_name); | 444 ReadFromFileAudioSource file_source(file_name); |
| 445 | 445 |
| 446 VLOG(0) << "File name : " << file_name.c_str(); | 446 DVLOG(0) << "File name : " << file_name.c_str(); |
| 447 VLOG(0) << "Sample rate : " << aosw.sample_rate(); | 447 DVLOG(0) << "Sample rate : " << aosw.sample_rate(); |
| 448 VLOG(0) << "Bits per sample: " << aosw.bits_per_sample(); | 448 DVLOG(0) << "Bits per sample: " << aosw.bits_per_sample(); |
| 449 VLOG(0) << "#channels : " << aosw.channels(); | 449 DVLOG(0) << "#channels : " << aosw.channels(); |
| 450 VLOG(0) << "File size : " << file_source.file_size(); | 450 DVLOG(0) << "File size : " << file_source.file_size(); |
| 451 VLOG(0) << "#file segments : " << kNumFileSegments; | 451 DVLOG(0) << "#file segments : " << kNumFileSegments; |
| 452 VLOG(0) << ">> Listen to the stereo file while playing..."; | 452 DVLOG(0) << ">> Listen to the stereo file while playing..."; |
| 453 | 453 |
| 454 for (int i = 0; i < kNumFileSegments; i++) { | 454 for (int i = 0; i < kNumFileSegments; i++) { |
| 455 // Each segment will start with a short (~20ms) block of zeros, hence | 455 // Each segment will start with a short (~20ms) block of zeros, hence |
| 456 // some short glitches might be heard in this test if kNumFileSegments | 456 // some short glitches might be heard in this test if kNumFileSegments |
| 457 // is larger than one. The exact length of the silence period depends on | 457 // is larger than one. The exact length of the silence period depends on |
| 458 // the selected sample rate. | 458 // the selected sample rate. |
| 459 aos->Start(&file_source); | 459 aos->Start(&file_source); |
| 460 base::PlatformThread::Sleep( | 460 base::PlatformThread::Sleep( |
| 461 base::TimeDelta::FromMilliseconds(kFileDurationMs / kNumFileSegments)); | 461 base::TimeDelta::FromMilliseconds(kFileDurationMs / kNumFileSegments)); |
| 462 aos->Stop(); | 462 aos->Stop(); |
| 463 } | 463 } |
| 464 | 464 |
| 465 VLOG(0) << ">> Stereo file playout has stopped."; | 465 DVLOG(0) << ">> Stereo file playout has stopped."; |
| 466 aos->Close(); | 466 aos->Close(); |
| 467 } | 467 } |
| 468 | 468 |
| 469 // Verify that we can open the output stream in exclusive mode using a | 469 // Verify that we can open the output stream in exclusive mode using a |
| 470 // certain set of audio parameters and a sample rate of 48kHz. | 470 // certain set of audio parameters and a sample rate of 48kHz. |
| 471 // The expected outcomes of each setting in this test has been derived | 471 // The expected outcomes of each setting in this test has been derived |
| 472 // manually using log outputs (--v=1). | 472 // manually using log outputs (--v=1). |
| 473 TEST(WASAPIAudioOutputStreamTest, ExclusiveModeBufferSizesAt48kHz) { | 473 TEST(WASAPIAudioOutputStreamTest, ExclusiveModeBufferSizesAt48kHz) { |
| 474 if (!ExclusiveModeIsEnabled()) | 474 if (!ExclusiveModeIsEnabled()) |
| 475 return; | 475 return; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 | 647 |
| 648 aos->Start(&source); | 648 aos->Start(&source); |
| 649 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitClosure(), | 649 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitClosure(), |
| 650 TestTimeouts::action_timeout()); | 650 TestTimeouts::action_timeout()); |
| 651 loop.Run(); | 651 loop.Run(); |
| 652 aos->Stop(); | 652 aos->Stop(); |
| 653 aos->Close(); | 653 aos->Close(); |
| 654 } | 654 } |
| 655 | 655 |
| 656 } // namespace media | 656 } // namespace media |
| OLD | NEW |