mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Audio HAL: Add API to attach an effect to a device
Add a method to IDevice interface allowing the attachement of an audio effect to an audio device. This is used when an audio effect is implemented below the HAL (e.g by an audio DSP) and is attached/enabled when a particular sink(e.g speaker) or source(e.g mic) device is selected. Bug: 136294538 Test: make Change-Id: I73d78c4f234fd80443a1cb3772c2d65457968652
This commit is contained in:
@@ -295,4 +295,28 @@ interface IDevice {
|
||||
*/
|
||||
@exit
|
||||
close() generates (Result retval);
|
||||
|
||||
/**
|
||||
* Applies an audio effect to an audio device.
|
||||
*
|
||||
* @param device identifies the sink or source device this effect must be applied to.
|
||||
* "device" is the AudioPortHandle indicated for the device when the audio
|
||||
* patch connecting that device was created.
|
||||
* @param effectId effect ID (obtained from IEffectsFactory.createEffect) of
|
||||
* the effect to add.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
addDeviceEffect(AudioPortHandle device, uint64_t effectId) generates (Result retval);
|
||||
|
||||
/**
|
||||
* Stops applying an audio effect to an audio device.
|
||||
*
|
||||
* @param device identifies the sink or source device this effect was applied to.
|
||||
* "device" is the AudioPortHandle indicated for the device when the audio
|
||||
* patch is created at the audio HAL.
|
||||
* @param effectId effect ID (obtained from IEffectsFactory.createEffect) of
|
||||
* the effect.
|
||||
* @return retval operation completion status.
|
||||
*/
|
||||
removeDeviceEffect(AudioPortHandle device, uint64_t effectId) generates (Result retval);
|
||||
};
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "core/default/Device.h"
|
||||
#include <HidlUtils.h>
|
||||
#include "common/all-versions/default/EffectMap.h"
|
||||
#include "core/default/Conversions.h"
|
||||
#include "core/default/StreamIn.h"
|
||||
#include "core/default/StreamOut.h"
|
||||
@@ -25,6 +26,7 @@
|
||||
|
||||
//#define LOG_NDEBUG 0
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
@@ -398,6 +400,39 @@ Result Device::doClose() {
|
||||
Return<Result> Device::close() {
|
||||
return doClose();
|
||||
}
|
||||
|
||||
Return<Result> Device::addDeviceEffect(AudioPortHandle device, uint64_t effectId) {
|
||||
if (version() < AUDIO_DEVICE_API_VERSION_3_1 || mDevice->add_device_effect == nullptr) {
|
||||
return Result::NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
effect_handle_t halEffect = EffectMap::getInstance().get(effectId);
|
||||
if (halEffect != NULL) {
|
||||
return analyzeStatus("add_device_effect",
|
||||
mDevice->add_device_effect(
|
||||
mDevice, static_cast<audio_port_handle_t>(device), halEffect));
|
||||
} else {
|
||||
ALOGW("%s Invalid effect ID passed from client: %" PRIu64 "", __func__, effectId);
|
||||
return Result::INVALID_ARGUMENTS;
|
||||
}
|
||||
}
|
||||
|
||||
Return<Result> Device::removeDeviceEffect(AudioPortHandle device, uint64_t effectId) {
|
||||
if (version() < AUDIO_DEVICE_API_VERSION_3_1 || mDevice->remove_device_effect == nullptr) {
|
||||
return Result::NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
effect_handle_t halEffect = EffectMap::getInstance().get(effectId);
|
||||
if (halEffect != NULL) {
|
||||
return analyzeStatus("remove_device_effect",
|
||||
mDevice->remove_device_effect(
|
||||
mDevice, static_cast<audio_port_handle_t>(device), halEffect));
|
||||
} else {
|
||||
ALOGW("%s Invalid effect ID passed from client: %" PRIu64 "", __func__, effectId);
|
||||
return Result::INVALID_ARGUMENTS;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace implementation
|
||||
|
||||
@@ -168,6 +168,14 @@ Return<Result> PrimaryDevice::setConnectedState(const DeviceAddress& address, bo
|
||||
Return<Result> PrimaryDevice::close() {
|
||||
return mDevice->close();
|
||||
}
|
||||
|
||||
Return<Result> PrimaryDevice::addDeviceEffect(AudioPortHandle device, uint64_t effectId) {
|
||||
return mDevice->addDeviceEffect(device, effectId);
|
||||
}
|
||||
|
||||
Return<Result> PrimaryDevice::removeDeviceEffect(AudioPortHandle device, uint64_t effectId) {
|
||||
return mDevice->removeDeviceEffect(device, effectId);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Methods from ::android::hardware::audio::CPP_VERSION::IPrimaryDevice follow.
|
||||
|
||||
@@ -116,8 +116,9 @@ struct Device : public IDevice, public ParametersUtil {
|
||||
#endif
|
||||
#if MAJOR_VERSION >= 6
|
||||
Return<Result> close() override;
|
||||
Return<Result> addDeviceEffect(AudioPortHandle device, uint64_t effectId) override;
|
||||
Return<Result> removeDeviceEffect(AudioPortHandle device, uint64_t effectId) override;
|
||||
#endif
|
||||
|
||||
Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override;
|
||||
|
||||
// Utility methods for extending interfaces.
|
||||
|
||||
@@ -98,6 +98,8 @@ struct PrimaryDevice : public IPrimaryDevice {
|
||||
#endif
|
||||
#if MAJOR_VERSION >= 6
|
||||
Return<Result> close() override;
|
||||
Return<Result> addDeviceEffect(AudioPortHandle device, uint64_t effectId) override;
|
||||
Return<Result> removeDeviceEffect(AudioPortHandle device, uint64_t effectId) override;
|
||||
#endif
|
||||
|
||||
Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override;
|
||||
|
||||
@@ -598,7 +598,7 @@ fd65298e1e09e0e3c781ab18305920d757dbe55a3b459ce17814ec5cf6dfee99 android.hardwar
|
||||
|
||||
# HALs released in Android R
|
||||
e966a3437d6a98d9d9e14e9d672088771716031900c0deb55a0946c751a03a44 android.hardware.audio@6.0::types
|
||||
2736c59abaccacac407ebe80c5e48d446edf015051d05632fb679ba471779e6e android.hardware.audio@6.0::IDevice
|
||||
4540d12fe1cea996f21bd1712d4ae0906dcbd58177dac494efc605b004902d43 android.hardware.audio@6.0::IDevice
|
||||
2402876cbc23c0de3690a665eca84fd3857d1808dba5cad25ce272f81ecef8c9 android.hardware.audio@6.0::IDevicesFactory
|
||||
bca5379d5065e2e08b6ad7308ffc8a71a972fc0698bec678ea32eea786d01cb5 android.hardware.audio@6.0::IPrimaryDevice
|
||||
fd1f1b29f26b42e886220f04a08086c00e5ade9d7b53f095438e578ab9d42a93 android.hardware.audio@6.0::IStream
|
||||
|
||||
Reference in New Issue
Block a user