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

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

Issue 1130753005: Get audio_unittests passing with h/w on windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: MTA -> STA Created 5 years, 7 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/environment.h" 9 #include "base/environment.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 19 matching lines...) Expand all
30 using ::testing::_; 30 using ::testing::_;
31 using ::testing::AnyNumber; 31 using ::testing::AnyNumber;
32 using ::testing::AtLeast; 32 using ::testing::AtLeast;
33 using ::testing::Between; 33 using ::testing::Between;
34 using ::testing::CreateFunctor; 34 using ::testing::CreateFunctor;
35 using ::testing::DoAll; 35 using ::testing::DoAll;
36 using ::testing::Gt; 36 using ::testing::Gt;
37 using ::testing::InvokeWithoutArgs; 37 using ::testing::InvokeWithoutArgs;
38 using ::testing::NotNull; 38 using ::testing::NotNull;
39 using ::testing::Return; 39 using ::testing::Return;
40 using base::win::ScopedCOMInitializer;
41 40
42 namespace media { 41 namespace media {
43 42
44 static const char kSpeechFile_16b_s_48k[] = "speech_16b_stereo_48kHz.raw"; 43 static const char kSpeechFile_16b_s_48k[] = "speech_16b_stereo_48kHz.raw";
45 static const char kSpeechFile_16b_s_44k[] = "speech_16b_stereo_44kHz.raw"; 44 static const char kSpeechFile_16b_s_44k[] = "speech_16b_stereo_44kHz.raw";
46 static const size_t kFileDurationMs = 20000; 45 static const size_t kFileDurationMs = 20000;
47 static const size_t kNumFileSegments = 2; 46 static const size_t kNumFileSegments = 2;
48 static const int kBitsPerSample = 16; 47 static const int kBitsPerSample = 16;
49 static const size_t kMaxDeltaSamples = 1000; 48 static const size_t kMaxDeltaSamples = 1000;
50 static const char kDeltaTimeMsFileName[] = "delta_times_ms.txt"; 49 static const char kDeltaTimeMsFileName[] = "delta_times_ms.txt";
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 AudioOutputStream* aos = aosw.Create(); 223 AudioOutputStream* aos = aosw.Create();
225 return aos; 224 return aos;
226 } 225 }
227 226
228 // Verify that we can retrieve the current hardware/mixing sample rate 227 // Verify that we can retrieve the current hardware/mixing sample rate
229 // for the default audio device. 228 // for the default audio device.
230 // TODO(henrika): modify this test when we support full device enumeration. 229 // TODO(henrika): modify this test when we support full device enumeration.
231 TEST(WASAPIAudioOutputStreamTest, HardwareSampleRate) { 230 TEST(WASAPIAudioOutputStreamTest, HardwareSampleRate) {
232 // Skip this test in exclusive mode since the resulting rate is only utilized 231 // Skip this test in exclusive mode since the resulting rate is only utilized
233 // for shared mode streams. 232 // for shared mode streams.
233 if (ExclusiveModeIsEnabled())
234 return;
234 scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting()); 235 scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
235 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()) && 236 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()));
236 ExclusiveModeIsEnabled());
237 237
238 // Default device intended for games, system notification sounds, 238 // Default device intended for games, system notification sounds,
239 // and voice commands. 239 // and voice commands.
240 int fs = static_cast<int>( 240 int fs = static_cast<int>(
241 WASAPIAudioOutputStream::HardwareSampleRate(std::string())); 241 WASAPIAudioOutputStream::HardwareSampleRate(std::string()));
242 EXPECT_GE(fs, 0); 242 EXPECT_GE(fs, 0);
243 } 243 }
244 244
245 // Test Create(), Close() calling sequence. 245 // Test Create(), Close() calling sequence.
246 TEST(WASAPIAudioOutputStreamTest, CreateAndClose) { 246 TEST(WASAPIAudioOutputStreamTest, CreateAndClose) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 } 442 }
443 443
444 DVLOG(0) << ">> Stereo file playout has stopped."; 444 DVLOG(0) << ">> Stereo file playout has stopped.";
445 aos->Close(); 445 aos->Close();
446 } 446 }
447 447
448 // Verify that we can open the output stream in exclusive mode using a 448 // Verify that we can open the output stream in exclusive mode using a
449 // certain set of audio parameters and a sample rate of 48kHz. 449 // certain set of audio parameters and a sample rate of 48kHz.
450 // The expected outcomes of each setting in this test has been derived 450 // The expected outcomes of each setting in this test has been derived
451 // manually using log outputs (--v=1). 451 // manually using log outputs (--v=1).
452 TEST(WASAPIAudioOutputStreamTest, ExclusiveModeBufferSizesAt48kHz) { 452 // It's disabled by default because a flag is required to enable exclusive mode.
453 TEST(WASAPIAudioOutputStreamTest, DISABLED_ExclusiveModeBufferSizesAt48kHz) {
453 scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting()); 454 scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
454 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()) && 455 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()) &&
455 ExclusiveModeIsEnabled()); 456 ExclusiveModeIsEnabled());
456 457
457 AudioOutputStreamWrapper aosw(audio_manager.get()); 458 AudioOutputStreamWrapper aosw(audio_manager.get());
458 459
459 // 10ms @ 48kHz shall work. 460 // 10ms @ 48kHz shall work.
460 // Note that, this is the same size as we can use for shared-mode streaming 461 // Note that, this is the same size as we can use for shared-mode streaming
461 // but here the endpoint buffer delay is only 10ms instead of 20ms. 462 // but here the endpoint buffer delay is only 10ms instead of 20ms.
462 AudioOutputStream* aos = aosw.Create(48000, 480); 463 AudioOutputStream* aos = aosw.Create(48000, 480);
(...skipping 27 matching lines...) Expand all
490 // 3.3333ms @ 48kHz <=> smallest possible buffer size we can use. 491 // 3.3333ms @ 48kHz <=> smallest possible buffer size we can use.
491 aos = aosw.Create(48000, 160); 492 aos = aosw.Create(48000, 160);
492 EXPECT_TRUE(aos->Open()); 493 EXPECT_TRUE(aos->Open());
493 aos->Close(); 494 aos->Close();
494 } 495 }
495 496
496 // Verify that we can open the output stream in exclusive mode using a 497 // Verify that we can open the output stream in exclusive mode using a
497 // certain set of audio parameters and a sample rate of 44.1kHz. 498 // certain set of audio parameters and a sample rate of 44.1kHz.
498 // The expected outcomes of each setting in this test has been derived 499 // The expected outcomes of each setting in this test has been derived
499 // manually using log outputs (--v=1). 500 // manually using log outputs (--v=1).
500 TEST(WASAPIAudioOutputStreamTest, ExclusiveModeBufferSizesAt44kHz) { 501 // It's disabled by default because a flag is required to enable exclusive mode.
502 TEST(WASAPIAudioOutputStreamTest, DISABLED_ExclusiveModeBufferSizesAt44kHz) {
501 scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting()); 503 scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
502 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()) && 504 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()) &&
503 ExclusiveModeIsEnabled()); 505 ExclusiveModeIsEnabled());
504 506
505 AudioOutputStreamWrapper aosw(audio_manager.get()); 507 AudioOutputStreamWrapper aosw(audio_manager.get());
506 508
507 // 10ms @ 44.1kHz does not work due to misalignment. 509 // 10ms @ 44.1kHz does not work due to misalignment.
508 // This test will propose an aligned buffer size of 10.1587ms. 510 // This test will propose an aligned buffer size of 10.1587ms.
509 AudioOutputStream* aos = aosw.Create(44100, 441); 511 AudioOutputStream* aos = aosw.Create(44100, 441);
510 EXPECT_FALSE(aos->Open()); 512 EXPECT_FALSE(aos->Open());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 aos->Close(); 547 aos->Close();
546 548
547 // 3.6281ms @ 44.1kHz <=> smallest possible buffer size we can use. 549 // 3.6281ms @ 44.1kHz <=> smallest possible buffer size we can use.
548 aos = aosw.Create(44100, 160); 550 aos = aosw.Create(44100, 160);
549 EXPECT_TRUE(aos->Open()); 551 EXPECT_TRUE(aos->Open());
550 aos->Close(); 552 aos->Close();
551 } 553 }
552 554
553 // Verify that we can open and start the output stream in exclusive mode at 555 // Verify that we can open and start the output stream in exclusive mode at
554 // the lowest possible delay at 48kHz. 556 // the lowest possible delay at 48kHz.
555 TEST(WASAPIAudioOutputStreamTest, ExclusiveModeMinBufferSizeAt48kHz) { 557 // It's disabled by default because a flag is required to enable exclusive mode.
558 TEST(WASAPIAudioOutputStreamTest, DISABLED_ExclusiveModeMinBufferSizeAt48kHz) {
556 scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting()); 559 scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
557 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()) && 560 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()) &&
558 ExclusiveModeIsEnabled()); 561 ExclusiveModeIsEnabled());
559 562
560 base::MessageLoopForUI loop; 563 base::MessageLoopForUI loop;
561 MockAudioSourceCallback source; 564 MockAudioSourceCallback source;
562 565
563 // Create exclusive-mode WASAPI output stream which plays out in stereo 566 // Create exclusive-mode WASAPI output stream which plays out in stereo
564 // using the minimum buffer size at 48kHz sample rate. 567 // using the minimum buffer size at 48kHz sample rate.
565 AudioOutputStreamWrapper aosw(audio_manager.get()); 568 AudioOutputStreamWrapper aosw(audio_manager.get());
(...skipping 14 matching lines...) Expand all
580 aos->Start(&source); 583 aos->Start(&source);
581 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitClosure(), 584 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitClosure(),
582 TestTimeouts::action_timeout()); 585 TestTimeouts::action_timeout());
583 loop.Run(); 586 loop.Run();
584 aos->Stop(); 587 aos->Stop();
585 aos->Close(); 588 aos->Close();
586 } 589 }
587 590
588 // Verify that we can open and start the output stream in exclusive mode at 591 // Verify that we can open and start the output stream in exclusive mode at
589 // the lowest possible delay at 44.1kHz. 592 // the lowest possible delay at 44.1kHz.
590 TEST(WASAPIAudioOutputStreamTest, ExclusiveModeMinBufferSizeAt44kHz) { 593 // It's disabled by default because a flag is required to enable exclusive mode.
594 TEST(WASAPIAudioOutputStreamTest, DISABLED_ExclusiveModeMinBufferSizeAt44kHz) {
591 ABORT_AUDIO_TEST_IF_NOT(ExclusiveModeIsEnabled()); 595 ABORT_AUDIO_TEST_IF_NOT(ExclusiveModeIsEnabled());
592 scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting()); 596 scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
593 597
594 base::MessageLoopForUI loop; 598 base::MessageLoopForUI loop;
595 MockAudioSourceCallback source; 599 MockAudioSourceCallback source;
596 600
597 // Create exclusive-mode WASAPI output stream which plays out in stereo 601 // Create exclusive-mode WASAPI output stream which plays out in stereo
598 // using the minimum buffer size at 44.1kHz sample rate. 602 // using the minimum buffer size at 44.1kHz sample rate.
599 AudioOutputStreamWrapper aosw(audio_manager.get()); 603 AudioOutputStreamWrapper aosw(audio_manager.get());
600 AudioOutputStream* aos = aosw.Create(44100, 160); 604 AudioOutputStream* aos = aosw.Create(44100, 160);
(...skipping 12 matching lines...) Expand all
613 617
614 aos->Start(&source); 618 aos->Start(&source);
615 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitClosure(), 619 loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitClosure(),
616 TestTimeouts::action_timeout()); 620 TestTimeouts::action_timeout());
617 loop.Run(); 621 loop.Run();
618 aos->Stop(); 622 aos->Stop();
619 aos->Close(); 623 aos->Close();
620 } 624 }
621 625
622 } // namespace media 626 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/win/audio_low_latency_input_win_unittest.cc ('k') | media/audio/win/audio_output_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698