Remove last references to hardware/audio.h
DeviceHalInterface transitioned to "capabilities" model
(similar to the one already used by streams, e.g. 'supportsDrain').
No direct checking of the HAL version is needed.
AudioPolicy uses its own version read from the configuration,
and these values never checked against the actual HAL version,
thus it does not need versions and macroses from hardware/*.
Test: make & run on N6P
Change-Id: Ic4a56bfa19a9a61edac2b9f9a163fd8f63a0ff87
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 6c71f60..04fb8ba 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -67,8 +67,6 @@
#include <mediautils/BatteryNotifier.h>
#include <private/android_filesystem_config.h>
-#include <hardware/audio.h> // for AUDIO_HARDWARE_MODULE_...
-
// ----------------------------------------------------------------------------
// Note: the following macro is used for extremely verbose logging message. In
diff --git a/services/audioflinger/AudioHwDevice.cpp b/services/audioflinger/AudioHwDevice.cpp
index 28110a2..b109d06 100644
--- a/services/audioflinger/AudioHwDevice.cpp
+++ b/services/audioflinger/AudioHwDevice.cpp
@@ -93,10 +93,10 @@
return status;
}
-uint32_t AudioHwDevice::version() const
-{
- uint32_t result;
- return mHwDevice->getVersion(&result) == OK ? result : 0;
+bool AudioHwDevice::supportsAudioPatches() const {
+ bool result;
+ return mHwDevice->supportsAudioPatches(&result) == OK ? result : false;
}
+
}; // namespace android
diff --git a/services/audioflinger/AudioHwDevice.h b/services/audioflinger/AudioHwDevice.h
index ebb8911..eb826c6 100644
--- a/services/audioflinger/AudioHwDevice.h
+++ b/services/audioflinger/AudioHwDevice.h
@@ -58,7 +58,6 @@
audio_module_handle_t handle() const { return mHandle; }
const char *moduleName() const { return mModuleName; }
sp<DeviceHalInterface> hwDevice() const { return mHwDevice; }
- uint32_t version() const;
/** This method creates and opens the audio hardware output stream.
* The "address" parameter qualifies the "devices" audio device type if needed.
@@ -75,6 +74,8 @@
struct audio_config *config,
const char *address);
+ bool supportsAudioPatches() const;
+
private:
const audio_module_handle_t mHandle;
const char * const mModuleName;
diff --git a/services/audioflinger/PatchPanel.cpp b/services/audioflinger/PatchPanel.cpp
index 93f634a..591a49e 100644
--- a/services/audioflinger/PatchPanel.cpp
+++ b/services/audioflinger/PatchPanel.cpp
@@ -27,8 +27,6 @@
#include "ServiceUtilities.h"
#include <media/AudioParameter.h>
-#include <hardware/audio.h> // for AUDIO_DEVICE_API_VERSION_...
-
// ----------------------------------------------------------------------------
// Note: the following macro is used for extremely verbose logging message. In
@@ -249,11 +247,11 @@
// - special patch request with 2 sources (reuse one existing output mix) OR
// - Device to device AND
// - source HW module != destination HW module OR
- // - audio HAL version < 3.0
+ // - audio HAL does not support audio patches creation
if ((patch->num_sources == 2) ||
((patch->sinks[0].type == AUDIO_PORT_TYPE_DEVICE) &&
((patch->sinks[0].ext.device.hw_module != srcModule) ||
- (audioHwDevice->version() < AUDIO_DEVICE_API_VERSION_3_0)))) {
+ !audioHwDevice->supportsAudioPatches()))) {
if (patch->num_sources == 2) {
if (patch->sources[1].type != AUDIO_PORT_TYPE_MIX ||
(patch->num_sinks != 0 && patch->sinks[0].ext.device.hw_module !=
@@ -341,17 +339,13 @@
}
status = thread->sendCreateAudioPatchConfigEvent(patch, &halHandle);
} else {
- if (audioHwDevice->version() < AUDIO_DEVICE_API_VERSION_3_0) {
- status = INVALID_OPERATION;
- goto exit;
- }
-
sp<DeviceHalInterface> hwDevice = audioHwDevice->hwDevice();
status = hwDevice->createAudioPatch(patch->num_sources,
patch->sources,
patch->num_sinks,
patch->sinks,
&halHandle);
+ if (status == INVALID_OPERATION) goto exit;
}
}
} break;
@@ -620,10 +614,6 @@
status = thread->sendReleaseAudioPatchConfigEvent(removedPatch->mHalHandle);
} else {
AudioHwDevice *audioHwDevice = audioflinger->mAudioHwDevs.valueAt(index);
- if (audioHwDevice->version() < AUDIO_DEVICE_API_VERSION_3_0) {
- status = INVALID_OPERATION;
- break;
- }
sp<DeviceHalInterface> hwDevice = audioHwDevice->hwDevice();
status = hwDevice->releaseAudioPatch(removedPatch->mHalHandle);
}
@@ -688,13 +678,7 @@
}
AudioHwDevice *audioHwDevice = audioflinger->mAudioHwDevs.valueAt(index);
- if (audioHwDevice->version() >= AUDIO_DEVICE_API_VERSION_3_0) {
- sp<DeviceHalInterface> hwDevice = audioHwDevice->hwDevice();
- return hwDevice->setAudioPortConfig(config);
- } else {
- return INVALID_OPERATION;
- }
- return NO_ERROR;
+ return audioHwDevice->hwDevice()->setAudioPortConfig(config);
}
} // namespace android
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index e661a3b..6b23e56 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -53,8 +53,6 @@
#include <powermanager/PowerManager.h>
-#include <hardware/audio.h> // for AUDIO_DEVICE_API_VERSION_...
-
#include "AudioFlinger.h"
#include "AudioMixer.h"
#include "BufferProviders.h"
@@ -3492,7 +3490,7 @@
mOutDevice = type;
mPatch = *patch;
- if (mOutput->audioHwDev->version() >= AUDIO_DEVICE_API_VERSION_3_0) {
+ if (mOutput->audioHwDev->supportsAudioPatches()) {
sp<DeviceHalInterface> hwDevice = mOutput->audioHwDev->hwDevice();
status = hwDevice->createAudioPatch(patch->num_sources,
patch->sources,
@@ -3542,7 +3540,7 @@
mOutDevice = AUDIO_DEVICE_NONE;
- if (mOutput->audioHwDev->version() >= AUDIO_DEVICE_API_VERSION_3_0) {
+ if (mOutput->audioHwDev->supportsAudioPatches()) {
sp<DeviceHalInterface> hwDevice = mOutput->audioHwDev->hwDevice();
status = hwDevice->releaseAudioPatch(handle);
} else {
@@ -7612,7 +7610,7 @@
}
}
- if (mInput->audioHwDev->version() >= AUDIO_DEVICE_API_VERSION_3_0) {
+ if (mInput->audioHwDev->supportsAudioPatches()) {
sp<DeviceHalInterface> hwDevice = mInput->audioHwDev->hwDevice();
status = hwDevice->createAudioPatch(patch->num_sources,
patch->sources,
@@ -7652,7 +7650,7 @@
mInDevice = AUDIO_DEVICE_NONE;
- if (mInput->audioHwDev->version() >= AUDIO_DEVICE_API_VERSION_3_0) {
+ if (mInput->audioHwDev->supportsAudioPatches()) {
sp<DeviceHalInterface> hwDevice = mInput->audioHwDev->hwDevice();
status = hwDevice->releaseAudioPatch(handle);
} else {