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/base/decoder_buffer.h" | 21 #include "media/base/decoder_buffer.h" |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 scoped_ptr<media::SeekableBuffer> fifo_; | 415 scoped_ptr<media::SeekableBuffer> fifo_; |
415 scoped_ptr<uint8[]> buffer_; | 416 scoped_ptr<uint8[]> buffer_; |
416 bool started_; | 417 bool started_; |
417 | 418 |
418 DISALLOW_COPY_AND_ASSIGN(FullDuplexAudioSinkSource); | 419 DISALLOW_COPY_AND_ASSIGN(FullDuplexAudioSinkSource); |
419 }; | 420 }; |
420 | 421 |
421 // Test fixture class for tests which only exercise the output path. | 422 // Test fixture class for tests which only exercise the output path. |
422 class AudioAndroidOutputTest : public testing::Test { | 423 class AudioAndroidOutputTest : public testing::Test { |
423 public: | 424 public: |
424 AudioAndroidOutputTest() {} | 425 AudioAndroidOutputTest() |
426 : loop_(new base::MessageLoopForUI()), | |
427 audio_manager_(AudioManager::CreateForTesting()) { | |
428 // Wait for the AudioManager to finish any initialization on the audio loop. | |
429 base::RunLoop().RunUntilIdle(); | |
tommi (sloooow) - chröme
2014/01/31 14:06:59
what exactly is it that happens during this loop?
henrika (OOO until Aug 14)
2014/01/31 14:19:05
Sorry, my bad. Copied from test that Dale had just
DaleCurtis
2014/01/31 19:18:12
This is only needed on platforms which post initia
| |
430 } | |
431 | |
432 virtual ~AudioAndroidOutputTest() { | |
433 base::RunLoop().RunUntilIdle(); | |
tommi (sloooow) - chröme
2014/01/31 14:06:59
add a comment for why we need this?
henrika (OOO until Aug 14)
2014/01/31 14:19:05
Will remove.
| |
434 } | |
425 | 435 |
426 protected: | 436 protected: |
427 virtual void SetUp() { | |
428 audio_manager_.reset(AudioManager::CreateForTesting()); | |
429 loop_.reset(new base::MessageLoopForUI()); | |
430 } | |
431 | |
432 virtual void TearDown() {} | |
433 | |
434 AudioManager* audio_manager() { return audio_manager_.get(); } | 437 AudioManager* audio_manager() { return audio_manager_.get(); } |
435 base::MessageLoopForUI* loop() { return loop_.get(); } | 438 base::MessageLoopForUI* loop() { return loop_.get(); } |
436 | 439 |
437 AudioParameters GetDefaultOutputStreamParameters() { | 440 AudioParameters GetDefaultOutputStreamParameters() { |
438 return audio_manager()->GetDefaultOutputStreamParameters(); | 441 return audio_manager()->GetDefaultOutputStreamParameters(); |
439 } | 442 } |
440 | 443 |
441 double AverageTimeBetweenCallbacks(int num_callbacks) const { | 444 double AverageTimeBetweenCallbacks(int num_callbacks) const { |
442 return ((end_time_ - start_time_) / static_cast<double>(num_callbacks - 1)) | 445 return ((end_time_ - start_time_) / static_cast<double>(num_callbacks - 1)) |
443 .InMillisecondsF(); | 446 .InMillisecondsF(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
501 tests.push_back(true); | 504 tests.push_back(true); |
502 return tests; | 505 return tests; |
503 } | 506 } |
504 | 507 |
505 // Test fixture class for tests which exercise the input path, or both input and | 508 // Test fixture class for tests which exercise the input path, or both input and |
506 // output paths. It is value-parameterized to test against both the Java | 509 // output paths. It is value-parameterized to test against both the Java |
507 // AudioRecord (when true) and native OpenSLES (when false) input paths. | 510 // AudioRecord (when true) and native OpenSLES (when false) input paths. |
508 class AudioAndroidInputTest : public AudioAndroidOutputTest, | 511 class AudioAndroidInputTest : public AudioAndroidOutputTest, |
509 public testing::WithParamInterface<bool> { | 512 public testing::WithParamInterface<bool> { |
510 public: | 513 public: |
511 AudioAndroidInputTest() {} | 514 AudioAndroidInputTest() : audio_input_stream_(NULL) {} |
512 | 515 |
513 protected: | 516 protected: |
517 AudioInputStream* ais() { return audio_input_stream_; } | |
tommi (sloooow) - chröme
2014/01/31 14:06:59
I would keep audio_input_stream() in the spirit of
henrika (OOO until Aug 14)
2014/01/31 14:19:05
Will fix.
| |
518 | |
514 AudioParameters GetInputStreamParameters() { | 519 AudioParameters GetInputStreamParameters() { |
515 AudioParameters input_params = audio_manager()->GetInputStreamParameters( | 520 AudioParameters input_params = audio_manager()->GetInputStreamParameters( |
516 AudioManagerBase::kDefaultDeviceId); | 521 AudioManagerBase::kDefaultDeviceId); |
517 // Override the platform effects setting to use the AudioRecord or OpenSLES | 522 // Override the platform effects setting to use the AudioRecord or OpenSLES |
518 // path as requested. | 523 // path as requested. |
519 int effects = GetParam() ? AudioParameters::ECHO_CANCELLER : | 524 int effects = GetParam() ? AudioParameters::ECHO_CANCELLER : |
520 AudioParameters::NO_EFFECTS; | 525 AudioParameters::NO_EFFECTS; |
521 AudioParameters params(input_params.format(), | 526 AudioParameters params(input_params.format(), |
522 input_params.channel_layout(), | 527 input_params.channel_layout(), |
523 input_params.input_channels(), | 528 input_params.input_channels(), |
524 input_params.sample_rate(), | 529 input_params.sample_rate(), |
525 input_params.bits_per_sample(), | 530 input_params.bits_per_sample(), |
526 input_params.frames_per_buffer(), | 531 input_params.frames_per_buffer(), |
527 effects); | 532 effects); |
528 return params; | 533 return params; |
529 } | 534 } |
530 | 535 |
536 void MakeAISOnAudioThread(const AudioParameters& params) { | |
537 RunOnAudioThread( | |
538 base::Bind(&AudioAndroidInputTest::MakeInputStream, | |
539 base::Unretained(this), | |
540 params)); | |
541 } | |
542 | |
543 void OpenAndCloseAISOnAudioThread() { | |
544 RunOnAudioThread( | |
545 base::Bind(&AudioAndroidInputTest::OpenAndClose, | |
546 base::Unretained(this))); | |
547 } | |
548 | |
549 void OpenAndStartAISOnAudioThread( | |
550 AudioInputStream::AudioInputCallback* source) { | |
551 RunOnAudioThread( | |
552 base::Bind(&AudioAndroidInputTest::OpenAndStart, | |
553 base::Unretained(this), | |
554 source)); | |
555 } | |
556 | |
557 void StopAndCloseAISOnAudioThread() { | |
558 RunOnAudioThread( | |
559 base::Bind(&AudioAndroidInputTest::StopAndClose, | |
560 base::Unretained(this))); | |
561 } | |
562 | |
531 void StartInputStreamCallbacks(const AudioParameters& params) { | 563 void StartInputStreamCallbacks(const AudioParameters& params) { |
532 double expected_time_between_callbacks_ms = | 564 double expected_time_between_callbacks_ms = |
533 ExpectedTimeBetweenCallbacks(params); | 565 ExpectedTimeBetweenCallbacks(params); |
534 const int num_callbacks = | 566 const int num_callbacks = |
535 (kCallbackTestTimeMs / expected_time_between_callbacks_ms); | 567 (kCallbackTestTimeMs / expected_time_between_callbacks_ms); |
536 AudioInputStream* stream = audio_manager()->MakeAudioInputStream( | 568 |
537 params, AudioManagerBase::kDefaultDeviceId); | 569 MakeAISOnAudioThread(params); |
538 EXPECT_TRUE(stream); | |
539 | 570 |
540 int count = 0; | 571 int count = 0; |
541 MockAudioInputCallback sink; | 572 MockAudioInputCallback sink; |
542 | 573 |
543 EXPECT_CALL(sink, | 574 EXPECT_CALL(sink, |
544 OnData(stream, NotNull(), params.GetBytesPerBuffer(), _, _)) | 575 OnData(ais(), NotNull(), params.GetBytesPerBuffer(), _, _)) |
545 .Times(AtLeast(num_callbacks)) | 576 .Times(AtLeast(num_callbacks)) |
546 .WillRepeatedly( | 577 .WillRepeatedly( |
547 CheckCountAndPostQuitTask(&count, num_callbacks, loop())); | 578 CheckCountAndPostQuitTask(&count, num_callbacks, loop())); |
548 EXPECT_CALL(sink, OnError(stream)).Times(0); | 579 EXPECT_CALL(sink, OnError(ais())).Times(0); |
549 | 580 |
550 EXPECT_TRUE(stream->Open()); | 581 OpenAndStartAISOnAudioThread(&sink); |
551 stream->Start(&sink); | 582 |
552 start_time_ = base::TimeTicks::Now(); | 583 start_time_ = base::TimeTicks::Now(); |
553 loop()->Run(); | 584 loop()->Run(); |
554 end_time_ = base::TimeTicks::Now(); | 585 end_time_ = base::TimeTicks::Now(); |
555 stream->Stop(); | 586 |
556 stream->Close(); | 587 StopAndCloseAISOnAudioThread(); |
557 | 588 |
558 double average_time_between_callbacks_ms = | 589 double average_time_between_callbacks_ms = |
559 AverageTimeBetweenCallbacks(num_callbacks); | 590 AverageTimeBetweenCallbacks(num_callbacks); |
560 VLOG(0) << "expected time between callbacks: " | 591 VLOG(0) << "expected time between callbacks: " |
561 << expected_time_between_callbacks_ms << " ms"; | 592 << expected_time_between_callbacks_ms << " ms"; |
562 VLOG(0) << "average time between callbacks: " | 593 VLOG(0) << "average time between callbacks: " |
563 << average_time_between_callbacks_ms << " ms"; | 594 << average_time_between_callbacks_ms << " ms"; |
564 EXPECT_GE(average_time_between_callbacks_ms, | 595 EXPECT_GE(average_time_between_callbacks_ms, |
565 0.70 * expected_time_between_callbacks_ms); | 596 0.70 * expected_time_between_callbacks_ms); |
566 EXPECT_LE(average_time_between_callbacks_ms, | 597 EXPECT_LE(average_time_between_callbacks_ms, |
567 1.30 * expected_time_between_callbacks_ms); | 598 1.30 * expected_time_between_callbacks_ms); |
568 } | 599 } |
569 | 600 |
601 void MakeInputStream(const AudioParameters& params) { | |
602 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); | |
603 audio_input_stream_ = audio_manager()->MakeAudioInputStream( | |
604 params, AudioManagerBase::kDefaultDeviceId); | |
605 EXPECT_TRUE(audio_input_stream_); | |
606 } | |
607 | |
608 void OpenAndStart(AudioInputStream::AudioInputCallback* source) { | |
609 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); | |
610 EXPECT_TRUE(ais()->Open()); | |
611 ais()->Start(source); | |
612 } | |
613 | |
614 void StopAndClose() { | |
615 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); | |
616 ais()->Stop(); | |
617 ais()->Close(); | |
618 } | |
619 | |
620 void OpenAndClose() { | |
621 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); | |
622 EXPECT_TRUE(ais()->Open()); | |
623 ais()->Close(); | |
624 } | |
625 | |
626 // Synchronously runs the provided callback/closure on the audio thread. | |
627 void RunOnAudioThread(const base::Closure& closure) { | |
628 if (!audio_manager()->GetTaskRunner()->BelongsToCurrentThread()) { | |
629 base::WaitableEvent event(false, false); | |
630 audio_manager()->GetTaskRunner()->PostTask( | |
631 FROM_HERE, | |
632 base::Bind(&AudioAndroidInputTest::RunOnAudioThreadImpl, | |
633 base::Unretained(this), | |
634 closure, | |
635 &event)); | |
636 event.Wait(); | |
637 } else { | |
638 closure.Run(); | |
639 } | |
640 } | |
641 | |
642 void RunOnAudioThreadImpl(const base::Closure& closure, | |
643 base::WaitableEvent* event) { | |
644 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); | |
645 closure.Run(); | |
646 event->Signal(); | |
647 } | |
570 | 648 |
571 private: | 649 private: |
650 AudioInputStream* audio_input_stream_; | |
572 DISALLOW_COPY_AND_ASSIGN(AudioAndroidInputTest); | 651 DISALLOW_COPY_AND_ASSIGN(AudioAndroidInputTest); |
573 }; | 652 }; |
574 | 653 |
575 // Get the default audio input parameters and log the result. | 654 // Get the default audio input parameters and log the result. |
576 TEST_P(AudioAndroidInputTest, GetDefaultInputStreamParameters) { | 655 TEST_P(AudioAndroidInputTest, GetDefaultInputStreamParameters) { |
577 // We don't go through AudioAndroidInputTest::GetInputStreamParameters() here | 656 // We don't go through AudioAndroidInputTest::GetInputStreamParameters() here |
578 // so that we can log the real (non-overridden) values of the effects. | 657 // so that we can log the real (non-overridden) values of the effects. |
579 AudioParameters params = audio_manager()->GetInputStreamParameters( | 658 AudioParameters params = audio_manager()->GetInputStreamParameters( |
580 AudioManagerBase::kDefaultDeviceId); | 659 AudioManagerBase::kDefaultDeviceId); |
581 EXPECT_TRUE(params.IsValid()); | 660 EXPECT_TRUE(params.IsValid()); |
(...skipping 10 matching lines...) Expand all Loading... | |
592 // Check if low-latency output is supported and log the result as output. | 671 // Check if low-latency output is supported and log the result as output. |
593 TEST_F(AudioAndroidOutputTest, IsAudioLowLatencySupported) { | 672 TEST_F(AudioAndroidOutputTest, IsAudioLowLatencySupported) { |
594 AudioManagerAndroid* manager = | 673 AudioManagerAndroid* manager = |
595 static_cast<AudioManagerAndroid*>(audio_manager()); | 674 static_cast<AudioManagerAndroid*>(audio_manager()); |
596 bool low_latency = manager->IsAudioLowLatencySupported(); | 675 bool low_latency = manager->IsAudioLowLatencySupported(); |
597 low_latency ? VLOG(0) << "Low latency output is supported" | 676 low_latency ? VLOG(0) << "Low latency output is supported" |
598 : VLOG(0) << "Low latency output is *not* supported"; | 677 : VLOG(0) << "Low latency output is *not* supported"; |
599 } | 678 } |
600 | 679 |
601 // Verify input device enumeration. | 680 // Verify input device enumeration. |
681 // GetAudioInputDeviceNames() is mainly called from a dedicated device thread | |
682 // in Chrome but perform the test on the main thread here. The call will be | |
683 // sent to the audio thread in AudioManagerAndroid::GetAudioInputDeviceNames(). | |
602 TEST_F(AudioAndroidInputTest, GetAudioInputDeviceNames) { | 684 TEST_F(AudioAndroidInputTest, GetAudioInputDeviceNames) { |
603 if (!audio_manager()->HasAudioInputDevices()) | 685 if (!audio_manager()->HasAudioInputDevices()) |
604 return; | 686 return; |
605 AudioDeviceNames devices; | 687 AudioDeviceNames devices; |
606 audio_manager()->GetAudioInputDeviceNames(&devices); | 688 audio_manager()->GetAudioInputDeviceNames(&devices); |
607 CheckDeviceNames(devices); | 689 CheckDeviceNames(devices); |
608 } | 690 } |
609 | 691 |
610 // Verify output device enumeration. | 692 // Verify output device enumeration. |
611 TEST_F(AudioAndroidOutputTest, GetAudioOutputDeviceNames) { | 693 TEST_F(AudioAndroidOutputTest, GetAudioOutputDeviceNames) { |
612 if (!audio_manager()->HasAudioOutputDevices()) | 694 if (!audio_manager()->HasAudioOutputDevices()) |
613 return; | 695 return; |
614 AudioDeviceNames devices; | 696 AudioDeviceNames devices; |
615 audio_manager()->GetAudioOutputDeviceNames(&devices); | 697 audio_manager()->GetAudioOutputDeviceNames(&devices); |
616 CheckDeviceNames(devices); | 698 CheckDeviceNames(devices); |
617 } | 699 } |
618 | 700 |
619 // Ensure that a default input stream can be created and closed. | 701 // Ensure that a default input stream can be created and closed. |
620 TEST_P(AudioAndroidInputTest, CreateAndCloseInputStream) { | 702 TEST_P(AudioAndroidInputTest, CreateAndCloseInputStream) { |
621 AudioParameters params = GetInputStreamParameters(); | 703 AudioParameters params = GetInputStreamParameters(); |
622 AudioInputStream* ais = audio_manager()->MakeAudioInputStream( | 704 MakeAISOnAudioThread(params); |
623 params, AudioManagerBase::kDefaultDeviceId); | 705 RunOnAudioThread( |
624 EXPECT_TRUE(ais); | 706 base::Bind(&AudioInputStream::Close, |
625 ais->Close(); | 707 base::Unretained(ais()))); |
626 } | 708 } |
627 | 709 |
628 // Ensure that a default output stream can be created and closed. | 710 // Ensure that a default output stream can be created and closed. |
629 // TODO(henrika): should we also verify that this API changes the audio mode | 711 // TODO(henrika): should we also verify that this API changes the audio mode |
630 // to communication mode, and calls RegisterHeadsetReceiver, the first time | 712 // to communication mode, and calls RegisterHeadsetReceiver, the first time |
631 // it is called? | 713 // it is called? |
632 TEST_F(AudioAndroidOutputTest, CreateAndCloseOutputStream) { | 714 TEST_F(AudioAndroidOutputTest, CreateAndCloseOutputStream) { |
633 AudioParameters params = GetDefaultOutputStreamParameters(); | 715 AudioParameters params = GetDefaultOutputStreamParameters(); |
634 AudioOutputStream* aos = audio_manager()->MakeAudioOutputStream( | 716 AudioOutputStream* aos = audio_manager()->MakeAudioOutputStream( |
635 params, std::string(), std::string()); | 717 params, std::string(), std::string()); |
636 EXPECT_TRUE(aos); | 718 EXPECT_TRUE(aos); |
637 aos->Close(); | 719 aos->Close(); |
638 } | 720 } |
639 | 721 |
640 // Ensure that a default input stream can be opened and closed. | 722 // Ensure that a default input stream can be opened and closed. |
641 TEST_P(AudioAndroidInputTest, OpenAndCloseInputStream) { | 723 TEST_P(AudioAndroidInputTest, OpenAndCloseInputStream) { |
642 AudioParameters params = GetInputStreamParameters(); | 724 AudioParameters params = GetInputStreamParameters(); |
643 AudioInputStream* ais = audio_manager()->MakeAudioInputStream( | 725 MakeAISOnAudioThread(params); |
644 params, AudioManagerBase::kDefaultDeviceId); | 726 OpenAndCloseAISOnAudioThread(); |
645 EXPECT_TRUE(ais); | |
646 EXPECT_TRUE(ais->Open()); | |
647 ais->Close(); | |
648 } | 727 } |
649 | 728 |
650 // Ensure that a default output stream can be opened and closed. | 729 // Ensure that a default output stream can be opened and closed. |
651 TEST_F(AudioAndroidOutputTest, OpenAndCloseOutputStream) { | 730 TEST_F(AudioAndroidOutputTest, OpenAndCloseOutputStream) { |
652 AudioParameters params = GetDefaultOutputStreamParameters(); | 731 AudioParameters params = GetDefaultOutputStreamParameters(); |
653 AudioOutputStream* aos = audio_manager()->MakeAudioOutputStream( | 732 AudioOutputStream* aos = audio_manager()->MakeAudioOutputStream( |
654 params, std::string(), std::string()); | 733 params, std::string(), std::string()); |
655 EXPECT_TRUE(aos); | 734 EXPECT_TRUE(aos); |
656 EXPECT_TRUE(aos->Open()); | 735 EXPECT_TRUE(aos->Open()); |
657 aos->Close(); | 736 aos->Close(); |
658 } | 737 } |
659 | 738 |
660 // Start input streaming using default input parameters and ensure that the | 739 // Start input streaming using default input parameters and ensure that the |
661 // callback sequence is sane. | 740 // callback sequence is sane. |
662 // Disabled per crbug/337867 | 741 TEST_P(AudioAndroidInputTest, StartInputStreamCallbacks) { |
663 TEST_P(AudioAndroidInputTest, DISABLED_StartInputStreamCallbacks) { | 742 AudioParameters native_params = GetInputStreamParameters(); |
664 AudioParameters params = GetInputStreamParameters(); | 743 StartInputStreamCallbacks(native_params); |
665 StartInputStreamCallbacks(params); | |
666 } | 744 } |
667 | 745 |
668 // Start input streaming using non default input parameters and ensure that the | 746 // Start input streaming using non default input parameters and ensure that the |
669 // callback sequence is sane. The only change we make in this test is to select | 747 // callback sequence is sane. The only change we make in this test is to select |
670 // a 10ms buffer size instead of the default size. | 748 // a 10ms buffer size instead of the default size. |
671 // TODO(henrika): possibly add support for more variations. | 749 TEST_P(AudioAndroidInputTest, StartInputStreamCallbacksNonDefaultParameters) { |
672 // Disabled per crbug/337867 | |
673 TEST_P(AudioAndroidInputTest, DISABLED_StartInputStreamCallbacksNonDefaultParame ters) { | |
674 AudioParameters native_params = GetInputStreamParameters(); | 750 AudioParameters native_params = GetInputStreamParameters(); |
675 AudioParameters params(native_params.format(), | 751 AudioParameters params(native_params.format(), |
676 native_params.channel_layout(), | 752 native_params.channel_layout(), |
677 native_params.input_channels(), | 753 native_params.input_channels(), |
678 native_params.sample_rate(), | 754 native_params.sample_rate(), |
679 native_params.bits_per_sample(), | 755 native_params.bits_per_sample(), |
680 native_params.sample_rate() / 100, | 756 native_params.sample_rate() / 100, |
681 native_params.effects()); | 757 native_params.effects()); |
682 StartInputStreamCallbacks(params); | 758 StartInputStreamCallbacks(params); |
683 } | 759 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
741 aos->Close(); | 817 aos->Close(); |
742 } | 818 } |
743 | 819 |
744 // Start input streaming and run it for ten seconds while recording to a | 820 // Start input streaming and run it for ten seconds while recording to a |
745 // local audio file. | 821 // local audio file. |
746 // NOTE: this test requires user interaction and is not designed to run as an | 822 // NOTE: this test requires user interaction and is not designed to run as an |
747 // automatized test on bots. | 823 // automatized test on bots. |
748 TEST_P(AudioAndroidInputTest, DISABLED_RunSimplexInputStreamWithFileAsSink) { | 824 TEST_P(AudioAndroidInputTest, DISABLED_RunSimplexInputStreamWithFileAsSink) { |
749 AudioParameters params = GetInputStreamParameters(); | 825 AudioParameters params = GetInputStreamParameters(); |
750 VLOG(1) << params; | 826 VLOG(1) << params; |
751 AudioInputStream* ais = audio_manager()->MakeAudioInputStream( | 827 MakeAISOnAudioThread(params); |
752 params, AudioManagerBase::kDefaultDeviceId); | |
753 EXPECT_TRUE(ais); | |
754 | 828 |
755 std::string file_name = base::StringPrintf("out_simplex_%d_%d_%d.pcm", | 829 std::string file_name = base::StringPrintf("out_simplex_%d_%d_%d.pcm", |
756 params.sample_rate(), | 830 params.sample_rate(), |
757 params.frames_per_buffer(), | 831 params.frames_per_buffer(), |
758 params.channels()); | 832 params.channels()); |
759 | 833 |
760 base::WaitableEvent event(false, false); | 834 base::WaitableEvent event(false, false); |
761 FileAudioSink sink(&event, params, file_name); | 835 FileAudioSink sink(&event, params, file_name); |
762 | 836 |
763 EXPECT_TRUE(ais->Open()); | 837 OpenAndStartAISOnAudioThread(&sink); |
764 ais->Start(&sink); | |
765 VLOG(0) << ">> Speak into the microphone to record audio..."; | 838 VLOG(0) << ">> Speak into the microphone to record audio..."; |
766 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_max_timeout())); | 839 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_max_timeout())); |
767 ais->Stop(); | 840 StopAndCloseAISOnAudioThread(); |
768 ais->Close(); | |
769 } | 841 } |
770 | 842 |
771 // Same test as RunSimplexInputStreamWithFileAsSink but this time output | 843 // Same test as RunSimplexInputStreamWithFileAsSink but this time output |
772 // streaming is active as well (reads zeros only). | 844 // streaming is active as well (reads zeros only). |
773 // NOTE: this test requires user interaction and is not designed to run as an | 845 // NOTE: this test requires user interaction and is not designed to run as an |
774 // automatized test on bots. | 846 // automatized test on bots. |
775 TEST_P(AudioAndroidInputTest, DISABLED_RunDuplexInputStreamWithFileAsSink) { | 847 TEST_P(AudioAndroidInputTest, DISABLED_RunDuplexInputStreamWithFileAsSink) { |
776 AudioParameters in_params = GetInputStreamParameters(); | 848 AudioParameters in_params = GetInputStreamParameters(); |
777 AudioInputStream* ais = audio_manager()->MakeAudioInputStream( | 849 AudioInputStream* ais = audio_manager()->MakeAudioInputStream( |
778 in_params, AudioManagerBase::kDefaultDeviceId); | 850 in_params, AudioManagerBase::kDefaultDeviceId); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
862 aos->Stop(); | 934 aos->Stop(); |
863 ais->Stop(); | 935 ais->Stop(); |
864 aos->Close(); | 936 aos->Close(); |
865 ais->Close(); | 937 ais->Close(); |
866 } | 938 } |
867 | 939 |
868 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, | 940 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, |
869 testing::ValuesIn(RunAudioRecordInputPathTests())); | 941 testing::ValuesIn(RunAudioRecordInputPathTests())); |
870 | 942 |
871 } // namespace media | 943 } // namespace media |
OLD | NEW |