| Index: media/audio/win/audio_low_latency_output_win_unittest.cc
|
| diff --git a/media/audio/win/audio_low_latency_output_win_unittest.cc b/media/audio/win/audio_low_latency_output_win_unittest.cc
|
| index c8c6bdf552eefbbaae1141a5b6425dd88f099d0a..5b748e7fc099ae941ef1959de5b563022d9230a7 100644
|
| --- a/media/audio/win/audio_low_latency_output_win_unittest.cc
|
| +++ b/media/audio/win/audio_low_latency_output_win_unittest.cc
|
| @@ -16,6 +16,7 @@
|
| #include "base/time/time.h"
|
| #include "base/win/scoped_com_initializer.h"
|
| #include "media/audio/audio_io.h"
|
| +#include "media/audio/audio_manager.h"
|
| #include "media/audio/audio_manager_base.h"
|
| #include "media/audio/audio_unittest_util.h"
|
| #include "media/audio/mock_audio_source_callback.h"
|
| @@ -227,32 +228,16 @@
|
| return aos;
|
| }
|
|
|
| -class WASAPIAudioOutputStreamTest : public ::testing::Test {
|
| - public:
|
| - WASAPIAudioOutputStreamTest() {
|
| - audio_manager_ =
|
| - AudioManager::CreateForTesting(message_loop_.task_runner());
|
| - message_loop_.RunUntilIdle();
|
| - }
|
| - ~WASAPIAudioOutputStreamTest() override {
|
| - audio_manager_.reset();
|
| - message_loop_.RunUntilIdle();
|
| - }
|
| -
|
| - protected:
|
| - base::MessageLoopForUI message_loop_;
|
| - ScopedAudioManagerPtr audio_manager_;
|
| -};
|
| -
|
| // Verify that we can retrieve the current hardware/mixing sample rate
|
| // for the default audio device.
|
| // TODO(henrika): modify this test when we support full device enumeration.
|
| -TEST_F(WASAPIAudioOutputStreamTest, HardwareSampleRate) {
|
| +TEST(WASAPIAudioOutputStreamTest, HardwareSampleRate) {
|
| // Skip this test in exclusive mode since the resulting rate is only utilized
|
| // for shared mode streams.
|
| if (ExclusiveModeIsEnabled())
|
| return;
|
| - ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager_.get()));
|
| + scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
|
| + ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()));
|
|
|
| // Default device intended for games, system notification sounds,
|
| // and voice commands.
|
| @@ -262,24 +247,27 @@
|
| }
|
|
|
| // Test Create(), Close() calling sequence.
|
| -TEST_F(WASAPIAudioOutputStreamTest, CreateAndClose) {
|
| - ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager_.get()));
|
| - AudioOutputStream* aos = CreateDefaultAudioOutputStream(audio_manager_.get());
|
| +TEST(WASAPIAudioOutputStreamTest, CreateAndClose) {
|
| + scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
|
| + ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()));
|
| + AudioOutputStream* aos = CreateDefaultAudioOutputStream(audio_manager.get());
|
| aos->Close();
|
| }
|
|
|
| // Test Open(), Close() calling sequence.
|
| -TEST_F(WASAPIAudioOutputStreamTest, OpenAndClose) {
|
| - ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager_.get()));
|
| - AudioOutputStream* aos = CreateDefaultAudioOutputStream(audio_manager_.get());
|
| +TEST(WASAPIAudioOutputStreamTest, OpenAndClose) {
|
| + scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
|
| + ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()));
|
| + AudioOutputStream* aos = CreateDefaultAudioOutputStream(audio_manager.get());
|
| EXPECT_TRUE(aos->Open());
|
| aos->Close();
|
| }
|
|
|
| // Test Open(), Start(), Close() calling sequence.
|
| -TEST_F(WASAPIAudioOutputStreamTest, OpenStartAndClose) {
|
| - ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager_.get()));
|
| - AudioOutputStream* aos = CreateDefaultAudioOutputStream(audio_manager_.get());
|
| +TEST(WASAPIAudioOutputStreamTest, OpenStartAndClose) {
|
| + scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
|
| + ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()));
|
| + AudioOutputStream* aos = CreateDefaultAudioOutputStream(audio_manager.get());
|
| EXPECT_TRUE(aos->Open());
|
| MockAudioSourceCallback source;
|
| EXPECT_CALL(source, OnError(aos))
|
| @@ -289,9 +277,10 @@
|
| }
|
|
|
| // Test Open(), Start(), Stop(), Close() calling sequence.
|
| -TEST_F(WASAPIAudioOutputStreamTest, OpenStartStopAndClose) {
|
| - ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager_.get()));
|
| - AudioOutputStream* aos = CreateDefaultAudioOutputStream(audio_manager_.get());
|
| +TEST(WASAPIAudioOutputStreamTest, OpenStartStopAndClose) {
|
| + scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
|
| + ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()));
|
| + AudioOutputStream* aos = CreateDefaultAudioOutputStream(audio_manager.get());
|
| EXPECT_TRUE(aos->Open());
|
| MockAudioSourceCallback source;
|
| EXPECT_CALL(source, OnError(aos))
|
| @@ -302,9 +291,10 @@
|
| }
|
|
|
| // Test SetVolume(), GetVolume()
|
| -TEST_F(WASAPIAudioOutputStreamTest, Volume) {
|
| - ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager_.get()));
|
| - AudioOutputStream* aos = CreateDefaultAudioOutputStream(audio_manager_.get());
|
| +TEST(WASAPIAudioOutputStreamTest, Volume) {
|
| + scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
|
| + ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()));
|
| + AudioOutputStream* aos = CreateDefaultAudioOutputStream(audio_manager.get());
|
|
|
| // Initial volume should be full volume (1.0).
|
| double volume = 0.0;
|
| @@ -337,10 +327,11 @@
|
| }
|
|
|
| // Test some additional calling sequences.
|
| -TEST_F(WASAPIAudioOutputStreamTest, MiscCallingSequences) {
|
| - ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager_.get()));
|
| -
|
| - AudioOutputStream* aos = CreateDefaultAudioOutputStream(audio_manager_.get());
|
| +TEST(WASAPIAudioOutputStreamTest, MiscCallingSequences) {
|
| + scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
|
| + ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()));
|
| +
|
| + AudioOutputStream* aos = CreateDefaultAudioOutputStream(audio_manager.get());
|
| WASAPIAudioOutputStream* waos = static_cast<WASAPIAudioOutputStream*>(aos);
|
|
|
| // Open(), Open() is a valid calling sequence (second call does nothing).
|
| @@ -375,13 +366,16 @@
|
| }
|
|
|
| // Use preferred packet size and verify that rendering starts.
|
| -TEST_F(WASAPIAudioOutputStreamTest, ValidPacketSize) {
|
| - ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager_.get()));
|
| -
|
| +TEST(WASAPIAudioOutputStreamTest, ValidPacketSize) {
|
| + scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
|
| + ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()));
|
| +
|
| + base::MessageLoopForUI loop;
|
| MockAudioSourceCallback source;
|
| +
|
| // Create default WASAPI output stream which plays out in stereo using
|
| // the shared mixing rate. The default buffer size is 10ms.
|
| - AudioOutputStreamWrapper aosw(audio_manager_.get());
|
| + AudioOutputStreamWrapper aosw(audio_manager.get());
|
| AudioOutputStream* aos = aosw.Create();
|
| EXPECT_TRUE(aos->Open());
|
|
|
| @@ -392,15 +386,14 @@
|
| // Wait for the first callback and verify its parameters. Ignore any
|
| // subsequent callbacks that might arrive.
|
| EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0))
|
| - .WillOnce(DoAll(QuitLoop(message_loop_.task_runner()),
|
| + .WillOnce(DoAll(QuitLoop(loop.task_runner()),
|
| Return(aosw.samples_per_packet())))
|
| .WillRepeatedly(Return(0));
|
|
|
| aos->Start(&source);
|
| - message_loop_.PostDelayedTask(FROM_HERE,
|
| - base::MessageLoop::QuitWhenIdleClosure(),
|
| - TestTimeouts::action_timeout());
|
| - message_loop_.Run();
|
| + loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
|
| + TestTimeouts::action_timeout());
|
| + loop.Run();
|
| aos->Stop();
|
| aos->Close();
|
| }
|
| @@ -412,10 +405,11 @@
|
| // with --gtest_also_run_disabled_tests or set the GTEST_ALSO_RUN_DISABLED_TESTS
|
| // environment variable to a value greater than 0.
|
| // The test files are approximately 20 seconds long.
|
| -TEST_F(WASAPIAudioOutputStreamTest, DISABLED_ReadFromStereoFile) {
|
| - ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager_.get()));
|
| -
|
| - AudioOutputStreamWrapper aosw(audio_manager_.get());
|
| +TEST(WASAPIAudioOutputStreamTest, DISABLED_ReadFromStereoFile) {
|
| + scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
|
| + ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()));
|
| +
|
| + AudioOutputStreamWrapper aosw(audio_manager.get());
|
| AudioOutputStream* aos = aosw.Create();
|
| EXPECT_TRUE(aos->Open());
|
|
|
| @@ -461,11 +455,12 @@
|
| // The expected outcomes of each setting in this test has been derived
|
| // manually using log outputs (--v=1).
|
| // It's disabled by default because a flag is required to enable exclusive mode.
|
| -TEST_F(WASAPIAudioOutputStreamTest, DISABLED_ExclusiveModeBufferSizesAt48kHz) {
|
| - ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager_.get()) &&
|
| +TEST(WASAPIAudioOutputStreamTest, DISABLED_ExclusiveModeBufferSizesAt48kHz) {
|
| + scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
|
| + ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()) &&
|
| ExclusiveModeIsEnabled());
|
|
|
| - AudioOutputStreamWrapper aosw(audio_manager_.get());
|
| + AudioOutputStreamWrapper aosw(audio_manager.get());
|
|
|
| // 10ms @ 48kHz shall work.
|
| // Note that, this is the same size as we can use for shared-mode streaming
|
| @@ -509,11 +504,12 @@
|
| // The expected outcomes of each setting in this test has been derived
|
| // manually using log outputs (--v=1).
|
| // It's disabled by default because a flag is required to enable exclusive mode.
|
| -TEST_F(WASAPIAudioOutputStreamTest, DISABLED_ExclusiveModeBufferSizesAt44kHz) {
|
| - ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager_.get()) &&
|
| +TEST(WASAPIAudioOutputStreamTest, DISABLED_ExclusiveModeBufferSizesAt44kHz) {
|
| + scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
|
| + ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()) &&
|
| ExclusiveModeIsEnabled());
|
|
|
| - AudioOutputStreamWrapper aosw(audio_manager_.get());
|
| + AudioOutputStreamWrapper aosw(audio_manager.get());
|
|
|
| // 10ms @ 44.1kHz does not work due to misalignment.
|
| // This test will propose an aligned buffer size of 10.1587ms.
|
| @@ -564,15 +560,17 @@
|
| // Verify that we can open and start the output stream in exclusive mode at
|
| // the lowest possible delay at 48kHz.
|
| // It's disabled by default because a flag is required to enable exclusive mode.
|
| -TEST_F(WASAPIAudioOutputStreamTest,
|
| - DISABLED_ExclusiveModeMinBufferSizeAt48kHz) {
|
| - ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager_.get()) &&
|
| +TEST(WASAPIAudioOutputStreamTest, DISABLED_ExclusiveModeMinBufferSizeAt48kHz) {
|
| + scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
|
| + ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndOutputDevices(audio_manager.get()) &&
|
| ExclusiveModeIsEnabled());
|
|
|
| + base::MessageLoopForUI loop;
|
| MockAudioSourceCallback source;
|
| +
|
| // Create exclusive-mode WASAPI output stream which plays out in stereo
|
| // using the minimum buffer size at 48kHz sample rate.
|
| - AudioOutputStreamWrapper aosw(audio_manager_.get());
|
| + AudioOutputStreamWrapper aosw(audio_manager.get());
|
| AudioOutputStream* aos = aosw.Create(48000, 160);
|
| EXPECT_TRUE(aos->Open());
|
|
|
| @@ -582,15 +580,14 @@
|
|
|
| // Wait for the first callback and verify its parameters.
|
| EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0))
|
| - .WillOnce(DoAll(QuitLoop(message_loop_.task_runner()),
|
| + .WillOnce(DoAll(QuitLoop(loop.task_runner()),
|
| Return(aosw.samples_per_packet())))
|
| .WillRepeatedly(Return(aosw.samples_per_packet()));
|
|
|
| aos->Start(&source);
|
| - message_loop_.PostDelayedTask(FROM_HERE,
|
| - base::MessageLoop::QuitWhenIdleClosure(),
|
| - TestTimeouts::action_timeout());
|
| - message_loop_.Run();
|
| + loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
|
| + TestTimeouts::action_timeout());
|
| + loop.Run();
|
| aos->Stop();
|
| aos->Close();
|
| }
|
| @@ -598,14 +595,16 @@
|
| // Verify that we can open and start the output stream in exclusive mode at
|
| // the lowest possible delay at 44.1kHz.
|
| // It's disabled by default because a flag is required to enable exclusive mode.
|
| -TEST_F(WASAPIAudioOutputStreamTest,
|
| - DISABLED_ExclusiveModeMinBufferSizeAt44kHz) {
|
| +TEST(WASAPIAudioOutputStreamTest, DISABLED_ExclusiveModeMinBufferSizeAt44kHz) {
|
| ABORT_AUDIO_TEST_IF_NOT(ExclusiveModeIsEnabled());
|
| -
|
| + scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
|
| +
|
| + base::MessageLoopForUI loop;
|
| MockAudioSourceCallback source;
|
| +
|
| // Create exclusive-mode WASAPI output stream which plays out in stereo
|
| // using the minimum buffer size at 44.1kHz sample rate.
|
| - AudioOutputStreamWrapper aosw(audio_manager_.get());
|
| + AudioOutputStreamWrapper aosw(audio_manager.get());
|
| AudioOutputStream* aos = aosw.Create(44100, 160);
|
| EXPECT_TRUE(aos->Open());
|
|
|
| @@ -615,15 +614,14 @@
|
|
|
| // Wait for the first callback and verify its parameters.
|
| EXPECT_CALL(source, OnMoreData(NotNull(), HasValidDelay(bytes_per_packet), 0))
|
| - .WillOnce(DoAll(QuitLoop(message_loop_.task_runner()),
|
| + .WillOnce(DoAll(QuitLoop(loop.task_runner()),
|
| Return(aosw.samples_per_packet())))
|
| .WillRepeatedly(Return(aosw.samples_per_packet()));
|
|
|
| aos->Start(&source);
|
| - message_loop_.PostDelayedTask(FROM_HERE,
|
| - base::MessageLoop::QuitWhenIdleClosure(),
|
| - TestTimeouts::action_timeout());
|
| - message_loop_.Run();
|
| + loop.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
|
| + TestTimeouts::action_timeout());
|
| + loop.Run();
|
| aos->Stop();
|
| aos->Close();
|
| }
|
|
|