From 40ca56b008f724ce029c00f5016884f4c6b2c707 Mon Sep 17 00:00:00 2001 From: Phil Burk Date: Thu, 22 Oct 2020 16:23:50 -0700 Subject: [PATCH] oboe: change VoicePerformance to VoiceRecognition on P Fixes #1009 --- src/aaudio/AudioStreamAAudio.cpp | 7 ++++++- src/opensles/AudioInputStreamOpenSLES.cpp | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/aaudio/AudioStreamAAudio.cpp b/src/aaudio/AudioStreamAAudio.cpp index d61407ec2..6d77c509b 100644 --- a/src/aaudio/AudioStreamAAudio.cpp +++ b/src/aaudio/AudioStreamAAudio.cpp @@ -213,8 +213,13 @@ Result AudioStreamAAudio::open() { } if (mLibLoader->builder_setInputPreset != nullptr) { + aaudio_input_preset_t inputPreset = mInputPreset; + if (getSdkVersion() <= __ANDROID_API_P__ && inputPreset == InputPreset::VoicePerformance) { + LOGD("InputPreset::VoicePerformance not supported before Q. Using VoiceRecognition."); + inputPreset = InputPreset::VoiceRecognition; // most similar preset + } mLibLoader->builder_setInputPreset(aaudioBuilder, - static_cast(mInputPreset)); + static_cast(inputPreset)); } if (mLibLoader->builder_setSessionId != nullptr) { diff --git a/src/opensles/AudioInputStreamOpenSLES.cpp b/src/opensles/AudioInputStreamOpenSLES.cpp index fcad183bf..8526765db 100644 --- a/src/opensles/AudioInputStreamOpenSLES.cpp +++ b/src/opensles/AudioInputStreamOpenSLES.cpp @@ -36,6 +36,7 @@ static SLuint32 OpenSLES_convertInputPreset(InputPreset oboePreset) { openslPreset = SL_ANDROID_RECORDING_PRESET_CAMCORDER; break; case InputPreset::VoiceRecognition: + case InputPreset::VoicePerformance: openslPreset = SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION; break; case InputPreset::VoiceCommunication: