summaryrefslogtreecommitdiff
path: root/audio/core/all-versions/default/Device.cpp
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2019-12-14 00:31:42 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-12-14 00:31:42 +0000
commit9866a1b22da2dabe8f08fce0f46a1eb99d1ad455 (patch)
tree9236d038d67afd00202f60ddecb21a5ca171cc18 /audio/core/all-versions/default/Device.cpp
parentd65c829d3024e09963068239ed64d95812961d08 (diff)
parent6c29bf20963069a6ba36cf1bf4ff7293e102fbe6 (diff)
Merge "Audio HAL: Add API to attach an effect to a device"
Diffstat (limited to 'audio/core/all-versions/default/Device.cpp')
-rw-r--r--audio/core/all-versions/default/Device.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/audio/core/all-versions/default/Device.cpp b/audio/core/all-versions/default/Device.cpp
index c6c9464656..ad841caf2e 100644
--- a/audio/core/all-versions/default/Device.cpp
+++ b/audio/core/all-versions/default/Device.cpp
@@ -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>
@@ -403,6 +405,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