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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 protected: | 584 protected: |
585 const AudioParameters& audio_input_parameters() { | 585 const AudioParameters& audio_input_parameters() { |
586 return audio_input_parameters_; | 586 return audio_input_parameters_; |
587 } | 587 } |
588 | 588 |
589 AudioParameters GetInputStreamParameters() { | 589 AudioParameters GetInputStreamParameters() { |
590 GetDefaultInputStreamParametersOnAudioThread(); | 590 GetDefaultInputStreamParametersOnAudioThread(); |
591 | 591 |
592 // Override the platform effects setting to use the AudioRecord or OpenSLES | 592 // Override the platform effects setting to use the AudioRecord or OpenSLES |
593 // path as requested. | 593 // path as requested. |
594 int effects = GetParam() ? AudioParameters::ECHO_CANCELLER : | 594 AudioParameters::PlatformEffectsMask effects = |
595 AudioParameters::NO_EFFECTS; | 595 GetParam() ? AudioParameters::ECHO_CANCELLER |
| 596 : AudioParameters::NO_EFFECTS; |
596 AudioParameters params(audio_input_parameters().format(), | 597 AudioParameters params(audio_input_parameters().format(), |
597 audio_input_parameters().channel_layout(), | 598 audio_input_parameters().channel_layout(), |
598 audio_input_parameters().sample_rate(), | 599 audio_input_parameters().sample_rate(), |
599 audio_input_parameters().bits_per_sample(), | 600 audio_input_parameters().bits_per_sample(), |
600 audio_input_parameters().frames_per_buffer(), | 601 audio_input_parameters().frames_per_buffer(), |
601 effects); | 602 std::vector<Point>(), effects); |
602 return params; | 603 return params; |
603 } | 604 } |
604 | 605 |
605 void GetDefaultInputStreamParametersOnAudioThread() { | 606 void GetDefaultInputStreamParametersOnAudioThread() { |
606 RunOnAudioThread( | 607 RunOnAudioThread( |
607 base::Bind(&AudioAndroidInputTest::GetDefaultInputStreamParameters, | 608 base::Bind(&AudioAndroidInputTest::GetDefaultInputStreamParameters, |
608 base::Unretained(this))); | 609 base::Unretained(this))); |
609 } | 610 } |
610 | 611 |
611 void MakeAudioInputStreamOnAudioThread(const AudioParameters& params) { | 612 void MakeAudioInputStreamOnAudioThread(const AudioParameters& params) { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 AudioParameters native_params = GetInputStreamParameters(); | 791 AudioParameters native_params = GetInputStreamParameters(); |
791 StartInputStreamCallbacks(native_params); | 792 StartInputStreamCallbacks(native_params); |
792 } | 793 } |
793 | 794 |
794 // Start input streaming using non default input parameters and ensure that the | 795 // Start input streaming using non default input parameters and ensure that the |
795 // callback sequence is sane. The only change we make in this test is to select | 796 // callback sequence is sane. The only change we make in this test is to select |
796 // a 10ms buffer size instead of the default size. | 797 // a 10ms buffer size instead of the default size. |
797 TEST_P(AudioAndroidInputTest, | 798 TEST_P(AudioAndroidInputTest, |
798 DISABLED_StartInputStreamCallbacksNonDefaultParameters) { | 799 DISABLED_StartInputStreamCallbacksNonDefaultParameters) { |
799 AudioParameters native_params = GetInputStreamParameters(); | 800 AudioParameters native_params = GetInputStreamParameters(); |
800 AudioParameters params(native_params.format(), | 801 AudioParameters params(native_params.format(), native_params.channel_layout(), |
801 native_params.channel_layout(), | |
802 native_params.sample_rate(), | 802 native_params.sample_rate(), |
803 native_params.bits_per_sample(), | 803 native_params.bits_per_sample(), |
804 native_params.sample_rate() / 100, | 804 native_params.sample_rate() / 100, |
805 native_params.effects()); | 805 std::vector<Point>(), native_params.effects()); |
806 StartInputStreamCallbacks(params); | 806 StartInputStreamCallbacks(params); |
807 } | 807 } |
808 | 808 |
809 // Start output streaming using default output parameters and ensure that the | 809 // Start output streaming using default output parameters and ensure that the |
810 // callback sequence is sane. | 810 // callback sequence is sane. |
811 TEST_F(AudioAndroidOutputTest, StartOutputStreamCallbacks) { | 811 TEST_F(AudioAndroidOutputTest, StartOutputStreamCallbacks) { |
812 GetDefaultOutputStreamParametersOnAudioThread(); | 812 GetDefaultOutputStreamParametersOnAudioThread(); |
813 StartOutputStreamCallbacks(audio_output_parameters()); | 813 StartOutputStreamCallbacks(audio_output_parameters()); |
814 } | 814 } |
815 | 815 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 // automatized test on bots. | 926 // automatized test on bots. |
927 TEST_P(AudioAndroidInputTest, | 927 TEST_P(AudioAndroidInputTest, |
928 DISABLED_RunSymmetricInputAndOutputStreamsInFullDuplex) { | 928 DISABLED_RunSymmetricInputAndOutputStreamsInFullDuplex) { |
929 // Get native audio parameters for the input side. | 929 // Get native audio parameters for the input side. |
930 AudioParameters default_input_params = GetInputStreamParameters(); | 930 AudioParameters default_input_params = GetInputStreamParameters(); |
931 | 931 |
932 // Modify the parameters so that both input and output can use the same | 932 // Modify the parameters so that both input and output can use the same |
933 // parameters by selecting 10ms as buffer size. This will also ensure that | 933 // parameters by selecting 10ms as buffer size. This will also ensure that |
934 // the output stream will be a mono stream since mono is default for input | 934 // the output stream will be a mono stream since mono is default for input |
935 // audio on Android. | 935 // audio on Android. |
936 AudioParameters io_params(default_input_params.format(), | 936 AudioParameters io_params( |
937 default_input_params.channel_layout(), | 937 default_input_params.format(), |
938 ChannelLayoutToChannelCount( | 938 ChannelLayoutToChannelCount(default_input_params.channel_layout()), |
939 default_input_params.channel_layout()), | 939 default_input_params.channel_layout(), default_input_params.sample_rate(), |
940 default_input_params.sample_rate(), | 940 default_input_params.bits_per_sample(), |
941 default_input_params.bits_per_sample(), | 941 default_input_params.sample_rate() / 100, std::vector<Point>(), |
942 default_input_params.sample_rate() / 100, | 942 default_input_params.effects()); |
943 default_input_params.effects()); | |
944 DVLOG(1) << io_params; | 943 DVLOG(1) << io_params; |
945 | 944 |
946 // Create input and output streams using the common audio parameters. | 945 // Create input and output streams using the common audio parameters. |
947 MakeAudioInputStreamOnAudioThread(io_params); | 946 MakeAudioInputStreamOnAudioThread(io_params); |
948 MakeAudioOutputStreamOnAudioThread(io_params); | 947 MakeAudioOutputStreamOnAudioThread(io_params); |
949 | 948 |
950 FullDuplexAudioSinkSource full_duplex(io_params); | 949 FullDuplexAudioSinkSource full_duplex(io_params); |
951 | 950 |
952 // Start a full duplex audio session and print out estimates of the extra | 951 // Start a full duplex audio session and print out estimates of the extra |
953 // delay we should expect from the FIFO. If real-time delay measurements are | 952 // delay we should expect from the FIFO. If real-time delay measurements are |
954 // performed, the result should be reduced by this extra delay since it is | 953 // performed, the result should be reduced by this extra delay since it is |
955 // something that has been added by the test. | 954 // something that has been added by the test. |
956 OpenAndStartAudioInputStreamOnAudioThread(&full_duplex); | 955 OpenAndStartAudioInputStreamOnAudioThread(&full_duplex); |
957 OpenAndStartAudioOutputStreamOnAudioThread(&full_duplex); | 956 OpenAndStartAudioOutputStreamOnAudioThread(&full_duplex); |
958 DVLOG(1) << "HINT: an estimate of the extra FIFO delay will be updated " | 957 DVLOG(1) << "HINT: an estimate of the extra FIFO delay will be updated " |
959 << "once per second during this test."; | 958 << "once per second during this test."; |
960 DVLOG(0) << ">> Speak into the mic and listen to the audio in loopback..."; | 959 DVLOG(0) << ">> Speak into the mic and listen to the audio in loopback..."; |
961 fflush(stdout); | 960 fflush(stdout); |
962 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); | 961 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); |
963 printf("\n"); | 962 printf("\n"); |
964 StopAndCloseAudioOutputStreamOnAudioThread(); | 963 StopAndCloseAudioOutputStreamOnAudioThread(); |
965 StopAndCloseAudioInputStreamOnAudioThread(); | 964 StopAndCloseAudioInputStreamOnAudioThread(); |
966 } | 965 } |
967 | 966 |
968 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, | 967 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, |
969 testing::ValuesIn(RunAudioRecordInputPathTests())); | 968 testing::ValuesIn(RunAudioRecordInputPathTests())); |
970 | 969 |
971 } // namespace media | 970 } // namespace media |
OLD | NEW |