OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... | |
35 | 35 |
36 using std::cout; | 36 using std::cout; |
37 using std::endl; | 37 using std::endl; |
38 using ::testing::_; | 38 using ::testing::_; |
39 using ::testing::AtLeast; | 39 using ::testing::AtLeast; |
40 using ::testing::Gt; | 40 using ::testing::Gt; |
41 using ::testing::Invoke; | 41 using ::testing::Invoke; |
42 using ::testing::NiceMock; | 42 using ::testing::NiceMock; |
43 using ::testing::NotNull; | 43 using ::testing::NotNull; |
44 using ::testing::Return; | 44 using ::testing::Return; |
45 using ::testing::TestWithParam; | |
46 | 45 |
47 // #define ENABLE_DEBUG_PRINTF | 46 // #define ENABLE_DEBUG_PRINTF |
48 #ifdef ENABLE_DEBUG_PRINTF | 47 #ifdef ENABLE_DEBUG_PRINTF |
49 #define PRINTD(...) fprintf(stderr, __VA_ARGS__); | 48 #define PRINTD(...) fprintf(stderr, __VA_ARGS__); |
50 #else | 49 #else |
51 #define PRINTD(...) ((void)0) | 50 #define PRINTD(...) ((void)0) |
52 #endif | 51 #endif |
53 #define PRINT(...) fprintf(stderr, __VA_ARGS__); | 52 #define PRINT(...) fprintf(stderr, __VA_ARGS__); |
54 | 53 |
55 namespace webrtc { | 54 namespace webrtc { |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
712 AudioParameters record_parameters_; | 711 AudioParameters record_parameters_; |
713 std::unique_ptr<BuildInfo> build_info_; | 712 std::unique_ptr<BuildInfo> build_info_; |
714 }; | 713 }; |
715 | 714 |
716 TEST_F(AudioDeviceTest, ConstructDestruct) { | 715 TEST_F(AudioDeviceTest, ConstructDestruct) { |
717 // Using the test fixture to create and destruct the audio device module. | 716 // Using the test fixture to create and destruct the audio device module. |
718 } | 717 } |
719 | 718 |
720 // We always ask for a default audio layer when the ADM is constructed. But the | 719 // We always ask for a default audio layer when the ADM is constructed. But the |
721 // ADM will then internally set the best suitable combination of audio layers, | 720 // ADM will then internally set the best suitable combination of audio layers, |
722 // for input and output based on if low-latency output audio in combination | 721 // for input and output based on if low-latency output and/or input audio in |
723 // with OpenSL ES is supported or not. This test ensures that the correct | 722 // combination with OpenSL ES is supported or not. This test ensures that the |
724 // selection is done. | 723 // correct selection is done. |
725 TEST_F(AudioDeviceTest, VerifyDefaultAudioLayer) { | 724 TEST_F(AudioDeviceTest, VerifyDefaultAudioLayer) { |
726 const AudioDeviceModule::AudioLayer audio_layer = GetActiveAudioLayer(); | 725 const AudioDeviceModule::AudioLayer audio_layer = GetActiveAudioLayer(); |
727 bool low_latency_output = audio_manager()->IsLowLatencyPlayoutSupported(); | 726 bool low_latency_output = audio_manager()->IsLowLatencyPlayoutSupported(); |
728 AudioDeviceModule::AudioLayer expected_audio_layer = low_latency_output ? | 727 bool low_latency_input = audio_manager()->IsLowLatencyRecordSupported(); |
729 AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio : | 728 AudioDeviceModule::AudioLayer expected_audio_layer; |
730 AudioDeviceModule::kAndroidJavaAudio; | 729 if (low_latency_output && low_latency_input) |
tommi
2016/09/15 09:34:12
use {} since lines 732-733 wrap
henrika_webrtc
2016/09/16 13:30:47
Done.
| |
730 expected_audio_layer = AudioDeviceModule::kAndroidOpenSLESAudio; | |
731 else if (low_latency_output && !low_latency_input) | |
732 expected_audio_layer = | |
733 AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio; | |
734 else | |
735 expected_audio_layer = AudioDeviceModule::kAndroidJavaAudio; | |
731 EXPECT_EQ(expected_audio_layer, audio_layer); | 736 EXPECT_EQ(expected_audio_layer, audio_layer); |
732 } | 737 } |
733 | 738 |
734 // Verify that it is possible to explicitly create the two types of supported | 739 // Verify that it is possible to explicitly create the two types of supported |
735 // ADMs. These two tests overrides the default selection of native audio layer | 740 // ADMs. These two tests overrides the default selection of native audio layer |
736 // by ignoring if the device supports low-latency output or not. | 741 // by ignoring if the device supports low-latency output or not. |
737 TEST_F(AudioDeviceTest, CorrectAudioLayerIsUsedForCombinedJavaOpenSLCombo) { | 742 TEST_F(AudioDeviceTest, CorrectAudioLayerIsUsedForCombinedJavaOpenSLCombo) { |
738 AudioDeviceModule::AudioLayer expected_layer = | 743 AudioDeviceModule::AudioLayer expected_layer = |
739 AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio; | 744 AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio; |
740 AudioDeviceModule::AudioLayer active_layer = TestActiveAudioLayer( | 745 AudioDeviceModule::AudioLayer active_layer = TestActiveAudioLayer( |
741 expected_layer); | 746 expected_layer); |
742 EXPECT_EQ(expected_layer, active_layer); | 747 EXPECT_EQ(expected_layer, active_layer); |
743 } | 748 } |
744 | 749 |
745 TEST_F(AudioDeviceTest, CorrectAudioLayerIsUsedForJavaInBothDirections) { | 750 TEST_F(AudioDeviceTest, CorrectAudioLayerIsUsedForJavaInBothDirections) { |
746 AudioDeviceModule::AudioLayer expected_layer = | 751 AudioDeviceModule::AudioLayer expected_layer = |
747 AudioDeviceModule::kAndroidJavaAudio; | 752 AudioDeviceModule::kAndroidJavaAudio; |
748 AudioDeviceModule::AudioLayer active_layer = TestActiveAudioLayer( | 753 AudioDeviceModule::AudioLayer active_layer = TestActiveAudioLayer( |
749 expected_layer); | 754 expected_layer); |
750 EXPECT_EQ(expected_layer, active_layer); | 755 EXPECT_EQ(expected_layer, active_layer); |
751 } | 756 } |
752 | 757 |
758 TEST_F(AudioDeviceTest, CorrectAudioLayerIsUsedForOpenSLInBothDirections) { | |
759 AudioDeviceModule::AudioLayer expected_layer = | |
760 AudioDeviceModule::kAndroidOpenSLESAudio; | |
761 AudioDeviceModule::AudioLayer active_layer = | |
762 TestActiveAudioLayer(expected_layer); | |
763 EXPECT_EQ(expected_layer, active_layer); | |
764 } | |
765 | |
753 // The Android ADM supports two different delay reporting modes. One for the | 766 // The Android ADM supports two different delay reporting modes. One for the |
754 // low-latency output path (in combination with OpenSL ES), and one for the | 767 // low-latency output path (in combination with OpenSL ES), and one for the |
755 // high-latency output path (Java backends in both directions). These two tests | 768 // high-latency output path (Java backends in both directions). These two tests |
756 // verifies that the audio manager reports correct delay estimate given the | 769 // verifies that the audio manager reports correct delay estimate given the |
757 // selected audio layer. Note that, this delay estimate will only be utilized | 770 // selected audio layer. Note that, this delay estimate will only be utilized |
758 // if the HW AEC is disabled. | 771 // if the HW AEC is disabled. |
759 TEST_F(AudioDeviceTest, UsesCorrectDelayEstimateForHighLatencyOutputPath) { | 772 TEST_F(AudioDeviceTest, UsesCorrectDelayEstimateForHighLatencyOutputPath) { |
760 EXPECT_EQ(kHighLatencyModeDelayEstimateInMilliseconds, | 773 EXPECT_EQ(kHighLatencyModeDelayEstimateInMilliseconds, |
761 TestDelayOnAudioLayer(AudioDeviceModule::kAndroidJavaAudio)); | 774 TestDelayOnAudioLayer(AudioDeviceModule::kAndroidJavaAudio)); |
762 } | 775 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
856 TEST_F(AudioDeviceTest, StartStopRecording) { | 869 TEST_F(AudioDeviceTest, StartStopRecording) { |
857 StartRecording(); | 870 StartRecording(); |
858 StopRecording(); | 871 StopRecording(); |
859 StartRecording(); | 872 StartRecording(); |
860 StopRecording(); | 873 StopRecording(); |
861 } | 874 } |
862 | 875 |
863 // Verify that calling StopPlayout() will leave us in an uninitialized state | 876 // Verify that calling StopPlayout() will leave us in an uninitialized state |
864 // which will require a new call to InitPlayout(). This test does not call | 877 // which will require a new call to InitPlayout(). This test does not call |
865 // StartPlayout() while being uninitialized since doing so will hit a | 878 // StartPlayout() while being uninitialized since doing so will hit a |
866 // RTC_DCHECK. | 879 // RTC_DCHECK and death tests are not supported on Android. |
867 TEST_F(AudioDeviceTest, StopPlayoutRequiresInitToRestart) { | 880 TEST_F(AudioDeviceTest, StopPlayoutRequiresInitToRestart) { |
868 EXPECT_EQ(0, audio_device()->InitPlayout()); | 881 EXPECT_EQ(0, audio_device()->InitPlayout()); |
869 EXPECT_EQ(0, audio_device()->StartPlayout()); | 882 EXPECT_EQ(0, audio_device()->StartPlayout()); |
870 EXPECT_EQ(0, audio_device()->StopPlayout()); | 883 EXPECT_EQ(0, audio_device()->StopPlayout()); |
871 EXPECT_FALSE(audio_device()->PlayoutIsInitialized()); | 884 EXPECT_FALSE(audio_device()->PlayoutIsInitialized()); |
872 } | 885 } |
873 | 886 |
887 // Verify that calling StopRecording() will leave us in an uninitialized state | |
888 // which will require a new call to InitRecording(). This test does not call | |
889 // StartRecording() while being uninitialized since doing so will hit a | |
890 // RTC_DCHECK and death tests are not supported on Android. | |
891 TEST_F(AudioDeviceTest, StopRecordingRequiresInitToRestart) { | |
892 EXPECT_EQ(0, audio_device()->InitRecording()); | |
893 EXPECT_EQ(0, audio_device()->StartRecording()); | |
894 EXPECT_EQ(0, audio_device()->StopRecording()); | |
895 EXPECT_FALSE(audio_device()->RecordingIsInitialized()); | |
896 } | |
897 | |
874 // Start playout and verify that the native audio layer starts asking for real | 898 // Start playout and verify that the native audio layer starts asking for real |
875 // audio samples to play out using the NeedMorePlayData callback. | 899 // audio samples to play out using the NeedMorePlayData callback. |
876 TEST_F(AudioDeviceTest, StartPlayoutVerifyCallbacks) { | 900 TEST_F(AudioDeviceTest, StartPlayoutVerifyCallbacks) { |
877 MockAudioTransport mock(kPlayout); | 901 MockAudioTransport mock(kPlayout); |
878 mock.HandleCallbacks(test_is_done_.get(), nullptr, kNumCallbacks); | 902 mock.HandleCallbacks(test_is_done_.get(), nullptr, kNumCallbacks); |
879 EXPECT_CALL(mock, NeedMorePlayData(playout_frames_per_10ms_buffer(), | 903 EXPECT_CALL(mock, NeedMorePlayData(playout_frames_per_10ms_buffer(), |
880 kBytesPerSample, | 904 kBytesPerSample, |
881 playout_channels(), | 905 playout_channels(), |
882 playout_sample_rate(), | 906 playout_sample_rate(), |
883 NotNull(), | 907 NotNull(), |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1027 StopPlayout(); | 1051 StopPlayout(); |
1028 StopRecording(); | 1052 StopRecording(); |
1029 // Verify that the correct number of transmitted impulses are detected. | 1053 // Verify that the correct number of transmitted impulses are detected. |
1030 EXPECT_EQ(latency_audio_stream->num_latency_values(), | 1054 EXPECT_EQ(latency_audio_stream->num_latency_values(), |
1031 static_cast<size_t>( | 1055 static_cast<size_t>( |
1032 kImpulseFrequencyInHz * kMeasureLatencyTimeInSec - 1)); | 1056 kImpulseFrequencyInHz * kMeasureLatencyTimeInSec - 1)); |
1033 latency_audio_stream->PrintResults(); | 1057 latency_audio_stream->PrintResults(); |
1034 } | 1058 } |
1035 | 1059 |
1036 } // namespace webrtc | 1060 } // namespace webrtc |
OLD | NEW |