| 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 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 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(), |
| 801 native_params.channel_layout(), | 802 native_params.channel_layout(), |
| 802 native_params.sample_rate(), | 803 native_params.sample_rate(), |
| 803 native_params.bits_per_sample(), | 804 native_params.bits_per_sample(), |
| 804 native_params.sample_rate() / 100, | 805 native_params.sample_rate() / 100, |
| 806 "", |
| 805 native_params.effects()); | 807 native_params.effects()); |
| 806 StartInputStreamCallbacks(params); | 808 StartInputStreamCallbacks(params); |
| 807 } | 809 } |
| 808 | 810 |
| 809 // Start output streaming using default output parameters and ensure that the | 811 // Start output streaming using default output parameters and ensure that the |
| 810 // callback sequence is sane. | 812 // callback sequence is sane. |
| 811 TEST_F(AudioAndroidOutputTest, StartOutputStreamCallbacks) { | 813 TEST_F(AudioAndroidOutputTest, StartOutputStreamCallbacks) { |
| 812 GetDefaultOutputStreamParametersOnAudioThread(); | 814 GetDefaultOutputStreamParametersOnAudioThread(); |
| 813 StartOutputStreamCallbacks(audio_output_parameters()); | 815 StartOutputStreamCallbacks(audio_output_parameters()); |
| 814 } | 816 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 TEST_P(AudioAndroidInputTest, | 929 TEST_P(AudioAndroidInputTest, |
| 928 DISABLED_RunSymmetricInputAndOutputStreamsInFullDuplex) { | 930 DISABLED_RunSymmetricInputAndOutputStreamsInFullDuplex) { |
| 929 // Get native audio parameters for the input side. | 931 // Get native audio parameters for the input side. |
| 930 AudioParameters default_input_params = GetInputStreamParameters(); | 932 AudioParameters default_input_params = GetInputStreamParameters(); |
| 931 | 933 |
| 932 // Modify the parameters so that both input and output can use the same | 934 // 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 | 935 // 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 | 936 // the output stream will be a mono stream since mono is default for input |
| 935 // audio on Android. | 937 // audio on Android. |
| 936 AudioParameters io_params(default_input_params.format(), | 938 AudioParameters io_params(default_input_params.format(), |
| 937 default_input_params.channel_layout(), | |
| 938 ChannelLayoutToChannelCount( | 939 ChannelLayoutToChannelCount( |
| 939 default_input_params.channel_layout()), | 940 default_input_params.channel_layout()), |
| 941 default_input_params.channel_layout(), |
| 940 default_input_params.sample_rate(), | 942 default_input_params.sample_rate(), |
| 941 default_input_params.bits_per_sample(), | 943 default_input_params.bits_per_sample(), |
| 942 default_input_params.sample_rate() / 100, | 944 default_input_params.sample_rate() / 100, |
| 945 "", |
| 943 default_input_params.effects()); | 946 default_input_params.effects()); |
| 944 DVLOG(1) << io_params; | 947 DVLOG(1) << io_params; |
| 945 | 948 |
| 946 // Create input and output streams using the common audio parameters. | 949 // Create input and output streams using the common audio parameters. |
| 947 MakeAudioInputStreamOnAudioThread(io_params); | 950 MakeAudioInputStreamOnAudioThread(io_params); |
| 948 MakeAudioOutputStreamOnAudioThread(io_params); | 951 MakeAudioOutputStreamOnAudioThread(io_params); |
| 949 | 952 |
| 950 FullDuplexAudioSinkSource full_duplex(io_params); | 953 FullDuplexAudioSinkSource full_duplex(io_params); |
| 951 | 954 |
| 952 // Start a full duplex audio session and print out estimates of the extra | 955 // 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 | 956 // 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 | 957 // performed, the result should be reduced by this extra delay since it is |
| 955 // something that has been added by the test. | 958 // something that has been added by the test. |
| 956 OpenAndStartAudioInputStreamOnAudioThread(&full_duplex); | 959 OpenAndStartAudioInputStreamOnAudioThread(&full_duplex); |
| 957 OpenAndStartAudioOutputStreamOnAudioThread(&full_duplex); | 960 OpenAndStartAudioOutputStreamOnAudioThread(&full_duplex); |
| 958 DVLOG(1) << "HINT: an estimate of the extra FIFO delay will be updated " | 961 DVLOG(1) << "HINT: an estimate of the extra FIFO delay will be updated " |
| 959 << "once per second during this test."; | 962 << "once per second during this test."; |
| 960 DVLOG(0) << ">> Speak into the mic and listen to the audio in loopback..."; | 963 DVLOG(0) << ">> Speak into the mic and listen to the audio in loopback..."; |
| 961 fflush(stdout); | 964 fflush(stdout); |
| 962 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); | 965 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); |
| 963 printf("\n"); | 966 printf("\n"); |
| 964 StopAndCloseAudioOutputStreamOnAudioThread(); | 967 StopAndCloseAudioOutputStreamOnAudioThread(); |
| 965 StopAndCloseAudioInputStreamOnAudioThread(); | 968 StopAndCloseAudioInputStreamOnAudioThread(); |
| 966 } | 969 } |
| 967 | 970 |
| 968 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, | 971 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, |
| 969 testing::ValuesIn(RunAudioRecordInputPathTests())); | 972 testing::ValuesIn(RunAudioRecordInputPathTests())); |
| 970 | 973 |
| 971 } // namespace media | 974 } // namespace media |
| OLD | NEW |