Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(844)

Unified Diff: webrtc/modules/audio_device/android/audio_device_unittest.cc

Issue 2119633004: Adds support for OpenSL ES based audio capture on Android (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing presubmit warnings Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_device/android/audio_device_unittest.cc
diff --git a/webrtc/modules/audio_device/android/audio_device_unittest.cc b/webrtc/modules/audio_device/android/audio_device_unittest.cc
index 78c83e98309d721265a5c0085b99ccc30366bcf3..e3a4920fdf095d5be1c3115726035772907b1c37 100644
--- a/webrtc/modules/audio_device/android/audio_device_unittest.cc
+++ b/webrtc/modules/audio_device/android/audio_device_unittest.cc
@@ -42,7 +42,6 @@ using ::testing::Invoke;
using ::testing::NiceMock;
using ::testing::NotNull;
using ::testing::Return;
-using ::testing::TestWithParam;
// #define ENABLE_DEBUG_PRINTF
#ifdef ENABLE_DEBUG_PRINTF
@@ -719,15 +718,22 @@ TEST_F(AudioDeviceTest, ConstructDestruct) {
// We always ask for a default audio layer when the ADM is constructed. But the
// ADM will then internally set the best suitable combination of audio layers,
-// for input and output based on if low-latency output audio in combination
-// with OpenSL ES is supported or not. This test ensures that the correct
-// selection is done.
+// for input and output based on if low-latency output and/or input audio in
+// combination with OpenSL ES is supported or not. This test ensures that the
+// correct selection is done.
TEST_F(AudioDeviceTest, VerifyDefaultAudioLayer) {
const AudioDeviceModule::AudioLayer audio_layer = GetActiveAudioLayer();
bool low_latency_output = audio_manager()->IsLowLatencyPlayoutSupported();
- AudioDeviceModule::AudioLayer expected_audio_layer = low_latency_output ?
- AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio :
- AudioDeviceModule::kAndroidJavaAudio;
+ bool low_latency_input = audio_manager()->IsLowLatencyRecordSupported();
+ AudioDeviceModule::AudioLayer expected_audio_layer;
+ if (low_latency_output && low_latency_input) {
+ expected_audio_layer = AudioDeviceModule::kAndroidOpenSLESAudio;
+ } else if (low_latency_output && !low_latency_input) {
+ expected_audio_layer =
+ AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio;
+ } else {
+ expected_audio_layer = AudioDeviceModule::kAndroidJavaAudio;
+ }
EXPECT_EQ(expected_audio_layer, audio_layer);
}
@@ -750,6 +756,14 @@ TEST_F(AudioDeviceTest, CorrectAudioLayerIsUsedForJavaInBothDirections) {
EXPECT_EQ(expected_layer, active_layer);
}
+TEST_F(AudioDeviceTest, CorrectAudioLayerIsUsedForOpenSLInBothDirections) {
+ AudioDeviceModule::AudioLayer expected_layer =
+ AudioDeviceModule::kAndroidOpenSLESAudio;
+ AudioDeviceModule::AudioLayer active_layer =
+ TestActiveAudioLayer(expected_layer);
+ EXPECT_EQ(expected_layer, active_layer);
+}
+
// The Android ADM supports two different delay reporting modes. One for the
// low-latency output path (in combination with OpenSL ES), and one for the
// high-latency output path (Java backends in both directions). These two tests
@@ -863,7 +877,7 @@ TEST_F(AudioDeviceTest, StartStopRecording) {
// Verify that calling StopPlayout() will leave us in an uninitialized state
// which will require a new call to InitPlayout(). This test does not call
// StartPlayout() while being uninitialized since doing so will hit a
-// RTC_DCHECK.
+// RTC_DCHECK and death tests are not supported on Android.
TEST_F(AudioDeviceTest, StopPlayoutRequiresInitToRestart) {
EXPECT_EQ(0, audio_device()->InitPlayout());
EXPECT_EQ(0, audio_device()->StartPlayout());
@@ -871,6 +885,17 @@ TEST_F(AudioDeviceTest, StopPlayoutRequiresInitToRestart) {
EXPECT_FALSE(audio_device()->PlayoutIsInitialized());
}
+// Verify that calling StopRecording() will leave us in an uninitialized state
+// which will require a new call to InitRecording(). This test does not call
+// StartRecording() while being uninitialized since doing so will hit a
+// RTC_DCHECK and death tests are not supported on Android.
+TEST_F(AudioDeviceTest, StopRecordingRequiresInitToRestart) {
+ EXPECT_EQ(0, audio_device()->InitRecording());
+ EXPECT_EQ(0, audio_device()->StartRecording());
+ EXPECT_EQ(0, audio_device()->StopRecording());
+ EXPECT_FALSE(audio_device()->RecordingIsInitialized());
+}
+
// Start playout and verify that the native audio layer starts asking for real
// audio samples to play out using the NeedMorePlayData callback.
TEST_F(AudioDeviceTest, StartPlayoutVerifyCallbacks) {
« no previous file with comments | « webrtc/modules/audio_device/android/audio_device_template.h ('k') | webrtc/modules/audio_device/android/audio_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698