From bee7f4eb1e74c0ca0cff2c745c13935d9e77a9e5 Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Thu, 1 Mar 2018 18:56:58 -0800 Subject: [PATCH] Audio V4: Declare support for 4.0 interface Declare that the audio HAL service supports 4.0 as well as 2.0 interface. Formatting done by clang-format. Test: compile Bug: 38184704 Change-Id: Iee842b141e1218f4f3779187339bde40680ec78a Merged-In: Iee842b141e1218f4f3779187339bde40680ec78a Cherry-picked from master Signed-off-by: Kevin Rocard --- .../all-versions/default/service/Android.mk | 3 ++ .../all-versions/default/service/service.cpp | 37 ++++++++----------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/audio/common/all-versions/default/service/Android.mk b/audio/common/all-versions/default/service/Android.mk index edf1761b7f..f502dfd430 100644 --- a/audio/common/all-versions/default/service/Android.mk +++ b/audio/common/all-versions/default/service/Android.mk @@ -38,8 +38,11 @@ LOCAL_SHARED_LIBRARIES := \ libutils \ libhardware \ android.hardware.audio@2.0 \ + android.hardware.audio@4.0 \ android.hardware.audio.common@2.0 \ + android.hardware.audio.common@4.0 \ android.hardware.audio.effect@2.0 \ + android.hardware.audio.effect@4.0 \ android.hardware.soundtrigger@2.0 \ android.hardware.soundtrigger@2.1 diff --git a/audio/common/all-versions/default/service/service.cpp b/audio/common/all-versions/default/service/service.cpp index d554481291..f6e4353598 100644 --- a/audio/common/all-versions/default/service/service.cpp +++ b/audio/common/all-versions/default/service/service.cpp @@ -17,23 +17,16 @@ #define LOG_TAG "audiohalservice" #include +#include #include +#include #include #include #include #include #include -using android::hardware::configureRpcThreadpool; -using android::hardware::joinRpcThreadpool; -using android::hardware::registerPassthroughServiceImplementation; - -using android::hardware::audio::effect::V2_0::IEffectsFactory; -using android::hardware::audio::V2_0::IDevicesFactory; -using V2_0_ISoundTriggerHw = android::hardware::soundtrigger::V2_0::ISoundTriggerHw; -using V2_1_ISoundTriggerHw = android::hardware::soundtrigger::V2_1::ISoundTriggerHw; -using android::hardware::registerPassthroughServiceImplementation; - +using namespace android::hardware; using android::OK; int main(int /* argc */, char* /* argv */ []) { @@ -41,16 +34,18 @@ int main(int /* argc */, char* /* argv */ []) { // start a threadpool for vndbinder interactions android::ProcessState::self()->startThreadPool(); configureRpcThreadpool(16, true /*callerWillJoin*/); - android::status_t status; - status = registerPassthroughServiceImplementation(); - LOG_ALWAYS_FATAL_IF(status != OK, "Error while registering audio service: %d", status); - status = registerPassthroughServiceImplementation(); - LOG_ALWAYS_FATAL_IF(status != OK, "Error while registering audio effects service: %d", status); - // Soundtrigger might be not present. - status = registerPassthroughServiceImplementation(); - ALOGW_IF(status != OK, "Registering soundtrigger V2.1 service was unsuccessful: %d", status); - status = registerPassthroughServiceImplementation(); - ALOGW_IF(status != OK, "Registering soundtrigger V2.0 service was unsuccessful: %d", status); + + bool fail = registerPassthroughServiceImplementation() != OK && + registerPassthroughServiceImplementation() != OK; + LOG_ALWAYS_FATAL_IF(fail, "Could not register audio core API 2.0 nor 4.0"); + + fail = registerPassthroughServiceImplementation() != OK && + registerPassthroughServiceImplementation() != OK, + LOG_ALWAYS_FATAL_IF(fail, "Could not register audio effect API 2.0 nor 4.0"); + + fail = registerPassthroughServiceImplementation() != OK && + registerPassthroughServiceImplementation() != OK, + ALOGW_IF(fail, "Could not register soundtrigger API 2.0 nor 2.1"); + joinRpcThreadpool(); - return status; }