Abstract away access to audio devices HAL
In this CL all direct access to audio_hw_device_t and its functions is
encapsulated within the new class DeviceHalLocal. Loading of hardware
modules is encapsulated withing DevicesFactoryHalLocal. AudioFlinger
uses interface classes DevicesFactoryHalInterface and DeviceHalInterface
to access these functions.
Bug: 30222631
Change-Id: Ic88b20c55813a24b898f4a832e082c17d81935b7
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 546cb86..6b5651d 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -3504,13 +3504,12 @@
mPatch = *patch;
if (mOutput->audioHwDev->version() >= AUDIO_DEVICE_API_VERSION_3_0) {
- audio_hw_device_t *hwDevice = mOutput->audioHwDev->hwDevice();
- status = hwDevice->create_audio_patch(hwDevice,
- patch->num_sources,
- patch->sources,
- patch->num_sinks,
- patch->sinks,
- handle);
+ sp<DeviceHalInterface> hwDevice = mOutput->audioHwDev->hwDevice();
+ status = hwDevice->createAudioPatch(patch->num_sources,
+ patch->sources,
+ patch->num_sinks,
+ patch->sinks,
+ handle);
} else {
char *address;
if (strcmp(patch->sinks[0].ext.device.address, "") != 0) {
@@ -3556,8 +3555,8 @@
mOutDevice = AUDIO_DEVICE_NONE;
if (mOutput->audioHwDev->version() >= AUDIO_DEVICE_API_VERSION_3_0) {
- audio_hw_device_t *hwDevice = mOutput->audioHwDev->hwDevice();
- status = hwDevice->release_audio_patch(hwDevice, handle);
+ sp<DeviceHalInterface> hwDevice = mOutput->audioHwDev->hwDevice();
+ status = hwDevice->releaseAudioPatch(handle);
} else {
AudioParameter param;
param.addInt(String8(AUDIO_PARAMETER_STREAM_ROUTING), 0);
@@ -7588,13 +7587,12 @@
}
if (mInput->audioHwDev->version() >= AUDIO_DEVICE_API_VERSION_3_0) {
- audio_hw_device_t *hwDevice = mInput->audioHwDev->hwDevice();
- status = hwDevice->create_audio_patch(hwDevice,
- patch->num_sources,
- patch->sources,
- patch->num_sinks,
- patch->sinks,
- handle);
+ sp<DeviceHalInterface> hwDevice = mInput->audioHwDev->hwDevice();
+ status = hwDevice->createAudioPatch(patch->num_sources,
+ patch->sources,
+ patch->num_sinks,
+ patch->sinks,
+ handle);
} else {
char *address;
if (strcmp(patch->sources[0].ext.device.address, "") != 0) {
@@ -7630,8 +7628,8 @@
mInDevice = AUDIO_DEVICE_NONE;
if (mInput->audioHwDev->version() >= AUDIO_DEVICE_API_VERSION_3_0) {
- audio_hw_device_t *hwDevice = mInput->audioHwDev->hwDevice();
- status = hwDevice->release_audio_patch(hwDevice, handle);
+ sp<DeviceHalInterface> hwDevice = mInput->audioHwDev->hwDevice();
+ status = hwDevice->releaseAudioPatch(handle);
} else {
AudioParameter param;
param.addInt(String8(AUDIO_PARAMETER_STREAM_ROUTING), 0);