OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/android/build_info.h" | 5 #include "base/android/build_info.h" |
6 #include "base/basictypes.h" | 6 #include "base/basictypes.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/run_loop.h" | |
11 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
12 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
13 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
14 #include "base/test/test_timeouts.h" | 15 #include "base/test/test_timeouts.h" |
15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
17 #include "media/audio/android/audio_manager_android.h" | 18 #include "media/audio/android/audio_manager_android.h" |
18 #include "media/audio/audio_io.h" | 19 #include "media/audio/audio_io.h" |
19 #include "media/audio/audio_manager_base.h" | 20 #include "media/audio/audio_manager_base.h" |
20 #include "media/audio/mock_audio_source_callback.h" | 21 #include "media/audio/mock_audio_source_callback.h" |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 scoped_ptr<media::SeekableBuffer> fifo_; | 404 scoped_ptr<media::SeekableBuffer> fifo_; |
404 scoped_ptr<uint8[]> buffer_; | 405 scoped_ptr<uint8[]> buffer_; |
405 bool started_; | 406 bool started_; |
406 | 407 |
407 DISALLOW_COPY_AND_ASSIGN(FullDuplexAudioSinkSource); | 408 DISALLOW_COPY_AND_ASSIGN(FullDuplexAudioSinkSource); |
408 }; | 409 }; |
409 | 410 |
410 // Test fixture class for tests which only exercise the output path. | 411 // Test fixture class for tests which only exercise the output path. |
411 class AudioAndroidOutputTest : public testing::Test { | 412 class AudioAndroidOutputTest : public testing::Test { |
412 public: | 413 public: |
413 AudioAndroidOutputTest() {} | 414 AudioAndroidOutputTest() |
415 : loop_(new base::MessageLoopForUI()), | |
416 audio_manager_(AudioManager::CreateForTesting()), | |
417 audio_output_stream_(NULL) { | |
418 } | |
419 | |
420 virtual ~AudioAndroidOutputTest() { | |
421 } | |
414 | 422 |
415 protected: | 423 protected: |
416 virtual void SetUp() { | 424 AudioManager* audio_manager() { return audio_manager_.get(); } |
417 audio_manager_.reset(AudioManager::CreateForTesting()); | 425 base::MessageLoopForUI* loop() { return loop_.get(); } |
418 loop_.reset(new base::MessageLoopForUI()); | 426 const AudioParameters& audio_output_parameters() { |
427 return audio_output_parameters_; | |
428 } | |
429 AudioOutputStream* audio_output_stream() const { | |
430 return audio_output_stream_; | |
419 } | 431 } |
420 | 432 |
421 virtual void TearDown() {} | 433 // Synchronously runs the provided callback/closure on the audio thread. |
434 void RunOnAudioThread(const base::Closure& closure) { | |
435 if (!audio_manager()->GetTaskRunner()->BelongsToCurrentThread()) { | |
436 base::WaitableEvent event(false, false); | |
437 audio_manager()->GetTaskRunner()->PostTask( | |
438 FROM_HERE, | |
439 base::Bind(&AudioAndroidOutputTest::RunOnAudioThreadImpl, | |
440 base::Unretained(this), | |
441 closure, | |
442 &event)); | |
443 event.Wait(); | |
444 } else { | |
445 closure.Run(); | |
446 } | |
447 } | |
422 | 448 |
423 AudioManager* audio_manager() { return audio_manager_.get(); } | 449 void RunOnAudioThreadImpl(const base::Closure& closure, |
424 base::MessageLoopForUI* loop() { return loop_.get(); } | 450 base::WaitableEvent* event) { |
451 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); | |
452 closure.Run(); | |
453 event->Signal(); | |
454 } | |
425 | 455 |
426 AudioParameters GetDefaultOutputStreamParameters() { | 456 void GetDefaultOutputStreamParametersOnAudioThread() { |
427 return audio_manager()->GetDefaultOutputStreamParameters(); | 457 RunOnAudioThread( |
458 base::Bind(&AudioAndroidOutputTest::GetDefaultOutputStreamParameters, | |
459 base::Unretained(this))); | |
460 } | |
461 | |
462 void MakeAudioOutputStreamOnAudioThread(const AudioParameters& params) { | |
463 RunOnAudioThread( | |
464 base::Bind(&AudioAndroidOutputTest::MakeOutputStream, | |
465 base::Unretained(this), | |
466 params)); | |
467 } | |
468 | |
469 void OpenAndCloseAudioOutputStreamOnAudioThread() { | |
470 RunOnAudioThread( | |
471 base::Bind(&AudioAndroidOutputTest::OpenAndClose, | |
472 base::Unretained(this))); | |
473 } | |
474 | |
475 void OpenAndStartAudioOutputStreamOnAudioThread( | |
476 AudioOutputStream::AudioSourceCallback* source) { | |
477 RunOnAudioThread( | |
478 base::Bind(&AudioAndroidOutputTest::OpenAndStart, | |
479 base::Unretained(this), | |
480 source)); | |
481 } | |
482 | |
483 void StopAndCloseAudioOutputStreamOnAudioThread() { | |
484 RunOnAudioThread( | |
485 base::Bind(&AudioAndroidOutputTest::StopAndClose, | |
486 base::Unretained(this))); | |
428 } | 487 } |
429 | 488 |
430 double AverageTimeBetweenCallbacks(int num_callbacks) const { | 489 double AverageTimeBetweenCallbacks(int num_callbacks) const { |
431 return ((end_time_ - start_time_) / static_cast<double>(num_callbacks - 1)) | 490 return ((end_time_ - start_time_) / static_cast<double>(num_callbacks - 1)) |
432 .InMillisecondsF(); | 491 .InMillisecondsF(); |
433 } | 492 } |
434 | 493 |
435 void StartOutputStreamCallbacks(const AudioParameters& params) { | 494 void StartOutputStreamCallbacks(const AudioParameters& params) { |
436 double expected_time_between_callbacks_ms = | 495 double expected_time_between_callbacks_ms = |
437 ExpectedTimeBetweenCallbacks(params); | 496 ExpectedTimeBetweenCallbacks(params); |
438 const int num_callbacks = | 497 const int num_callbacks = |
439 (kCallbackTestTimeMs / expected_time_between_callbacks_ms); | 498 (kCallbackTestTimeMs / expected_time_between_callbacks_ms); |
440 AudioOutputStream* stream = audio_manager()->MakeAudioOutputStream( | 499 MakeAudioOutputStreamOnAudioThread(params); |
441 params, std::string()); | |
442 EXPECT_TRUE(stream); | |
443 | 500 |
444 int count = 0; | 501 int count = 0; |
445 MockAudioSourceCallback source; | 502 MockAudioSourceCallback source; |
446 | 503 |
447 EXPECT_CALL(source, OnMoreData(NotNull(), _)) | 504 EXPECT_CALL(source, OnMoreData(NotNull(), _)) |
448 .Times(AtLeast(num_callbacks)) | 505 .Times(AtLeast(num_callbacks)) |
449 .WillRepeatedly( | 506 .WillRepeatedly( |
450 DoAll(CheckCountAndPostQuitTask(&count, num_callbacks, loop()), | 507 DoAll(CheckCountAndPostQuitTask(&count, num_callbacks, loop()), |
451 Invoke(RealOnMoreData))); | 508 Invoke(RealOnMoreData))); |
452 EXPECT_CALL(source, OnError(stream)).Times(0); | 509 EXPECT_CALL(source, OnError(audio_output_stream())).Times(0); |
453 EXPECT_CALL(source, OnMoreIOData(_, _, _)).Times(0); | 510 EXPECT_CALL(source, OnMoreIOData(_, _, _)).Times(0); |
454 | 511 |
455 EXPECT_TRUE(stream->Open()); | 512 OpenAndStartAudioOutputStreamOnAudioThread(&source); |
456 stream->Start(&source); | 513 |
457 start_time_ = base::TimeTicks::Now(); | 514 start_time_ = base::TimeTicks::Now(); |
458 loop()->Run(); | 515 loop()->Run(); |
459 end_time_ = base::TimeTicks::Now(); | 516 end_time_ = base::TimeTicks::Now(); |
460 stream->Stop(); | 517 |
461 stream->Close(); | 518 StopAndCloseAudioOutputStreamOnAudioThread(); |
462 | 519 |
463 double average_time_between_callbacks_ms = | 520 double average_time_between_callbacks_ms = |
464 AverageTimeBetweenCallbacks(num_callbacks); | 521 AverageTimeBetweenCallbacks(num_callbacks); |
465 VLOG(0) << "expected time between callbacks: " | 522 VLOG(0) << "expected time between callbacks: " |
466 << expected_time_between_callbacks_ms << " ms"; | 523 << expected_time_between_callbacks_ms << " ms"; |
467 VLOG(0) << "average time between callbacks: " | 524 VLOG(0) << "average time between callbacks: " |
468 << average_time_between_callbacks_ms << " ms"; | 525 << average_time_between_callbacks_ms << " ms"; |
469 EXPECT_GE(average_time_between_callbacks_ms, | 526 EXPECT_GE(average_time_between_callbacks_ms, |
470 0.70 * expected_time_between_callbacks_ms); | 527 0.70 * expected_time_between_callbacks_ms); |
471 EXPECT_LE(average_time_between_callbacks_ms, | 528 EXPECT_LE(average_time_between_callbacks_ms, |
472 1.30 * expected_time_between_callbacks_ms); | 529 1.30 * expected_time_between_callbacks_ms); |
473 } | 530 } |
474 | 531 |
532 void GetDefaultOutputStreamParameters() { | |
533 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); | |
534 audio_output_parameters_ = | |
535 audio_manager()->GetDefaultOutputStreamParameters(); | |
536 EXPECT_TRUE(audio_output_parameters_.IsValid()); | |
537 } | |
538 | |
539 void MakeOutputStream(const AudioParameters& params) { | |
540 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); | |
541 audio_output_stream_ = audio_manager()->MakeAudioOutputStream( | |
542 params, std::string()); | |
543 EXPECT_TRUE(audio_output_stream_); | |
544 } | |
545 | |
546 void OpenAndClose() { | |
547 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); | |
548 EXPECT_TRUE(audio_output_stream()->Open()); | |
549 audio_output_stream()->Close(); | |
tommi (sloooow) - chröme
2014/02/18 12:03:35
Everywhere where we do this, we have a dangling po
henrika (OOO until Aug 14)
2014/02/18 12:34:41
Done.
| |
550 } | |
551 | |
552 void OpenAndStart(AudioOutputStream::AudioSourceCallback* source) { | |
553 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); | |
554 EXPECT_TRUE(audio_output_stream()->Open()); | |
555 audio_output_stream()->Start(source); | |
556 } | |
557 | |
558 void StopAndClose() { | |
559 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); | |
560 audio_output_stream()->Stop(); | |
561 audio_output_stream()->Close(); | |
562 audio_output_stream_ = NULL; | |
563 } | |
564 | |
475 scoped_ptr<base::MessageLoopForUI> loop_; | 565 scoped_ptr<base::MessageLoopForUI> loop_; |
476 scoped_ptr<AudioManager> audio_manager_; | 566 scoped_ptr<AudioManager> audio_manager_; |
567 AudioParameters audio_output_parameters_; | |
568 AudioOutputStream* audio_output_stream_; | |
477 base::TimeTicks start_time_; | 569 base::TimeTicks start_time_; |
478 base::TimeTicks end_time_; | 570 base::TimeTicks end_time_; |
479 | 571 |
480 private: | 572 private: |
481 DISALLOW_COPY_AND_ASSIGN(AudioAndroidOutputTest); | 573 DISALLOW_COPY_AND_ASSIGN(AudioAndroidOutputTest); |
482 }; | 574 }; |
483 | 575 |
484 // AudioRecordInputStream should only be created on Jelly Bean and higher. This | 576 // AudioRecordInputStream should only be created on Jelly Bean and higher. This |
485 // ensures we only test against the AudioRecord path when that is satisfied. | 577 // ensures we only test against the AudioRecord path when that is satisfied. |
486 std::vector<bool> RunAudioRecordInputPathTests() { | 578 std::vector<bool> RunAudioRecordInputPathTests() { |
487 std::vector<bool> tests; | 579 std::vector<bool> tests; |
488 tests.push_back(false); | 580 tests.push_back(false); |
489 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 16) | 581 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 16) |
490 tests.push_back(true); | 582 tests.push_back(true); |
491 return tests; | 583 return tests; |
492 } | 584 } |
493 | 585 |
494 // Test fixture class for tests which exercise the input path, or both input and | 586 // Test fixture class for tests which exercise the input path, or both input and |
495 // output paths. It is value-parameterized to test against both the Java | 587 // output paths. It is value-parameterized to test against both the Java |
496 // AudioRecord (when true) and native OpenSLES (when false) input paths. | 588 // AudioRecord (when true) and native OpenSLES (when false) input paths. |
497 class AudioAndroidInputTest : public AudioAndroidOutputTest, | 589 class AudioAndroidInputTest : public AudioAndroidOutputTest, |
498 public testing::WithParamInterface<bool> { | 590 public testing::WithParamInterface<bool> { |
499 public: | 591 public: |
500 AudioAndroidInputTest() {} | 592 AudioAndroidInputTest() : audio_input_stream_(NULL) {} |
501 | 593 |
502 protected: | 594 protected: |
595 AudioInputStream* audio_input_stream() { return audio_input_stream_; } | |
596 AudioParameters audio_input_parameters() { return audio_input_parameters_; } | |
597 | |
503 AudioParameters GetInputStreamParameters() { | 598 AudioParameters GetInputStreamParameters() { |
504 AudioParameters input_params = audio_manager()->GetInputStreamParameters( | 599 GetDefaultInputStreamParametersOnAudioThread(); |
505 AudioManagerBase::kDefaultDeviceId); | 600 |
506 // Override the platform effects setting to use the AudioRecord or OpenSLES | 601 // Override the platform effects setting to use the AudioRecord or OpenSLES |
507 // path as requested. | 602 // path as requested. |
508 int effects = GetParam() ? AudioParameters::ECHO_CANCELLER : | 603 int effects = GetParam() ? AudioParameters::ECHO_CANCELLER : |
509 AudioParameters::NO_EFFECTS; | 604 AudioParameters::NO_EFFECTS; |
510 AudioParameters params(input_params.format(), | 605 AudioParameters params(audio_input_parameters().format(), |
511 input_params.channel_layout(), | 606 audio_input_parameters().channel_layout(), |
512 input_params.input_channels(), | 607 audio_input_parameters().input_channels(), |
513 input_params.sample_rate(), | 608 audio_input_parameters().sample_rate(), |
514 input_params.bits_per_sample(), | 609 audio_input_parameters().bits_per_sample(), |
515 input_params.frames_per_buffer(), | 610 audio_input_parameters().frames_per_buffer(), |
516 effects); | 611 effects); |
517 return params; | 612 return params; |
518 } | 613 } |
519 | 614 |
615 void GetDefaultInputStreamParametersOnAudioThread() { | |
616 RunOnAudioThread( | |
617 base::Bind(&AudioAndroidInputTest::GetDefaultInputStreamParameters, | |
618 base::Unretained(this))); | |
619 } | |
620 | |
621 void MakeAudioInputStreamOnAudioThread(const AudioParameters& params) { | |
622 RunOnAudioThread( | |
623 base::Bind(&AudioAndroidInputTest::MakeInputStream, | |
624 base::Unretained(this), | |
625 params)); | |
626 } | |
627 | |
628 void OpenAndCloseAudioInputStreamOnAudioThread() { | |
629 RunOnAudioThread( | |
630 base::Bind(&AudioAndroidInputTest::OpenAndClose, | |
631 base::Unretained(this))); | |
632 } | |
633 | |
634 void OpenAndStartAudioInputStreamOnAudioThread( | |
635 AudioInputStream::AudioInputCallback* sink) { | |
636 RunOnAudioThread( | |
637 base::Bind(&AudioAndroidInputTest::OpenAndStart, | |
638 base::Unretained(this), | |
639 sink)); | |
640 } | |
641 | |
642 void StopAndCloseAudioInputStreamOnAudioThread() { | |
643 RunOnAudioThread( | |
644 base::Bind(&AudioAndroidInputTest::StopAndClose, | |
645 base::Unretained(this))); | |
646 } | |
647 | |
520 void StartInputStreamCallbacks(const AudioParameters& params) { | 648 void StartInputStreamCallbacks(const AudioParameters& params) { |
521 double expected_time_between_callbacks_ms = | 649 double expected_time_between_callbacks_ms = |
522 ExpectedTimeBetweenCallbacks(params); | 650 ExpectedTimeBetweenCallbacks(params); |
523 const int num_callbacks = | 651 const int num_callbacks = |
524 (kCallbackTestTimeMs / expected_time_between_callbacks_ms); | 652 (kCallbackTestTimeMs / expected_time_between_callbacks_ms); |
525 AudioInputStream* stream = audio_manager()->MakeAudioInputStream( | 653 |
526 params, AudioManagerBase::kDefaultDeviceId); | 654 MakeAudioInputStreamOnAudioThread(params); |
527 EXPECT_TRUE(stream); | |
528 | 655 |
529 int count = 0; | 656 int count = 0; |
530 MockAudioInputCallback sink; | 657 MockAudioInputCallback sink; |
531 | 658 |
532 EXPECT_CALL(sink, | 659 EXPECT_CALL(sink, |
533 OnData(stream, NotNull(), params.GetBytesPerBuffer(), _, _)) | 660 OnData(audio_input_stream(), |
661 NotNull(), | |
662 params. | |
663 GetBytesPerBuffer(), _, _)) | |
534 .Times(AtLeast(num_callbacks)) | 664 .Times(AtLeast(num_callbacks)) |
535 .WillRepeatedly( | 665 .WillRepeatedly( |
536 CheckCountAndPostQuitTask(&count, num_callbacks, loop())); | 666 CheckCountAndPostQuitTask(&count, num_callbacks, loop())); |
537 EXPECT_CALL(sink, OnError(stream)).Times(0); | 667 EXPECT_CALL(sink, OnError(audio_input_stream())).Times(0); |
538 | 668 |
539 EXPECT_TRUE(stream->Open()); | 669 OpenAndStartAudioInputStreamOnAudioThread(&sink); |
540 stream->Start(&sink); | 670 |
541 start_time_ = base::TimeTicks::Now(); | 671 start_time_ = base::TimeTicks::Now(); |
542 loop()->Run(); | 672 loop()->Run(); |
543 end_time_ = base::TimeTicks::Now(); | 673 end_time_ = base::TimeTicks::Now(); |
544 stream->Stop(); | 674 |
545 stream->Close(); | 675 StopAndCloseAudioInputStreamOnAudioThread(); |
546 | 676 |
547 double average_time_between_callbacks_ms = | 677 double average_time_between_callbacks_ms = |
548 AverageTimeBetweenCallbacks(num_callbacks); | 678 AverageTimeBetweenCallbacks(num_callbacks); |
549 VLOG(0) << "expected time between callbacks: " | 679 VLOG(0) << "expected time between callbacks: " |
550 << expected_time_between_callbacks_ms << " ms"; | 680 << expected_time_between_callbacks_ms << " ms"; |
551 VLOG(0) << "average time between callbacks: " | 681 VLOG(0) << "average time between callbacks: " |
552 << average_time_between_callbacks_ms << " ms"; | 682 << average_time_between_callbacks_ms << " ms"; |
553 EXPECT_GE(average_time_between_callbacks_ms, | 683 EXPECT_GE(average_time_between_callbacks_ms, |
554 0.70 * expected_time_between_callbacks_ms); | 684 0.70 * expected_time_between_callbacks_ms); |
555 EXPECT_LE(average_time_between_callbacks_ms, | 685 EXPECT_LE(average_time_between_callbacks_ms, |
556 1.30 * expected_time_between_callbacks_ms); | 686 1.30 * expected_time_between_callbacks_ms); |
557 } | 687 } |
558 | 688 |
689 void GetDefaultInputStreamParameters() { | |
690 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); | |
691 audio_input_parameters_ = audio_manager()->GetInputStreamParameters( | |
692 AudioManagerBase::kDefaultDeviceId); | |
693 } | |
694 | |
695 void MakeInputStream(const AudioParameters& params) { | |
696 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); | |
697 audio_input_stream_ = audio_manager()->MakeAudioInputStream( | |
698 params, AudioManagerBase::kDefaultDeviceId); | |
699 EXPECT_TRUE(audio_input_stream_); | |
700 } | |
701 | |
702 void OpenAndClose() { | |
703 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); | |
704 EXPECT_TRUE(audio_input_stream()->Open()); | |
705 audio_input_stream()->Close(); | |
tommi (sloooow) - chröme
2014/02/18 12:03:35
same for the input side
henrika (OOO until Aug 14)
2014/02/18 12:34:41
Done.
| |
706 } | |
707 | |
708 void OpenAndStart(AudioInputStream::AudioInputCallback* sink) { | |
709 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); | |
710 EXPECT_TRUE(audio_input_stream()->Open()); | |
711 audio_input_stream()->Start(sink); | |
712 } | |
713 | |
714 void StopAndClose() { | |
715 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); | |
716 audio_input_stream()->Stop(); | |
717 audio_input_stream()->Close(); | |
718 audio_input_stream_ = NULL; | |
719 } | |
559 | 720 |
560 private: | 721 private: |
722 AudioInputStream* audio_input_stream_; | |
723 AudioParameters audio_input_parameters_; | |
561 DISALLOW_COPY_AND_ASSIGN(AudioAndroidInputTest); | 724 DISALLOW_COPY_AND_ASSIGN(AudioAndroidInputTest); |
562 }; | 725 }; |
563 | 726 |
564 // Get the default audio input parameters and log the result. | 727 // Get the default audio input parameters and log the result. |
565 TEST_P(AudioAndroidInputTest, GetDefaultInputStreamParameters) { | 728 TEST_P(AudioAndroidInputTest, GetDefaultInputStreamParameters) { |
566 // We don't go through AudioAndroidInputTest::GetInputStreamParameters() here | 729 // We don't go through AudioAndroidInputTest::GetInputStreamParameters() here |
567 // so that we can log the real (non-overridden) values of the effects. | 730 // so that we can log the real (non-overridden) values of the effects. |
568 AudioParameters params = audio_manager()->GetInputStreamParameters( | 731 GetDefaultInputStreamParametersOnAudioThread(); |
569 AudioManagerBase::kDefaultDeviceId); | 732 EXPECT_TRUE(audio_input_parameters().IsValid()); |
570 EXPECT_TRUE(params.IsValid()); | 733 VLOG(1) << audio_input_parameters(); |
571 VLOG(1) << params; | |
572 } | 734 } |
573 | 735 |
574 // Get the default audio output parameters and log the result. | 736 // Get the default audio output parameters and log the result. |
575 TEST_F(AudioAndroidOutputTest, GetDefaultOutputStreamParameters) { | 737 TEST_F(AudioAndroidOutputTest, GetDefaultOutputStreamParameters) { |
576 AudioParameters params = GetDefaultOutputStreamParameters(); | 738 GetDefaultOutputStreamParametersOnAudioThread(); |
577 EXPECT_TRUE(params.IsValid()); | 739 VLOG(1) << audio_output_parameters(); |
578 VLOG(1) << params; | |
579 } | |
580 | |
581 // Check if low-latency output is supported and log the result as output. | |
582 TEST_F(AudioAndroidOutputTest, IsAudioLowLatencySupported) { | |
583 AudioManagerAndroid* manager = | |
584 static_cast<AudioManagerAndroid*>(audio_manager()); | |
585 bool low_latency = manager->IsAudioLowLatencySupported(); | |
586 low_latency ? VLOG(0) << "Low latency output is supported" | |
587 : VLOG(0) << "Low latency output is *not* supported"; | |
588 } | 740 } |
589 | 741 |
590 // Verify input device enumeration. | 742 // Verify input device enumeration. |
591 TEST_F(AudioAndroidInputTest, GetAudioInputDeviceNames) { | 743 TEST_F(AudioAndroidInputTest, GetAudioInputDeviceNames) { |
592 if (!audio_manager()->HasAudioInputDevices()) | 744 if (!audio_manager()->HasAudioInputDevices()) |
593 return; | 745 return; |
594 AudioDeviceNames devices; | 746 AudioDeviceNames devices; |
595 audio_manager()->GetAudioInputDeviceNames(&devices); | 747 RunOnAudioThread( |
748 base::Bind(&AudioManager::GetAudioInputDeviceNames, | |
749 base::Unretained(audio_manager()), | |
750 &devices)); | |
596 CheckDeviceNames(devices); | 751 CheckDeviceNames(devices); |
597 } | 752 } |
598 | 753 |
599 // Verify output device enumeration. | 754 // Verify output device enumeration. |
600 TEST_F(AudioAndroidOutputTest, GetAudioOutputDeviceNames) { | 755 TEST_F(AudioAndroidOutputTest, GetAudioOutputDeviceNames) { |
601 if (!audio_manager()->HasAudioOutputDevices()) | 756 if (!audio_manager()->HasAudioOutputDevices()) |
602 return; | 757 return; |
603 AudioDeviceNames devices; | 758 AudioDeviceNames devices; |
604 audio_manager()->GetAudioOutputDeviceNames(&devices); | 759 RunOnAudioThread( |
760 base::Bind(&AudioManager::GetAudioOutputDeviceNames, | |
761 base::Unretained(audio_manager()), | |
762 &devices)); | |
605 CheckDeviceNames(devices); | 763 CheckDeviceNames(devices); |
606 } | 764 } |
607 | 765 |
608 // Ensure that a default input stream can be created and closed. | 766 // Ensure that a default input stream can be created and closed. |
609 TEST_P(AudioAndroidInputTest, CreateAndCloseInputStream) { | 767 TEST_P(AudioAndroidInputTest, CreateAndCloseInputStream) { |
610 AudioParameters params = GetInputStreamParameters(); | 768 AudioParameters params = GetInputStreamParameters(); |
611 AudioInputStream* ais = audio_manager()->MakeAudioInputStream( | 769 MakeAudioInputStreamOnAudioThread(params); |
612 params, AudioManagerBase::kDefaultDeviceId); | 770 RunOnAudioThread( |
613 EXPECT_TRUE(ais); | 771 base::Bind(&AudioInputStream::Close, |
614 ais->Close(); | 772 base::Unretained(audio_input_stream()))); |
615 } | 773 } |
616 | 774 |
617 // Ensure that a default output stream can be created and closed. | 775 // Ensure that a default output stream can be created and closed. |
618 // TODO(henrika): should we also verify that this API changes the audio mode | 776 // TODO(henrika): should we also verify that this API changes the audio mode |
619 // to communication mode, and calls RegisterHeadsetReceiver, the first time | 777 // to communication mode, and calls RegisterHeadsetReceiver, the first time |
620 // it is called? | 778 // it is called? |
621 TEST_F(AudioAndroidOutputTest, CreateAndCloseOutputStream) { | 779 TEST_F(AudioAndroidOutputTest, CreateAndCloseOutputStream) { |
622 AudioParameters params = GetDefaultOutputStreamParameters(); | 780 GetDefaultOutputStreamParametersOnAudioThread(); |
623 AudioOutputStream* aos = audio_manager()->MakeAudioOutputStream( | 781 MakeAudioOutputStreamOnAudioThread(audio_output_parameters()); |
624 params, std::string()); | 782 RunOnAudioThread( |
625 EXPECT_TRUE(aos); | 783 base::Bind(&AudioOutputStream::Close, |
626 aos->Close(); | 784 base::Unretained(audio_output_stream()))); |
627 } | 785 } |
628 | 786 |
629 // Ensure that a default input stream can be opened and closed. | 787 // Ensure that a default input stream can be opened and closed. |
630 TEST_P(AudioAndroidInputTest, OpenAndCloseInputStream) { | 788 TEST_P(AudioAndroidInputTest, OpenAndCloseInputStream) { |
631 AudioParameters params = GetInputStreamParameters(); | 789 AudioParameters params = GetInputStreamParameters(); |
632 AudioInputStream* ais = audio_manager()->MakeAudioInputStream( | 790 MakeAudioInputStreamOnAudioThread(params); |
633 params, AudioManagerBase::kDefaultDeviceId); | 791 OpenAndCloseAudioInputStreamOnAudioThread(); |
634 EXPECT_TRUE(ais); | |
635 EXPECT_TRUE(ais->Open()); | |
636 ais->Close(); | |
637 } | 792 } |
638 | 793 |
639 // Ensure that a default output stream can be opened and closed. | 794 // Ensure that a default output stream can be opened and closed. |
640 TEST_F(AudioAndroidOutputTest, OpenAndCloseOutputStream) { | 795 TEST_F(AudioAndroidOutputTest, OpenAndCloseOutputStream) { |
641 AudioParameters params = GetDefaultOutputStreamParameters(); | 796 GetDefaultOutputStreamParametersOnAudioThread(); |
642 AudioOutputStream* aos = audio_manager()->MakeAudioOutputStream( | 797 MakeAudioOutputStreamOnAudioThread(audio_output_parameters()); |
643 params, std::string()); | 798 OpenAndCloseAudioOutputStreamOnAudioThread(); |
644 EXPECT_TRUE(aos); | |
645 EXPECT_TRUE(aos->Open()); | |
646 aos->Close(); | |
647 } | 799 } |
648 | 800 |
649 // Start input streaming using default input parameters and ensure that the | 801 // Start input streaming using default input parameters and ensure that the |
650 // callback sequence is sane. | 802 // callback sequence is sane. |
651 // Disabled per crbug/337867 | |
652 TEST_P(AudioAndroidInputTest, DISABLED_StartInputStreamCallbacks) { | 803 TEST_P(AudioAndroidInputTest, DISABLED_StartInputStreamCallbacks) { |
653 AudioParameters params = GetInputStreamParameters(); | 804 AudioParameters native_params = GetInputStreamParameters(); |
654 StartInputStreamCallbacks(params); | 805 StartInputStreamCallbacks(native_params); |
655 } | 806 } |
656 | 807 |
657 // Start input streaming using non default input parameters and ensure that the | 808 // Start input streaming using non default input parameters and ensure that the |
658 // callback sequence is sane. The only change we make in this test is to select | 809 // callback sequence is sane. The only change we make in this test is to select |
659 // a 10ms buffer size instead of the default size. | 810 // a 10ms buffer size instead of the default size. |
660 // TODO(henrika): possibly add support for more variations. | 811 TEST_P(AudioAndroidInputTest, |
661 // Disabled per crbug/337867 | 812 DISABLED_StartInputStreamCallbacksNonDefaultParameters) { |
662 TEST_P(AudioAndroidInputTest, DISABLED_StartInputStreamCallbacksNonDefaultParame ters) { | |
663 AudioParameters native_params = GetInputStreamParameters(); | 813 AudioParameters native_params = GetInputStreamParameters(); |
664 AudioParameters params(native_params.format(), | 814 AudioParameters params(native_params.format(), |
665 native_params.channel_layout(), | 815 native_params.channel_layout(), |
666 native_params.input_channels(), | 816 native_params.input_channels(), |
667 native_params.sample_rate(), | 817 native_params.sample_rate(), |
668 native_params.bits_per_sample(), | 818 native_params.bits_per_sample(), |
669 native_params.sample_rate() / 100, | 819 native_params.sample_rate() / 100, |
670 native_params.effects()); | 820 native_params.effects()); |
671 StartInputStreamCallbacks(params); | 821 StartInputStreamCallbacks(params); |
672 } | 822 } |
673 | 823 |
674 // Start output streaming using default output parameters and ensure that the | 824 // Start output streaming using default output parameters and ensure that the |
675 // callback sequence is sane. | 825 // callback sequence is sane. |
676 TEST_F(AudioAndroidOutputTest, StartOutputStreamCallbacks) { | 826 TEST_F(AudioAndroidOutputTest, StartOutputStreamCallbacks) { |
677 AudioParameters params = GetDefaultOutputStreamParameters(); | 827 GetDefaultOutputStreamParametersOnAudioThread(); |
678 StartOutputStreamCallbacks(params); | 828 StartOutputStreamCallbacks(audio_output_parameters()); |
679 } | 829 } |
680 | 830 |
681 // Start output streaming using non default output parameters and ensure that | 831 // Start output streaming using non default output parameters and ensure that |
682 // the callback sequence is sane. The only change we make in this test is to | 832 // the callback sequence is sane. The only change we make in this test is to |
683 // select a 10ms buffer size instead of the default size and to open up the | 833 // select a 10ms buffer size instead of the default size and to open up the |
684 // device in mono. | 834 // device in mono. |
685 // TODO(henrika): possibly add support for more variations. | 835 // TODO(henrika): possibly add support for more variations. |
686 TEST_F(AudioAndroidOutputTest, StartOutputStreamCallbacksNonDefaultParameters) { | 836 TEST_F(AudioAndroidOutputTest, StartOutputStreamCallbacksNonDefaultParameters) { |
687 AudioParameters native_params = GetDefaultOutputStreamParameters(); | 837 GetDefaultOutputStreamParametersOnAudioThread(); |
688 AudioParameters params(native_params.format(), | 838 AudioParameters params(audio_output_parameters().format(), |
689 CHANNEL_LAYOUT_MONO, | 839 CHANNEL_LAYOUT_MONO, |
690 native_params.sample_rate(), | 840 audio_output_parameters().sample_rate(), |
691 native_params.bits_per_sample(), | 841 audio_output_parameters().bits_per_sample(), |
692 native_params.sample_rate() / 100); | 842 audio_output_parameters().sample_rate() / 100); |
693 StartOutputStreamCallbacks(params); | 843 StartOutputStreamCallbacks(params); |
694 } | 844 } |
695 | 845 |
696 // Play out a PCM file segment in real time and allow the user to verify that | 846 // Play out a PCM file segment in real time and allow the user to verify that |
697 // the rendered audio sounds OK. | 847 // the rendered audio sounds OK. |
698 // NOTE: this test requires user interaction and is not designed to run as an | 848 // NOTE: this test requires user interaction and is not designed to run as an |
699 // automatized test on bots. | 849 // automatized test on bots. |
700 TEST_F(AudioAndroidOutputTest, DISABLED_RunOutputStreamWithFileAsSource) { | 850 TEST_F(AudioAndroidOutputTest, DISABLED_RunOutputStreamWithFileAsSource) { |
701 AudioParameters params = GetDefaultOutputStreamParameters(); | 851 GetDefaultOutputStreamParametersOnAudioThread(); |
702 VLOG(1) << params; | 852 VLOG(1) << audio_output_parameters(); |
703 AudioOutputStream* aos = audio_manager()->MakeAudioOutputStream( | 853 MakeAudioOutputStreamOnAudioThread(audio_output_parameters()); |
704 params, std::string()); | |
705 EXPECT_TRUE(aos); | |
706 | 854 |
707 std::string file_name; | 855 std::string file_name; |
856 const AudioParameters params = audio_output_parameters(); | |
708 if (params.sample_rate() == 48000 && params.channels() == 2) { | 857 if (params.sample_rate() == 48000 && params.channels() == 2) { |
709 file_name = kSpeechFile_16b_s_48k; | 858 file_name = kSpeechFile_16b_s_48k; |
710 } else if (params.sample_rate() == 48000 && params.channels() == 1) { | 859 } else if (params.sample_rate() == 48000 && params.channels() == 1) { |
711 file_name = kSpeechFile_16b_m_48k; | 860 file_name = kSpeechFile_16b_m_48k; |
712 } else if (params.sample_rate() == 44100 && params.channels() == 2) { | 861 } else if (params.sample_rate() == 44100 && params.channels() == 2) { |
713 file_name = kSpeechFile_16b_s_44k; | 862 file_name = kSpeechFile_16b_s_44k; |
714 } else if (params.sample_rate() == 44100 && params.channels() == 1) { | 863 } else if (params.sample_rate() == 44100 && params.channels() == 1) { |
715 file_name = kSpeechFile_16b_m_44k; | 864 file_name = kSpeechFile_16b_m_44k; |
716 } else { | 865 } else { |
717 FAIL() << "This test supports 44.1kHz and 48kHz mono/stereo only."; | 866 FAIL() << "This test supports 44.1kHz and 48kHz mono/stereo only."; |
718 return; | 867 return; |
719 } | 868 } |
720 | 869 |
721 base::WaitableEvent event(false, false); | 870 base::WaitableEvent event(false, false); |
722 FileAudioSource source(&event, file_name); | 871 FileAudioSource source(&event, file_name); |
723 | 872 |
724 EXPECT_TRUE(aos->Open()); | 873 OpenAndStartAudioOutputStreamOnAudioThread(&source); |
725 aos->SetVolume(1.0); | |
726 aos->Start(&source); | |
727 VLOG(0) << ">> Verify that the file is played out correctly..."; | 874 VLOG(0) << ">> Verify that the file is played out correctly..."; |
728 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_max_timeout())); | 875 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_max_timeout())); |
729 aos->Stop(); | 876 StopAndCloseAudioOutputStreamOnAudioThread(); |
730 aos->Close(); | |
731 } | 877 } |
732 | 878 |
733 // Start input streaming and run it for ten seconds while recording to a | 879 // Start input streaming and run it for ten seconds while recording to a |
734 // local audio file. | 880 // local audio file. |
735 // NOTE: this test requires user interaction and is not designed to run as an | 881 // NOTE: this test requires user interaction and is not designed to run as an |
736 // automatized test on bots. | 882 // automatized test on bots. |
737 TEST_P(AudioAndroidInputTest, DISABLED_RunSimplexInputStreamWithFileAsSink) { | 883 TEST_P(AudioAndroidInputTest, DISABLED_RunSimplexInputStreamWithFileAsSink) { |
738 AudioParameters params = GetInputStreamParameters(); | 884 AudioParameters params = GetInputStreamParameters(); |
739 VLOG(1) << params; | 885 VLOG(1) << params; |
740 AudioInputStream* ais = audio_manager()->MakeAudioInputStream( | 886 MakeAudioInputStreamOnAudioThread(params); |
741 params, AudioManagerBase::kDefaultDeviceId); | |
742 EXPECT_TRUE(ais); | |
743 | 887 |
744 std::string file_name = base::StringPrintf("out_simplex_%d_%d_%d.pcm", | 888 std::string file_name = base::StringPrintf("out_simplex_%d_%d_%d.pcm", |
745 params.sample_rate(), | 889 params.sample_rate(), |
746 params.frames_per_buffer(), | 890 params.frames_per_buffer(), |
747 params.channels()); | 891 params.channels()); |
748 | 892 |
749 base::WaitableEvent event(false, false); | 893 base::WaitableEvent event(false, false); |
750 FileAudioSink sink(&event, params, file_name); | 894 FileAudioSink sink(&event, params, file_name); |
751 | 895 |
752 EXPECT_TRUE(ais->Open()); | 896 OpenAndStartAudioInputStreamOnAudioThread(&sink); |
753 ais->Start(&sink); | |
754 VLOG(0) << ">> Speak into the microphone to record audio..."; | 897 VLOG(0) << ">> Speak into the microphone to record audio..."; |
755 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_max_timeout())); | 898 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_max_timeout())); |
756 ais->Stop(); | 899 StopAndCloseAudioInputStreamOnAudioThread(); |
757 ais->Close(); | |
758 } | 900 } |
759 | 901 |
760 // Same test as RunSimplexInputStreamWithFileAsSink but this time output | 902 // Same test as RunSimplexInputStreamWithFileAsSink but this time output |
761 // streaming is active as well (reads zeros only). | 903 // streaming is active as well (reads zeros only). |
762 // NOTE: this test requires user interaction and is not designed to run as an | 904 // NOTE: this test requires user interaction and is not designed to run as an |
763 // automatized test on bots. | 905 // automatized test on bots. |
764 TEST_P(AudioAndroidInputTest, DISABLED_RunDuplexInputStreamWithFileAsSink) { | 906 TEST_P(AudioAndroidInputTest, DISABLED_RunDuplexInputStreamWithFileAsSink) { |
765 AudioParameters in_params = GetInputStreamParameters(); | 907 AudioParameters in_params = GetInputStreamParameters(); |
766 AudioInputStream* ais = audio_manager()->MakeAudioInputStream( | 908 VLOG(1) << in_params; |
767 in_params, AudioManagerBase::kDefaultDeviceId); | 909 MakeAudioInputStreamOnAudioThread(in_params); |
768 EXPECT_TRUE(ais); | |
769 | 910 |
770 AudioParameters out_params = | 911 GetDefaultOutputStreamParametersOnAudioThread(); |
771 audio_manager()->GetDefaultOutputStreamParameters(); | 912 VLOG(1) << audio_output_parameters(); |
772 AudioOutputStream* aos = audio_manager()->MakeAudioOutputStream( | 913 MakeAudioOutputStreamOnAudioThread(audio_output_parameters()); |
773 out_params, std::string()); | |
774 EXPECT_TRUE(aos); | |
775 | 914 |
776 std::string file_name = base::StringPrintf("out_duplex_%d_%d_%d.pcm", | 915 std::string file_name = base::StringPrintf("out_duplex_%d_%d_%d.pcm", |
777 in_params.sample_rate(), | 916 in_params.sample_rate(), |
778 in_params.frames_per_buffer(), | 917 in_params.frames_per_buffer(), |
779 in_params.channels()); | 918 in_params.channels()); |
780 | 919 |
781 base::WaitableEvent event(false, false); | 920 base::WaitableEvent event(false, false); |
782 FileAudioSink sink(&event, in_params, file_name); | 921 FileAudioSink sink(&event, in_params, file_name); |
783 MockAudioSourceCallback source; | 922 MockAudioSourceCallback source; |
784 | 923 |
785 EXPECT_CALL(source, OnMoreData(NotNull(), _)) | 924 EXPECT_CALL(source, OnMoreData(NotNull(), _)) |
786 .WillRepeatedly(Invoke(RealOnMoreData)); | 925 .WillRepeatedly(Invoke(RealOnMoreData)); |
787 EXPECT_CALL(source, OnError(aos)).Times(0); | 926 EXPECT_CALL(source, OnError(audio_output_stream())).Times(0); |
788 EXPECT_CALL(source, OnMoreIOData(_, _, _)).Times(0); | 927 EXPECT_CALL(source, OnMoreIOData(_, _, _)).Times(0); |
789 | 928 |
790 EXPECT_TRUE(ais->Open()); | 929 OpenAndStartAudioInputStreamOnAudioThread(&sink); |
791 EXPECT_TRUE(aos->Open()); | 930 OpenAndStartAudioOutputStreamOnAudioThread(&source); |
792 ais->Start(&sink); | |
793 aos->Start(&source); | |
794 VLOG(0) << ">> Speak into the microphone to record audio"; | 931 VLOG(0) << ">> Speak into the microphone to record audio"; |
795 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_max_timeout())); | 932 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_max_timeout())); |
796 aos->Stop(); | 933 StopAndCloseAudioOutputStreamOnAudioThread(); |
797 ais->Stop(); | 934 StopAndCloseAudioInputStreamOnAudioThread(); |
798 aos->Close(); | |
799 ais->Close(); | |
800 } | 935 } |
801 | 936 |
802 // Start audio in both directions while feeding captured data into a FIFO so | 937 // Start audio in both directions while feeding captured data into a FIFO so |
803 // it can be read directly (in loopback) by the render side. A small extra | 938 // it can be read directly (in loopback) by the render side. A small extra |
804 // delay will be added by the FIFO and an estimate of this delay will be | 939 // delay will be added by the FIFO and an estimate of this delay will be |
805 // printed out during the test. | 940 // printed out during the test. |
806 // NOTE: this test requires user interaction and is not designed to run as an | 941 // NOTE: this test requires user interaction and is not designed to run as an |
807 // automatized test on bots. | 942 // automatized test on bots. |
808 TEST_P(AudioAndroidInputTest, | 943 TEST_P(AudioAndroidInputTest, |
809 DISABLED_RunSymmetricInputAndOutputStreamsInFullDuplex) { | 944 DISABLED_RunSymmetricInputAndOutputStreamsInFullDuplex) { |
810 // Get native audio parameters for the input side. | 945 // Get native audio parameters for the input side. |
811 AudioParameters default_input_params = GetInputStreamParameters(); | 946 AudioParameters default_input_params = GetInputStreamParameters(); |
812 | 947 |
813 // Modify the parameters so that both input and output can use the same | 948 // Modify the parameters so that both input and output can use the same |
814 // parameters by selecting 10ms as buffer size. This will also ensure that | 949 // parameters by selecting 10ms as buffer size. This will also ensure that |
815 // the output stream will be a mono stream since mono is default for input | 950 // the output stream will be a mono stream since mono is default for input |
816 // audio on Android. | 951 // audio on Android. |
817 AudioParameters io_params(default_input_params.format(), | 952 AudioParameters io_params(default_input_params.format(), |
818 default_input_params.channel_layout(), | 953 default_input_params.channel_layout(), |
819 ChannelLayoutToChannelCount( | 954 ChannelLayoutToChannelCount( |
820 default_input_params.channel_layout()), | 955 default_input_params.channel_layout()), |
821 default_input_params.sample_rate(), | 956 default_input_params.sample_rate(), |
822 default_input_params.bits_per_sample(), | 957 default_input_params.bits_per_sample(), |
823 default_input_params.sample_rate() / 100, | 958 default_input_params.sample_rate() / 100, |
824 default_input_params.effects()); | 959 default_input_params.effects()); |
825 VLOG(1) << io_params; | 960 VLOG(1) << io_params; |
826 | 961 |
827 // Create input and output streams using the common audio parameters. | 962 // Create input and output streams using the common audio parameters. |
828 AudioInputStream* ais = audio_manager()->MakeAudioInputStream( | 963 MakeAudioInputStreamOnAudioThread(io_params); |
829 io_params, AudioManagerBase::kDefaultDeviceId); | 964 MakeAudioOutputStreamOnAudioThread(io_params); |
830 EXPECT_TRUE(ais); | |
831 AudioOutputStream* aos = audio_manager()->MakeAudioOutputStream( | |
832 io_params, std::string()); | |
833 EXPECT_TRUE(aos); | |
834 | 965 |
835 FullDuplexAudioSinkSource full_duplex(io_params); | 966 FullDuplexAudioSinkSource full_duplex(io_params); |
836 | 967 |
837 // Start a full duplex audio session and print out estimates of the extra | 968 // Start a full duplex audio session and print out estimates of the extra |
838 // delay we should expect from the FIFO. If real-time delay measurements are | 969 // delay we should expect from the FIFO. If real-time delay measurements are |
839 // performed, the result should be reduced by this extra delay since it is | 970 // performed, the result should be reduced by this extra delay since it is |
840 // something that has been added by the test. | 971 // something that has been added by the test. |
841 EXPECT_TRUE(ais->Open()); | 972 OpenAndStartAudioInputStreamOnAudioThread(&full_duplex); |
842 EXPECT_TRUE(aos->Open()); | 973 OpenAndStartAudioOutputStreamOnAudioThread(&full_duplex); |
843 ais->Start(&full_duplex); | |
844 aos->Start(&full_duplex); | |
845 VLOG(1) << "HINT: an estimate of the extra FIFO delay will be updated " | 974 VLOG(1) << "HINT: an estimate of the extra FIFO delay will be updated " |
846 << "once per second during this test."; | 975 << "once per second during this test."; |
847 VLOG(0) << ">> Speak into the mic and listen to the audio in loopback..."; | 976 VLOG(0) << ">> Speak into the mic and listen to the audio in loopback..."; |
848 fflush(stdout); | 977 fflush(stdout); |
849 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); | 978 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); |
850 printf("\n"); | 979 printf("\n"); |
851 aos->Stop(); | 980 StopAndCloseAudioOutputStreamOnAudioThread(); |
852 ais->Stop(); | 981 StopAndCloseAudioInputStreamOnAudioThread(); |
853 aos->Close(); | |
854 ais->Close(); | |
855 } | 982 } |
856 | 983 |
857 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, | 984 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, |
858 testing::ValuesIn(RunAudioRecordInputPathTests())); | 985 testing::ValuesIn(RunAudioRecordInputPathTests())); |
859 | 986 |
860 } // namespace media | 987 } // namespace media |
OLD | NEW |