| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 }; | 217 }; |
| 218 | 218 |
| 219 // Convenience method which creates a default AudioOutputStream object. | 219 // Convenience method which creates a default AudioOutputStream object. |
| 220 static AudioOutputStream* CreateDefaultAudioOutputStream() { | 220 static AudioOutputStream* CreateDefaultAudioOutputStream() { |
| 221 AudioOutputStreamWrapper aosw; | 221 AudioOutputStreamWrapper aosw; |
| 222 AudioOutputStream* aos = aosw.Create(); | 222 AudioOutputStream* aos = aosw.Create(); |
| 223 return aos; | 223 return aos; |
| 224 } | 224 } |
| 225 | 225 |
| 226 static void QuitMessageLoop(base::MessageLoopProxy* proxy) { | 226 static void QuitMessageLoop(base::MessageLoopProxy* proxy) { |
| 227 proxy->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 227 proxy->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 228 } | 228 } |
| 229 | 229 |
| 230 // Verify that we can retrieve the current hardware/mixing sample rate | 230 // Verify that we can retrieve the current hardware/mixing sample rate |
| 231 // for all supported device roles. The ERole enumeration defines constants | 231 // for all supported device roles. The ERole enumeration defines constants |
| 232 // that indicate the role that the system/user has assigned to an audio | 232 // that indicate the role that the system/user has assigned to an audio |
| 233 // endpoint device. | 233 // endpoint device. |
| 234 // TODO(henrika): modify this test when we support full device enumeration. | 234 // TODO(henrika): modify this test when we support full device enumeration. |
| 235 TEST(WinAudioOutputTest, WASAPIAudioOutputStreamTestHardwareSampleRate) { | 235 TEST(WinAudioOutputTest, WASAPIAudioOutputStreamTestHardwareSampleRate) { |
| 236 if (!CanRunAudioTests()) | 236 if (!CanRunAudioTests()) |
| 237 return; | 237 return; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 // Wait for the first callback and verify its parameters. | 389 // Wait for the first callback and verify its parameters. |
| 390 EXPECT_CALL(source, OnMoreData(aos, NotNull(), bytes_per_packet, | 390 EXPECT_CALL(source, OnMoreData(aos, NotNull(), bytes_per_packet, |
| 391 HasValidDelay(state))) | 391 HasValidDelay(state))) |
| 392 .WillOnce( | 392 .WillOnce( |
| 393 DoAll( | 393 DoAll( |
| 394 InvokeWithoutArgs( | 394 InvokeWithoutArgs( |
| 395 CreateFunctor(&QuitMessageLoop, proxy.get())), | 395 CreateFunctor(&QuitMessageLoop, proxy.get())), |
| 396 Return(bytes_per_packet))); | 396 Return(bytes_per_packet))); |
| 397 | 397 |
| 398 aos->Start(&source); | 398 aos->Start(&source); |
| 399 loop.PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask(), | 399 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), |
| 400 TestTimeouts::action_timeout_ms()); | 400 TestTimeouts::action_timeout_ms()); |
| 401 loop.Run(); | 401 loop.Run(); |
| 402 aos->Stop(); | 402 aos->Stop(); |
| 403 aos->Close(); | 403 aos->Close(); |
| 404 } | 404 } |
| 405 | 405 |
| 406 // Use a fixed packets size (independent of sample rate) and verify | 406 // Use a fixed packets size (independent of sample rate) and verify |
| 407 // that rendering starts. | 407 // that rendering starts. |
| 408 TEST(WinAudioOutputTest, WASAPIAudioOutputStreamTestPacketSizeInSamples) { | 408 TEST(WinAudioOutputTest, WASAPIAudioOutputStreamTestPacketSizeInSamples) { |
| 409 if (!CanRunAudioTests()) | 409 if (!CanRunAudioTests()) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 430 // Wait for the first callback and verify its parameters. | 430 // Wait for the first callback and verify its parameters. |
| 431 EXPECT_CALL(source, OnMoreData(aos, NotNull(), bytes_per_packet, | 431 EXPECT_CALL(source, OnMoreData(aos, NotNull(), bytes_per_packet, |
| 432 HasValidDelay(state))) | 432 HasValidDelay(state))) |
| 433 .WillOnce( | 433 .WillOnce( |
| 434 DoAll( | 434 DoAll( |
| 435 InvokeWithoutArgs( | 435 InvokeWithoutArgs( |
| 436 CreateFunctor(&QuitMessageLoop, proxy.get())), | 436 CreateFunctor(&QuitMessageLoop, proxy.get())), |
| 437 Return(bytes_per_packet))); | 437 Return(bytes_per_packet))); |
| 438 | 438 |
| 439 aos->Start(&source); | 439 aos->Start(&source); |
| 440 loop.PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask(), | 440 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), |
| 441 TestTimeouts::action_timeout_ms()); | 441 TestTimeouts::action_timeout_ms()); |
| 442 loop.Run(); | 442 loop.Run(); |
| 443 aos->Stop(); | 443 aos->Stop(); |
| 444 aos->Close(); | 444 aos->Close(); |
| 445 } | 445 } |
| 446 | 446 |
| 447 TEST(WinAudioOutputTest, WASAPIAudioOutputStreamTestMono) { | 447 TEST(WinAudioOutputTest, WASAPIAudioOutputStreamTestMono) { |
| 448 if (!CanRunAudioTests()) | 448 if (!CanRunAudioTests()) |
| 449 return; | 449 return; |
| 450 | 450 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 468 | 468 |
| 469 EXPECT_CALL(source, OnMoreData(aos, NotNull(), bytes_per_packet, | 469 EXPECT_CALL(source, OnMoreData(aos, NotNull(), bytes_per_packet, |
| 470 HasValidDelay(state))) | 470 HasValidDelay(state))) |
| 471 .WillOnce( | 471 .WillOnce( |
| 472 DoAll( | 472 DoAll( |
| 473 InvokeWithoutArgs( | 473 InvokeWithoutArgs( |
| 474 CreateFunctor(&QuitMessageLoop, proxy.get())), | 474 CreateFunctor(&QuitMessageLoop, proxy.get())), |
| 475 Return(bytes_per_packet))); | 475 Return(bytes_per_packet))); |
| 476 | 476 |
| 477 aos->Start(&source); | 477 aos->Start(&source); |
| 478 loop.PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask(), | 478 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), |
| 479 TestTimeouts::action_timeout_ms()); | 479 TestTimeouts::action_timeout_ms()); |
| 480 loop.Run(); | 480 loop.Run(); |
| 481 aos->Stop(); | 481 aos->Stop(); |
| 482 aos->Close(); | 482 aos->Close(); |
| 483 } | 483 } |
| 484 | 484 |
| 485 // This test is intended for manual tests and should only be enabled | 485 // This test is intended for manual tests and should only be enabled |
| 486 // when it is required to store the captured data on a local file. | 486 // when it is required to store the captured data on a local file. |
| 487 // By default, GTest will print out YOU HAVE 1 DISABLED TEST. | 487 // By default, GTest will print out YOU HAVE 1 DISABLED TEST. |
| 488 // To include disabled tests in test execution, just invoke the test program | 488 // To include disabled tests in test execution, just invoke the test program |
| (...skipping 30 matching lines...) Expand all Loading... |
| 519 | 519 |
| 520 aos->Start(&file_source); | 520 aos->Start(&file_source); |
| 521 base::PlatformThread::Sleep(file_duration_ms); | 521 base::PlatformThread::Sleep(file_duration_ms); |
| 522 aos->Stop(); | 522 aos->Stop(); |
| 523 | 523 |
| 524 LOG(INFO) << ">> File playout has stopped."; | 524 LOG(INFO) << ">> File playout has stopped."; |
| 525 aos->Close(); | 525 aos->Close(); |
| 526 } | 526 } |
| 527 | 527 |
| 528 } // namespace media | 528 } // namespace media |
| OLD | NEW |