From 929923e66ccb51ae18ddbf72ef51058b3b2dbb82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Mon, 22 Feb 2021 15:12:48 -0500 Subject: [PATCH] opensl: gracefully fallback from AEC errors Change-Id: I2a59248df58ad5e019d3ded0b97e4db95c5520cb --- src/media/audio/opensl/audio_recorder.cpp | 59 ++++++++++------------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/src/media/audio/opensl/audio_recorder.cpp b/src/media/audio/opensl/audio_recorder.cpp index a996f63820..379ff6d72c 100644 --- a/src/media/audio/opensl/audio_recorder.cpp +++ b/src/media/audio/opensl/audio_recorder.cpp @@ -131,8 +131,9 @@ AudioRecorder::AudioRecorder(jami::AudioFormat sampleFormat, size_t bufSize, SLE SL_ANDROID_KEY_PERFORMANCE_MODE, &modeSize, (void*) &modeRetrieved); - SLASSERT(result); - JAMI_WARN("Actual performance mode is %u\n", modeRetrieved); + if (result == SL_RESULT_SUCCESS) { + JAMI_WARN("Actual performance mode is %u\n", modeRetrieved); + } /* Enable AEC if requested */ if (aec) { @@ -144,18 +145,14 @@ AudioRecorder::AudioRecorder(jami::AudioFormat sampleFormat, size_t bufSize, SLE JAMI_WARN("AEC is %savailable\n", SL_RESULT_SUCCESS == result ? "" : "not "); if (SL_RESULT_SUCCESS == result) { SLboolean enabled; - result = (*aecItf)->IsEnabled(aecItf, &enabled); - SLASSERT(result); - JAMI_WARN("AEC was %s\n", enabled ? "enabled" : "not enabled"); - - result = (*aecItf)->SetEnabled(aecItf, true); - SLASSERT(result); - - result = (*aecItf)->IsEnabled(aecItf, &enabled); - SLASSERT(result); - JAMI_WARN("AEC is now %s\n", enabled ? "enabled" : "not enabled"); - - hasNativeAEC_ = enabled; + if ((*aecItf)->IsEnabled(aecItf, &enabled) == SL_RESULT_SUCCESS) { + JAMI_WARN("AEC was %s\n", enabled ? "enabled" : "not enabled"); + (*aecItf)->SetEnabled(aecItf, true); + if ((*aecItf)->IsEnabled(aecItf, &enabled) == SL_RESULT_SUCCESS) { + JAMI_WARN("AEC is now %s\n", enabled ? "enabled" : "not enabled"); + hasNativeAEC_ = enabled; + } + } } } /* Enable AGC if requested */ @@ -168,16 +165,13 @@ AudioRecorder::AudioRecorder(jami::AudioFormat sampleFormat, size_t bufSize, SLE JAMI_WARN("AGC is %savailable\n", SL_RESULT_SUCCESS == result ? "" : "not "); if (SL_RESULT_SUCCESS == result) { SLboolean enabled; - result = (*agcItf)->IsEnabled(agcItf, &enabled); - SLASSERT(result); - JAMI_WARN("AGC was %s\n", enabled ? "enabled" : "not enabled"); - - result = (*agcItf)->SetEnabled(agcItf, true); - SLASSERT(result); - - result = (*agcItf)->IsEnabled(agcItf, &enabled); - SLASSERT(result); - JAMI_WARN("AGC is now %s\n", enabled ? "enabled" : "not enabled"); + if ((*agcItf)->IsEnabled(agcItf, &enabled) == SL_RESULT_SUCCESS) { + JAMI_WARN("AGC was %s\n", enabled ? "enabled" : "not enabled"); + (*agcItf)->SetEnabled(agcItf, true); + if ((*agcItf)->IsEnabled(agcItf, &enabled) == SL_RESULT_SUCCESS) { + JAMI_WARN("AGC is now %s\n", enabled ? "enabled" : "not enabled"); + } + } } } /* Enable NS if requested */ @@ -188,16 +182,13 @@ AudioRecorder::AudioRecorder(jami::AudioFormat sampleFormat, size_t bufSize, SLE JAMI_WARN("NS is %savailable\n", SL_RESULT_SUCCESS == result ? "" : "not "); if (SL_RESULT_SUCCESS == result) { SLboolean enabled; - result = (*nsItf)->IsEnabled(nsItf, &enabled); - SLASSERT(result); - JAMI_WARN("NS was %s\n", enabled ? "enabled" : "not enabled"); - - result = (*nsItf)->SetEnabled(nsItf, true); - SLASSERT(result); - - result = (*nsItf)->IsEnabled(nsItf, &enabled); - SLASSERT(result); - JAMI_WARN("NS is now %s\n", enabled ? "enabled" : "not enabled"); + if ((*nsItf)->IsEnabled(nsItf, &enabled) == SL_RESULT_SUCCESS) { + JAMI_WARN("NS was %s\n", enabled ? "enabled" : "not enabled"); + (*nsItf)->SetEnabled(nsItf, true); + if ((*nsItf)->IsEnabled(nsItf, &enabled) == SL_RESULT_SUCCESS) { + JAMI_WARN("NS is now %s\n", enabled ? "enabled" : "not enabled"); + } + } } } -- GitLab