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 <krocard@google.com>
diff --git a/audio/common/all-versions/default/service/Android.mk b/audio/common/all-versions/default/service/Android.mk
index edf1761..f502dfd 100644
--- a/audio/common/all-versions/default/service/Android.mk
+++ b/audio/common/all-versions/default/service/Android.mk
@@ -38,8 +38,11 @@
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 d554481..f6e4353 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 <android/hardware/audio/2.0/IDevicesFactory.h>
+#include <android/hardware/audio/4.0/IDevicesFactory.h>
#include <android/hardware/audio/effect/2.0/IEffectsFactory.h>
+#include <android/hardware/audio/effect/4.0/IEffectsFactory.h>
#include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h>
#include <android/hardware/soundtrigger/2.1/ISoundTriggerHw.h>
#include <binder/ProcessState.h>
#include <hidl/HidlTransportSupport.h>
#include <hidl/LegacySupport.h>
-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 @@
// start a threadpool for vndbinder interactions
android::ProcessState::self()->startThreadPool();
configureRpcThreadpool(16, true /*callerWillJoin*/);
- android::status_t status;
- status = registerPassthroughServiceImplementation<IDevicesFactory>();
- LOG_ALWAYS_FATAL_IF(status != OK, "Error while registering audio service: %d", status);
- status = registerPassthroughServiceImplementation<IEffectsFactory>();
- LOG_ALWAYS_FATAL_IF(status != OK, "Error while registering audio effects service: %d", status);
- // Soundtrigger might be not present.
- status = registerPassthroughServiceImplementation<V2_1_ISoundTriggerHw>();
- ALOGW_IF(status != OK, "Registering soundtrigger V2.1 service was unsuccessful: %d", status);
- status = registerPassthroughServiceImplementation<V2_0_ISoundTriggerHw>();
- ALOGW_IF(status != OK, "Registering soundtrigger V2.0 service was unsuccessful: %d", status);
+
+ bool fail = registerPassthroughServiceImplementation<audio::V4_0::IDevicesFactory>() != OK &&
+ registerPassthroughServiceImplementation<audio::V2_0::IDevicesFactory>() != OK;
+ LOG_ALWAYS_FATAL_IF(fail, "Could not register audio core API 2.0 nor 4.0");
+
+ fail = registerPassthroughServiceImplementation<audio::effect::V4_0::IEffectsFactory>() != OK &&
+ registerPassthroughServiceImplementation<audio::effect::V2_0::IEffectsFactory>() != OK,
+ LOG_ALWAYS_FATAL_IF(fail, "Could not register audio effect API 2.0 nor 4.0");
+
+ fail = registerPassthroughServiceImplementation<soundtrigger::V2_1::ISoundTriggerHw>() != OK &&
+ registerPassthroughServiceImplementation<soundtrigger::V2_0::ISoundTriggerHw>() != OK,
+ ALOGW_IF(fail, "Could not register soundtrigger API 2.0 nor 2.1");
+
joinRpcThreadpool();
- return status;
}