| Index: media/audio/win/audio_output_win_unittest.cc
|
| diff --git a/media/audio/win/audio_output_win_unittest.cc b/media/audio/win/audio_output_win_unittest.cc
|
| index 23c85e5918c6ae5737de1738078d49d3cf63229a..9b573030b5615b6060d7e1557a0367c1c5421e98 100644
|
| --- a/media/audio/win/audio_output_win_unittest.cc
|
| +++ b/media/audio/win/audio_output_win_unittest.cc
|
| @@ -11,12 +11,14 @@
|
|
|
| #include "base/base_paths.h"
|
| #include "base/memory/aligned_memory.h"
|
| +#include "base/memory/ptr_util.h"
|
| #include "base/message_loop/message_loop.h"
|
| #include "base/run_loop.h"
|
| #include "base/sync_socket.h"
|
| #include "base/time/time.h"
|
| #include "base/win/scoped_com_initializer.h"
|
| #include "base/win/windows_version.h"
|
| +#include "media/audio/audio_device_info_accessor_for_tests.h"
|
| #include "media/audio/audio_io.h"
|
| #include "media/audio/audio_manager.h"
|
| #include "media/audio/audio_unittest_util.h"
|
| @@ -155,9 +157,12 @@ class WinAudioTest : public ::testing::Test {
|
| WinAudioTest() {
|
| audio_manager_ =
|
| AudioManager::CreateForTesting(message_loop_.task_runner());
|
| + audio_manager_device_info_ =
|
| + base::MakeUnique<AudioDeviceInfoAccessorForTests>(audio_manager_.get());
|
| base::RunLoop().RunUntilIdle();
|
| }
|
| ~WinAudioTest() override {
|
| + audio_manager_device_info_.reset();
|
| audio_manager_.reset();
|
| base::RunLoop().RunUntilIdle();
|
| }
|
| @@ -165,6 +170,7 @@ class WinAudioTest : public ::testing::Test {
|
| protected:
|
| base::MessageLoop message_loop_;
|
| ScopedAudioManagerPtr audio_manager_;
|
| + std::unique_ptr<AudioDeviceInfoAccessorForTests> audio_manager_device_info_;
|
| };
|
|
|
| // ===========================================================================
|
| @@ -177,7 +183,7 @@ class WinAudioTest : public ::testing::Test {
|
|
|
| // Test that can it be created and closed.
|
| TEST_F(WinAudioTest, PCMWaveStreamGetAndClose) {
|
| - ABORT_AUDIO_TEST_IF_NOT(audio_manager_->HasAudioOutputDevices());
|
| + ABORT_AUDIO_TEST_IF_NOT(audio_manager_device_info_->HasAudioOutputDevices());
|
|
|
| AudioOutputStream* oas = audio_manager_->MakeAudioOutputStream(
|
| AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO,
|
| @@ -189,7 +195,7 @@ TEST_F(WinAudioTest, PCMWaveStreamGetAndClose) {
|
|
|
| // Test that can it be cannot be created with invalid parameters.
|
| TEST_F(WinAudioTest, SanityOnMakeParams) {
|
| - ABORT_AUDIO_TEST_IF_NOT(audio_manager_->HasAudioOutputDevices());
|
| + ABORT_AUDIO_TEST_IF_NOT(audio_manager_device_info_->HasAudioOutputDevices());
|
|
|
| AudioParameters::Format fmt = AudioParameters::AUDIO_PCM_LINEAR;
|
| EXPECT_TRUE(
|
| @@ -232,7 +238,7 @@ TEST_F(WinAudioTest, SanityOnMakeParams) {
|
|
|
| // Test that it can be opened and closed.
|
| TEST_F(WinAudioTest, PCMWaveStreamOpenAndClose) {
|
| - ABORT_AUDIO_TEST_IF_NOT(audio_manager_->HasAudioOutputDevices());
|
| + ABORT_AUDIO_TEST_IF_NOT(audio_manager_device_info_->HasAudioOutputDevices());
|
|
|
| AudioOutputStream* oas = audio_manager_->MakeAudioOutputStream(
|
| AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO,
|
| @@ -245,7 +251,7 @@ TEST_F(WinAudioTest, PCMWaveStreamOpenAndClose) {
|
|
|
| // Test that it has a maximum packet size.
|
| TEST_F(WinAudioTest, PCMWaveStreamOpenLimit) {
|
| - ABORT_AUDIO_TEST_IF_NOT(audio_manager_->HasAudioOutputDevices());
|
| + ABORT_AUDIO_TEST_IF_NOT(audio_manager_device_info_->HasAudioOutputDevices());
|
|
|
| AudioOutputStream* oas = audio_manager_->MakeAudioOutputStream(
|
| AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO,
|
| @@ -260,7 +266,7 @@ TEST_F(WinAudioTest, PCMWaveStreamOpenLimit) {
|
| // time. The actual EXPECT_GT are mostly meaningless and the real test is that
|
| // the test completes in reasonable time.
|
| TEST_F(WinAudioTest, PCMWaveSlowSource) {
|
| - ABORT_AUDIO_TEST_IF_NOT(audio_manager_->HasAudioOutputDevices());
|
| + ABORT_AUDIO_TEST_IF_NOT(audio_manager_device_info_->HasAudioOutputDevices());
|
|
|
| AudioOutputStream* oas = audio_manager_->MakeAudioOutputStream(
|
| AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_MONO,
|
| @@ -284,7 +290,7 @@ TEST_F(WinAudioTest, PCMWaveSlowSource) {
|
| // gets paused. This test is best when run over RDP with audio enabled. See
|
| // bug 19276 for more details.
|
| TEST_F(WinAudioTest, PCMWaveStreamPlaySlowLoop) {
|
| - ABORT_AUDIO_TEST_IF_NOT(audio_manager_->HasAudioOutputDevices());
|
| + ABORT_AUDIO_TEST_IF_NOT(audio_manager_device_info_->HasAudioOutputDevices());
|
|
|
| uint32_t samples_100_ms = AudioParameters::kAudioCDSampleRate / 10;
|
| AudioOutputStream* oas = audio_manager_->MakeAudioOutputStream(
|
| @@ -311,7 +317,7 @@ TEST_F(WinAudioTest, PCMWaveStreamPlaySlowLoop) {
|
| // device at 44.1K s/sec. Parameters have been chosen carefully so you should
|
| // not hear pops or noises while the sound is playing.
|
| TEST_F(WinAudioTest, PCMWaveStreamPlay200HzTone44Kss) {
|
| - if (!audio_manager_->HasAudioOutputDevices()) {
|
| + if (!audio_manager_device_info_->HasAudioOutputDevices()) {
|
| LOG(WARNING) << "No output device detected.";
|
| return;
|
| }
|
| @@ -338,7 +344,7 @@ TEST_F(WinAudioTest, PCMWaveStreamPlay200HzTone44Kss) {
|
| // not hear pops or noises while the sound is playing. The audio also should
|
| // sound with a lower volume than PCMWaveStreamPlay200HzTone44Kss.
|
| TEST_F(WinAudioTest, PCMWaveStreamPlay200HzTone22Kss) {
|
| - ABORT_AUDIO_TEST_IF_NOT(audio_manager_->HasAudioOutputDevices());
|
| + ABORT_AUDIO_TEST_IF_NOT(audio_manager_device_info_->HasAudioOutputDevices());
|
|
|
| uint32_t samples_100_ms = AudioParameters::kAudioCDSampleRate / 20;
|
| AudioOutputStream* oas = audio_manager_->MakeAudioOutputStream(
|
| @@ -369,7 +375,7 @@ TEST_F(WinAudioTest, PCMWaveStreamPlay200HzTone22Kss) {
|
| // try hard to generate situation where the two threads are accessing the
|
| // object roughly at the same time.
|
| TEST_F(WinAudioTest, PushSourceFile16KHz) {
|
| - ABORT_AUDIO_TEST_IF_NOT(audio_manager_->HasAudioOutputDevices());
|
| + ABORT_AUDIO_TEST_IF_NOT(audio_manager_device_info_->HasAudioOutputDevices());
|
|
|
| static const int kSampleRate = 16000;
|
| SineWaveAudioSource source(1, 200.0, kSampleRate);
|
| @@ -408,7 +414,7 @@ TEST_F(WinAudioTest, PushSourceFile16KHz) {
|
| // stopped. You will here two .5 seconds wave signal separated by 0.5 seconds
|
| // of silence.
|
| TEST_F(WinAudioTest, PCMWaveStreamPlayTwice200HzTone44Kss) {
|
| - ABORT_AUDIO_TEST_IF_NOT(audio_manager_->HasAudioOutputDevices());
|
| + ABORT_AUDIO_TEST_IF_NOT(audio_manager_device_info_->HasAudioOutputDevices());
|
|
|
| uint32_t samples_100_ms = AudioParameters::kAudioCDSampleRate / 10;
|
| AudioOutputStream* oas = audio_manager_->MakeAudioOutputStream(
|
| @@ -441,12 +447,12 @@ TEST_F(WinAudioTest, PCMWaveStreamPlayTwice200HzTone44Kss) {
|
| // higher and Wave is used for XP and lower. It is possible to utilize a
|
| // smaller buffer size for WASAPI than for Wave.
|
| TEST_F(WinAudioTest, PCMWaveStreamPlay200HzToneLowLatency) {
|
| - ABORT_AUDIO_TEST_IF_NOT(audio_manager_->HasAudioOutputDevices());
|
| + ABORT_AUDIO_TEST_IF_NOT(audio_manager_device_info_->HasAudioOutputDevices());
|
|
|
| // Use 10 ms buffer size for WASAPI and 50 ms buffer size for Wave.
|
| // Take the existing native sample rate into account.
|
| const AudioParameters params =
|
| - audio_manager_->GetDefaultOutputStreamParameters();
|
| + audio_manager_device_info_->GetDefaultOutputStreamParameters();
|
| int sample_rate = params.sample_rate();
|
| uint32_t samples_10_ms = sample_rate / 100;
|
| int n = 1;
|
| @@ -478,7 +484,7 @@ TEST_F(WinAudioTest, PCMWaveStreamPlay200HzToneLowLatency) {
|
|
|
| // Check that the pending bytes value is correct what the stream starts.
|
| TEST_F(WinAudioTest, PCMWaveStreamPendingBytes) {
|
| - ABORT_AUDIO_TEST_IF_NOT(audio_manager_->HasAudioOutputDevices());
|
| + ABORT_AUDIO_TEST_IF_NOT(audio_manager_device_info_->HasAudioOutputDevices());
|
|
|
| uint32_t samples_100_ms = AudioParameters::kAudioCDSampleRate / 10;
|
| AudioOutputStream* oas = audio_manager_->MakeAudioOutputStream(
|
| @@ -625,7 +631,7 @@ DWORD __stdcall SyncSocketThread(void* context) {
|
| // related to the two different audio-layers for AUDIO_PCM_LOW_LATENCY.
|
| // In this test you should hear a continuous 200Hz tone for 2 seconds.
|
| TEST_F(WinAudioTest, SyncSocketBasic) {
|
| - ABORT_AUDIO_TEST_IF_NOT(audio_manager_->HasAudioOutputDevices());
|
| + ABORT_AUDIO_TEST_IF_NOT(audio_manager_device_info_->HasAudioOutputDevices());
|
|
|
| static const int sample_rate = AudioParameters::kAudioCDSampleRate;
|
| static const uint32_t kSamples20ms = sample_rate / 50;
|
|
|