| 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 } |
| 418 |
| 419 virtual ~AudioAndroidOutputTest() { |
| 420 } |
| 414 | 421 |
| 415 protected: | 422 protected: |
| 416 virtual void SetUp() { | |
| 417 audio_manager_.reset(AudioManager::CreateForTesting()); | |
| 418 loop_.reset(new base::MessageLoopForUI()); | |
| 419 } | |
| 420 | |
| 421 virtual void TearDown() {} | |
| 422 | |
| 423 AudioManager* audio_manager() { return audio_manager_.get(); } | 423 AudioManager* audio_manager() { return audio_manager_.get(); } |
| 424 base::MessageLoopForUI* loop() { return loop_.get(); } | 424 base::MessageLoopForUI* loop() { return loop_.get(); } |
| 425 | 425 |
| 426 AudioParameters GetDefaultOutputStreamParameters() { | 426 AudioParameters GetDefaultOutputStreamParameters() { |
| 427 return audio_manager()->GetDefaultOutputStreamParameters(); | 427 return audio_manager()->GetDefaultOutputStreamParameters(); |
| 428 } | 428 } |
| 429 | 429 |
| 430 double AverageTimeBetweenCallbacks(int num_callbacks) const { | 430 double AverageTimeBetweenCallbacks(int num_callbacks) const { |
| 431 return ((end_time_ - start_time_) / static_cast<double>(num_callbacks - 1)) | 431 return ((end_time_ - start_time_) / static_cast<double>(num_callbacks - 1)) |
| 432 .InMillisecondsF(); | 432 .InMillisecondsF(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 tests.push_back(true); | 490 tests.push_back(true); |
| 491 return tests; | 491 return tests; |
| 492 } | 492 } |
| 493 | 493 |
| 494 // Test fixture class for tests which exercise the input path, or both input and | 494 // 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 | 495 // output paths. It is value-parameterized to test against both the Java |
| 496 // AudioRecord (when true) and native OpenSLES (when false) input paths. | 496 // AudioRecord (when true) and native OpenSLES (when false) input paths. |
| 497 class AudioAndroidInputTest : public AudioAndroidOutputTest, | 497 class AudioAndroidInputTest : public AudioAndroidOutputTest, |
| 498 public testing::WithParamInterface<bool> { | 498 public testing::WithParamInterface<bool> { |
| 499 public: | 499 public: |
| 500 AudioAndroidInputTest() {} | 500 AudioAndroidInputTest() : audio_input_stream_(NULL) {} |
| 501 | 501 |
| 502 protected: | 502 protected: |
| 503 AudioInputStream* ais() { return audio_input_stream_; } |
| 504 |
| 503 AudioParameters GetInputStreamParameters() { | 505 AudioParameters GetInputStreamParameters() { |
| 504 AudioParameters input_params = audio_manager()->GetInputStreamParameters( | 506 AudioParameters input_params = audio_manager()->GetInputStreamParameters( |
| 505 AudioManagerBase::kDefaultDeviceId); | 507 AudioManagerBase::kDefaultDeviceId); |
| 506 // Override the platform effects setting to use the AudioRecord or OpenSLES | 508 // Override the platform effects setting to use the AudioRecord or OpenSLES |
| 507 // path as requested. | 509 // path as requested. |
| 508 int effects = GetParam() ? AudioParameters::ECHO_CANCELLER : | 510 int effects = GetParam() ? AudioParameters::ECHO_CANCELLER : |
| 509 AudioParameters::NO_EFFECTS; | 511 AudioParameters::NO_EFFECTS; |
| 510 AudioParameters params(input_params.format(), | 512 AudioParameters params(input_params.format(), |
| 511 input_params.channel_layout(), | 513 input_params.channel_layout(), |
| 512 input_params.input_channels(), | 514 input_params.input_channels(), |
| 513 input_params.sample_rate(), | 515 input_params.sample_rate(), |
| 514 input_params.bits_per_sample(), | 516 input_params.bits_per_sample(), |
| 515 input_params.frames_per_buffer(), | 517 input_params.frames_per_buffer(), |
| 516 effects); | 518 effects); |
| 517 return params; | 519 return params; |
| 518 } | 520 } |
| 519 | 521 |
| 522 void MakeAISOnAudioThread(const AudioParameters& params) { |
| 523 RunOnAudioThread( |
| 524 base::Bind(&AudioAndroidInputTest::MakeInputStream, |
| 525 base::Unretained(this), |
| 526 params)); |
| 527 } |
| 528 |
| 529 void OpenAndCloseAISOnAudioThread() { |
| 530 RunOnAudioThread( |
| 531 base::Bind(&AudioAndroidInputTest::OpenAndClose, |
| 532 base::Unretained(this))); |
| 533 } |
| 534 |
| 535 void OpenAndStartAISOnAudioThread( |
| 536 AudioInputStream::AudioInputCallback* source) { |
| 537 RunOnAudioThread( |
| 538 base::Bind(&AudioAndroidInputTest::OpenAndStart, |
| 539 base::Unretained(this), |
| 540 source)); |
| 541 } |
| 542 |
| 543 void StopAndCloseAISOnAudioThread() { |
| 544 RunOnAudioThread( |
| 545 base::Bind(&AudioAndroidInputTest::StopAndClose, |
| 546 base::Unretained(this))); |
| 547 } |
| 548 |
| 520 void StartInputStreamCallbacks(const AudioParameters& params) { | 549 void StartInputStreamCallbacks(const AudioParameters& params) { |
| 521 double expected_time_between_callbacks_ms = | 550 double expected_time_between_callbacks_ms = |
| 522 ExpectedTimeBetweenCallbacks(params); | 551 ExpectedTimeBetweenCallbacks(params); |
| 523 const int num_callbacks = | 552 const int num_callbacks = |
| 524 (kCallbackTestTimeMs / expected_time_between_callbacks_ms); | 553 (kCallbackTestTimeMs / expected_time_between_callbacks_ms); |
| 525 AudioInputStream* stream = audio_manager()->MakeAudioInputStream( | 554 |
| 526 params, AudioManagerBase::kDefaultDeviceId); | 555 MakeAISOnAudioThread(params); |
| 527 EXPECT_TRUE(stream); | |
| 528 | 556 |
| 529 int count = 0; | 557 int count = 0; |
| 530 MockAudioInputCallback sink; | 558 MockAudioInputCallback sink; |
| 531 | 559 |
| 532 EXPECT_CALL(sink, | 560 EXPECT_CALL(sink, |
| 533 OnData(stream, NotNull(), params.GetBytesPerBuffer(), _, _)) | 561 OnData(ais(), NotNull(), params.GetBytesPerBuffer(), _, _)) |
| 534 .Times(AtLeast(num_callbacks)) | 562 .Times(AtLeast(num_callbacks)) |
| 535 .WillRepeatedly( | 563 .WillRepeatedly( |
| 536 CheckCountAndPostQuitTask(&count, num_callbacks, loop())); | 564 CheckCountAndPostQuitTask(&count, num_callbacks, loop())); |
| 537 EXPECT_CALL(sink, OnError(stream)).Times(0); | 565 EXPECT_CALL(sink, OnError(ais())).Times(0); |
| 538 | 566 |
| 539 EXPECT_TRUE(stream->Open()); | 567 OpenAndStartAISOnAudioThread(&sink); |
| 540 stream->Start(&sink); | 568 |
| 541 start_time_ = base::TimeTicks::Now(); | 569 start_time_ = base::TimeTicks::Now(); |
| 542 loop()->Run(); | 570 loop()->Run(); |
| 543 end_time_ = base::TimeTicks::Now(); | 571 end_time_ = base::TimeTicks::Now(); |
| 544 stream->Stop(); | 572 |
| 545 stream->Close(); | 573 StopAndCloseAISOnAudioThread(); |
| 546 | 574 |
| 547 double average_time_between_callbacks_ms = | 575 double average_time_between_callbacks_ms = |
| 548 AverageTimeBetweenCallbacks(num_callbacks); | 576 AverageTimeBetweenCallbacks(num_callbacks); |
| 549 VLOG(0) << "expected time between callbacks: " | 577 VLOG(0) << "expected time between callbacks: " |
| 550 << expected_time_between_callbacks_ms << " ms"; | 578 << expected_time_between_callbacks_ms << " ms"; |
| 551 VLOG(0) << "average time between callbacks: " | 579 VLOG(0) << "average time between callbacks: " |
| 552 << average_time_between_callbacks_ms << " ms"; | 580 << average_time_between_callbacks_ms << " ms"; |
| 553 EXPECT_GE(average_time_between_callbacks_ms, | 581 EXPECT_GE(average_time_between_callbacks_ms, |
| 554 0.70 * expected_time_between_callbacks_ms); | 582 0.70 * expected_time_between_callbacks_ms); |
| 555 EXPECT_LE(average_time_between_callbacks_ms, | 583 EXPECT_LE(average_time_between_callbacks_ms, |
| 556 1.30 * expected_time_between_callbacks_ms); | 584 1.30 * expected_time_between_callbacks_ms); |
| 557 } | 585 } |
| 558 | 586 |
| 587 void MakeInputStream(const AudioParameters& params) { |
| 588 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); |
| 589 audio_input_stream_ = audio_manager()->MakeAudioInputStream( |
| 590 params, AudioManagerBase::kDefaultDeviceId); |
| 591 EXPECT_TRUE(audio_input_stream_); |
| 592 } |
| 593 |
| 594 void OpenAndStart(AudioInputStream::AudioInputCallback* source) { |
| 595 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); |
| 596 EXPECT_TRUE(ais()->Open()); |
| 597 ais()->Start(source); |
| 598 } |
| 599 |
| 600 void StopAndClose() { |
| 601 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); |
| 602 ais()->Stop(); |
| 603 ais()->Close(); |
| 604 } |
| 605 |
| 606 void OpenAndClose() { |
| 607 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); |
| 608 EXPECT_TRUE(ais()->Open()); |
| 609 ais()->Close(); |
| 610 } |
| 611 |
| 612 // Synchronously runs the provided callback/closure on the audio thread. |
| 613 void RunOnAudioThread(const base::Closure& closure) { |
| 614 if (!audio_manager()->GetTaskRunner()->BelongsToCurrentThread()) { |
| 615 base::WaitableEvent event(false, false); |
| 616 audio_manager()->GetTaskRunner()->PostTask( |
| 617 FROM_HERE, |
| 618 base::Bind(&AudioAndroidInputTest::RunOnAudioThreadImpl, |
| 619 base::Unretained(this), |
| 620 closure, |
| 621 &event)); |
| 622 event.Wait(); |
| 623 } else { |
| 624 closure.Run(); |
| 625 } |
| 626 } |
| 627 |
| 628 void RunOnAudioThreadImpl(const base::Closure& closure, |
| 629 base::WaitableEvent* event) { |
| 630 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); |
| 631 closure.Run(); |
| 632 event->Signal(); |
| 633 } |
| 559 | 634 |
| 560 private: | 635 private: |
| 636 AudioInputStream* audio_input_stream_; |
| 561 DISALLOW_COPY_AND_ASSIGN(AudioAndroidInputTest); | 637 DISALLOW_COPY_AND_ASSIGN(AudioAndroidInputTest); |
| 562 }; | 638 }; |
| 563 | 639 |
| 564 // Get the default audio input parameters and log the result. | 640 // Get the default audio input parameters and log the result. |
| 565 TEST_P(AudioAndroidInputTest, GetDefaultInputStreamParameters) { | 641 TEST_P(AudioAndroidInputTest, GetDefaultInputStreamParameters) { |
| 566 // We don't go through AudioAndroidInputTest::GetInputStreamParameters() here | 642 // We don't go through AudioAndroidInputTest::GetInputStreamParameters() here |
| 567 // so that we can log the real (non-overridden) values of the effects. | 643 // so that we can log the real (non-overridden) values of the effects. |
| 568 AudioParameters params = audio_manager()->GetInputStreamParameters( | 644 AudioParameters params = audio_manager()->GetInputStreamParameters( |
| 569 AudioManagerBase::kDefaultDeviceId); | 645 AudioManagerBase::kDefaultDeviceId); |
| 570 EXPECT_TRUE(params.IsValid()); | 646 EXPECT_TRUE(params.IsValid()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 581 // Check if low-latency output is supported and log the result as output. | 657 // Check if low-latency output is supported and log the result as output. |
| 582 TEST_F(AudioAndroidOutputTest, IsAudioLowLatencySupported) { | 658 TEST_F(AudioAndroidOutputTest, IsAudioLowLatencySupported) { |
| 583 AudioManagerAndroid* manager = | 659 AudioManagerAndroid* manager = |
| 584 static_cast<AudioManagerAndroid*>(audio_manager()); | 660 static_cast<AudioManagerAndroid*>(audio_manager()); |
| 585 bool low_latency = manager->IsAudioLowLatencySupported(); | 661 bool low_latency = manager->IsAudioLowLatencySupported(); |
| 586 low_latency ? VLOG(0) << "Low latency output is supported" | 662 low_latency ? VLOG(0) << "Low latency output is supported" |
| 587 : VLOG(0) << "Low latency output is *not* supported"; | 663 : VLOG(0) << "Low latency output is *not* supported"; |
| 588 } | 664 } |
| 589 | 665 |
| 590 // Verify input device enumeration. | 666 // Verify input device enumeration. |
| 667 // GetAudioInputDeviceNames() is mainly called from a dedicated device thread |
| 668 // in Chrome but perform the test on the main thread here. The call will be |
| 669 // sent to the audio thread in AudioManagerAndroid::GetAudioInputDeviceNames(). |
| 591 TEST_F(AudioAndroidInputTest, GetAudioInputDeviceNames) { | 670 TEST_F(AudioAndroidInputTest, GetAudioInputDeviceNames) { |
| 592 if (!audio_manager()->HasAudioInputDevices()) | 671 if (!audio_manager()->HasAudioInputDevices()) |
| 593 return; | 672 return; |
| 594 AudioDeviceNames devices; | 673 AudioDeviceNames devices; |
| 595 audio_manager()->GetAudioInputDeviceNames(&devices); | 674 audio_manager()->GetAudioInputDeviceNames(&devices); |
| 596 CheckDeviceNames(devices); | 675 CheckDeviceNames(devices); |
| 597 } | 676 } |
| 598 | 677 |
| 599 // Verify output device enumeration. | 678 // Verify output device enumeration. |
| 600 TEST_F(AudioAndroidOutputTest, GetAudioOutputDeviceNames) { | 679 TEST_F(AudioAndroidOutputTest, GetAudioOutputDeviceNames) { |
| 601 if (!audio_manager()->HasAudioOutputDevices()) | 680 if (!audio_manager()->HasAudioOutputDevices()) |
| 602 return; | 681 return; |
| 603 AudioDeviceNames devices; | 682 AudioDeviceNames devices; |
| 604 audio_manager()->GetAudioOutputDeviceNames(&devices); | 683 audio_manager()->GetAudioOutputDeviceNames(&devices); |
| 605 CheckDeviceNames(devices); | 684 CheckDeviceNames(devices); |
| 606 } | 685 } |
| 607 | 686 |
| 608 // Ensure that a default input stream can be created and closed. | 687 // Ensure that a default input stream can be created and closed. |
| 609 TEST_P(AudioAndroidInputTest, CreateAndCloseInputStream) { | 688 TEST_P(AudioAndroidInputTest, CreateAndCloseInputStream) { |
| 610 AudioParameters params = GetInputStreamParameters(); | 689 AudioParameters params = GetInputStreamParameters(); |
| 611 AudioInputStream* ais = audio_manager()->MakeAudioInputStream( | 690 MakeAISOnAudioThread(params); |
| 612 params, AudioManagerBase::kDefaultDeviceId); | 691 RunOnAudioThread( |
| 613 EXPECT_TRUE(ais); | 692 base::Bind(&AudioInputStream::Close, |
| 614 ais->Close(); | 693 base::Unretained(ais()))); |
| 615 } | 694 } |
| 616 | 695 |
| 617 // Ensure that a default output stream can be created and closed. | 696 // 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 | 697 // TODO(henrika): should we also verify that this API changes the audio mode |
| 619 // to communication mode, and calls RegisterHeadsetReceiver, the first time | 698 // to communication mode, and calls RegisterHeadsetReceiver, the first time |
| 620 // it is called? | 699 // it is called? |
| 621 TEST_F(AudioAndroidOutputTest, CreateAndCloseOutputStream) { | 700 TEST_F(AudioAndroidOutputTest, CreateAndCloseOutputStream) { |
| 622 AudioParameters params = GetDefaultOutputStreamParameters(); | 701 AudioParameters params = GetDefaultOutputStreamParameters(); |
| 623 AudioOutputStream* aos = audio_manager()->MakeAudioOutputStream( | 702 AudioOutputStream* aos = audio_manager()->MakeAudioOutputStream( |
| 624 params, std::string(), std::string()); | 703 params, std::string(), std::string()); |
| 625 EXPECT_TRUE(aos); | 704 EXPECT_TRUE(aos); |
| 626 aos->Close(); | 705 aos->Close(); |
| 627 } | 706 } |
| 628 | 707 |
| 629 // Ensure that a default input stream can be opened and closed. | 708 // Ensure that a default input stream can be opened and closed. |
| 630 TEST_P(AudioAndroidInputTest, OpenAndCloseInputStream) { | 709 TEST_P(AudioAndroidInputTest, OpenAndCloseInputStream) { |
| 631 AudioParameters params = GetInputStreamParameters(); | 710 AudioParameters params = GetInputStreamParameters(); |
| 632 AudioInputStream* ais = audio_manager()->MakeAudioInputStream( | 711 MakeAISOnAudioThread(params); |
| 633 params, AudioManagerBase::kDefaultDeviceId); | 712 OpenAndCloseAISOnAudioThread(); |
| 634 EXPECT_TRUE(ais); | |
| 635 EXPECT_TRUE(ais->Open()); | |
| 636 ais->Close(); | |
| 637 } | 713 } |
| 638 | 714 |
| 639 // Ensure that a default output stream can be opened and closed. | 715 // Ensure that a default output stream can be opened and closed. |
| 640 TEST_F(AudioAndroidOutputTest, OpenAndCloseOutputStream) { | 716 TEST_F(AudioAndroidOutputTest, OpenAndCloseOutputStream) { |
| 641 AudioParameters params = GetDefaultOutputStreamParameters(); | 717 AudioParameters params = GetDefaultOutputStreamParameters(); |
| 642 AudioOutputStream* aos = audio_manager()->MakeAudioOutputStream( | 718 AudioOutputStream* aos = audio_manager()->MakeAudioOutputStream( |
| 643 params, std::string(), std::string()); | 719 params, std::string(), std::string()); |
| 644 EXPECT_TRUE(aos); | 720 EXPECT_TRUE(aos); |
| 645 EXPECT_TRUE(aos->Open()); | 721 EXPECT_TRUE(aos->Open()); |
| 646 aos->Close(); | 722 aos->Close(); |
| 647 } | 723 } |
| 648 | 724 |
| 649 // Start input streaming using default input parameters and ensure that the | 725 // Start input streaming using default input parameters and ensure that the |
| 650 // callback sequence is sane. | 726 // callback sequence is sane. |
| 651 // Disabled per crbug/337867 | 727 TEST_P(AudioAndroidInputTest, StartInputStreamCallbacks) { |
| 652 TEST_P(AudioAndroidInputTest, DISABLED_StartInputStreamCallbacks) { | 728 AudioParameters native_params = GetInputStreamParameters(); |
| 653 AudioParameters params = GetInputStreamParameters(); | 729 StartInputStreamCallbacks(native_params); |
| 654 StartInputStreamCallbacks(params); | |
| 655 } | 730 } |
| 656 | 731 |
| 657 // Start input streaming using non default input parameters and ensure that the | 732 // 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 | 733 // 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. | 734 // a 10ms buffer size instead of the default size. |
| 660 // TODO(henrika): possibly add support for more variations. | 735 TEST_P(AudioAndroidInputTest, StartInputStreamCallbacksNonDefaultParameters) { |
| 661 // Disabled per crbug/337867 | |
| 662 TEST_P(AudioAndroidInputTest, DISABLED_StartInputStreamCallbacksNonDefaultParame
ters) { | |
| 663 AudioParameters native_params = GetInputStreamParameters(); | 736 AudioParameters native_params = GetInputStreamParameters(); |
| 664 AudioParameters params(native_params.format(), | 737 AudioParameters params(native_params.format(), |
| 665 native_params.channel_layout(), | 738 native_params.channel_layout(), |
| 666 native_params.input_channels(), | 739 native_params.input_channels(), |
| 667 native_params.sample_rate(), | 740 native_params.sample_rate(), |
| 668 native_params.bits_per_sample(), | 741 native_params.bits_per_sample(), |
| 669 native_params.sample_rate() / 100, | 742 native_params.sample_rate() / 100, |
| 670 native_params.effects()); | 743 native_params.effects()); |
| 671 StartInputStreamCallbacks(params); | 744 StartInputStreamCallbacks(params); |
| 672 } | 745 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 aos->Close(); | 803 aos->Close(); |
| 731 } | 804 } |
| 732 | 805 |
| 733 // Start input streaming and run it for ten seconds while recording to a | 806 // Start input streaming and run it for ten seconds while recording to a |
| 734 // local audio file. | 807 // local audio file. |
| 735 // NOTE: this test requires user interaction and is not designed to run as an | 808 // NOTE: this test requires user interaction and is not designed to run as an |
| 736 // automatized test on bots. | 809 // automatized test on bots. |
| 737 TEST_P(AudioAndroidInputTest, DISABLED_RunSimplexInputStreamWithFileAsSink) { | 810 TEST_P(AudioAndroidInputTest, DISABLED_RunSimplexInputStreamWithFileAsSink) { |
| 738 AudioParameters params = GetInputStreamParameters(); | 811 AudioParameters params = GetInputStreamParameters(); |
| 739 VLOG(1) << params; | 812 VLOG(1) << params; |
| 740 AudioInputStream* ais = audio_manager()->MakeAudioInputStream( | 813 MakeAISOnAudioThread(params); |
| 741 params, AudioManagerBase::kDefaultDeviceId); | |
| 742 EXPECT_TRUE(ais); | |
| 743 | 814 |
| 744 std::string file_name = base::StringPrintf("out_simplex_%d_%d_%d.pcm", | 815 std::string file_name = base::StringPrintf("out_simplex_%d_%d_%d.pcm", |
| 745 params.sample_rate(), | 816 params.sample_rate(), |
| 746 params.frames_per_buffer(), | 817 params.frames_per_buffer(), |
| 747 params.channels()); | 818 params.channels()); |
| 748 | 819 |
| 749 base::WaitableEvent event(false, false); | 820 base::WaitableEvent event(false, false); |
| 750 FileAudioSink sink(&event, params, file_name); | 821 FileAudioSink sink(&event, params, file_name); |
| 751 | 822 |
| 752 EXPECT_TRUE(ais->Open()); | 823 OpenAndStartAISOnAudioThread(&sink); |
| 753 ais->Start(&sink); | |
| 754 VLOG(0) << ">> Speak into the microphone to record audio..."; | 824 VLOG(0) << ">> Speak into the microphone to record audio..."; |
| 755 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_max_timeout())); | 825 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_max_timeout())); |
| 756 ais->Stop(); | 826 StopAndCloseAISOnAudioThread(); |
| 757 ais->Close(); | |
| 758 } | 827 } |
| 759 | 828 |
| 760 // Same test as RunSimplexInputStreamWithFileAsSink but this time output | 829 // Same test as RunSimplexInputStreamWithFileAsSink but this time output |
| 761 // streaming is active as well (reads zeros only). | 830 // streaming is active as well (reads zeros only). |
| 762 // NOTE: this test requires user interaction and is not designed to run as an | 831 // NOTE: this test requires user interaction and is not designed to run as an |
| 763 // automatized test on bots. | 832 // automatized test on bots. |
| 764 TEST_P(AudioAndroidInputTest, DISABLED_RunDuplexInputStreamWithFileAsSink) { | 833 TEST_P(AudioAndroidInputTest, DISABLED_RunDuplexInputStreamWithFileAsSink) { |
| 765 AudioParameters in_params = GetInputStreamParameters(); | 834 AudioParameters in_params = GetInputStreamParameters(); |
| 766 AudioInputStream* ais = audio_manager()->MakeAudioInputStream( | 835 AudioInputStream* ais = audio_manager()->MakeAudioInputStream( |
| 767 in_params, AudioManagerBase::kDefaultDeviceId); | 836 in_params, AudioManagerBase::kDefaultDeviceId); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 aos->Stop(); | 920 aos->Stop(); |
| 852 ais->Stop(); | 921 ais->Stop(); |
| 853 aos->Close(); | 922 aos->Close(); |
| 854 ais->Close(); | 923 ais->Close(); |
| 855 } | 924 } |
| 856 | 925 |
| 857 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, | 926 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, |
| 858 testing::ValuesIn(RunAudioRecordInputPathTests())); | 927 testing::ValuesIn(RunAudioRecordInputPathTests())); |
| 859 | 928 |
| 860 } // namespace media | 929 } // namespace media |
| OLD | NEW |