Audio V4: Introduce 4.0 shim to HIDL
The difference between the 2.0 and the 4.0 is very small
by design and most of the modification have been made in a
retro compatible way
The intent is to be able to merge the two implementation
but it could not be done in this patch due to time constrains.
Bug: 38184704
Test: compile
Change-Id: I4738928313b7fd1f6332c0f22bb802d4fba41d82
Merged-In: I4738928313b7fd1f6332c0f22bb802d4fba41d82
Cherry-picked from master
Signed-off-by: Kevin Rocard <krocard@google.com>
diff --git a/media/libaudiohal/4.0/DevicesFactoryHalHidl.cpp b/media/libaudiohal/4.0/DevicesFactoryHalHidl.cpp
index 5feed09..c83194e 100644
--- a/media/libaudiohal/4.0/DevicesFactoryHalHidl.cpp
+++ b/media/libaudiohal/4.0/DevicesFactoryHalHidl.cpp
@@ -52,36 +52,11 @@
DevicesFactoryHalHidl::~DevicesFactoryHalHidl() {
}
-// static
-status_t DevicesFactoryHalHidl::nameFromHal(const char *name, IDevicesFactory::Device *device) {
- if (strcmp(name, AUDIO_HARDWARE_MODULE_ID_PRIMARY) == 0) {
- *device = IDevicesFactory::Device::PRIMARY;
- return OK;
- } else if(strcmp(name, AUDIO_HARDWARE_MODULE_ID_A2DP) == 0) {
- *device = IDevicesFactory::Device::A2DP;
- return OK;
- } else if(strcmp(name, AUDIO_HARDWARE_MODULE_ID_USB) == 0) {
- *device = IDevicesFactory::Device::USB;
- return OK;
- } else if(strcmp(name, AUDIO_HARDWARE_MODULE_ID_REMOTE_SUBMIX) == 0) {
- *device = IDevicesFactory::Device::R_SUBMIX;
- return OK;
- } else if(strcmp(name, AUDIO_HARDWARE_MODULE_ID_STUB) == 0) {
- *device = IDevicesFactory::Device::STUB;
- return OK;
- }
- ALOGE("Invalid device name %s", name);
- return BAD_VALUE;
-}
-
status_t DevicesFactoryHalHidl::openDevice(const char *name, sp<DeviceHalInterface> *device) {
if (mDevicesFactory == 0) return NO_INIT;
- IDevicesFactory::Device hidlDevice;
- status_t status = nameFromHal(name, &hidlDevice);
- if (status != OK) return status;
Result retval = Result::NOT_INITIALIZED;
Return<void> ret = mDevicesFactory->openDevice(
- hidlDevice,
+ name,
[&](Result r, const sp<IDevice>& result) {
retval = r;
if (retval == Result::OK) {