diff --git a/CMakeLists.txt b/CMakeLists.txt index fb4609f..0133a2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.16.3) + set(CMAKE_CXX_COMPILER_VERSION 20) +set(CMAKE_CXX_STANDARD 20) # NDK Settings #add_compile_definitions(ANDROID_ABI=arm64-v8a) diff --git a/src/ViPER4Android.cpp b/src/ViPER4Android.cpp index 5140bf8..60c8380 100644 --- a/src/ViPER4Android.cpp +++ b/src/ViPER4Android.cpp @@ -3,6 +3,14 @@ #include "essential.h" #include "viper/constants.h" #include "ViperContext.h" +#include +#include +#include +#include + +using aidl::android::hardware::audio::effect::Descriptor; +using aidl::android::hardware::audio::effect::IEffect; +using aidl::android::media::audio::common::AudioUuid; extern "C" { struct ViperHandle { @@ -82,23 +90,30 @@ static int32_t viperLibraryGetDescriptor(const effect_uuid_t *uuid, effect_descr extern "C" __attribute__((visibility("default"))) -int createEffect() { +binder_exception_t createEffect(const AudioUuid *audio_uuid, std::shared_ptr *instance) { VIPER_LOGD("createEffect called"); - return -3; + return EX_ILLEGAL_ARGUMENT; } extern "C" __attribute__((visibility("default"))) -int destroyEffect() { +binder_exception_t destroyEffect(const std::shared_ptr &instanceSp) { VIPER_LOGD("destroyEffect called"); - return -5; + return EX_ILLEGAL_STATE; } -extern "C" -__attribute__((visibility("default"))) -int queryEffect() { +//extern "C" binder_exception_t queryEffect(const AudioUuid* in_impl_uuid, Descriptor* _aidl_return) { +// if (!in_impl_uuid || *in_impl_uuid != getEffectImplUuidVisualizer()) { +// LOG(ERROR) << __func__ << "uuid not supported"; +// return EX_ILLEGAL_ARGUMENT; +// } +// *_aidl_return = VisualizerImpl::kDescriptor; +// return EX_NONE; +//} + +extern "C" binder_exception_t queryEffect(const AudioUuid *audio_uuid, Descriptor *descriptor) { VIPER_LOGD("queryEffect called"); - return -3; + return EX_ILLEGAL_ARGUMENT; } extern "C" diff --git a/src/include/aidl/android/hardware/audio/effect/Descriptor.h b/src/include/aidl/android/hardware/audio/effect/Descriptor.h new file mode 100644 index 0000000..cb545a5 --- /dev/null +++ b/src/include/aidl/android/hardware/audio/effect/Descriptor.h @@ -0,0 +1,89 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +namespace aidl::android::hardware::audio::effect { + class Descriptor { + public: + class Identity { + public: + ::aidl::android::media::audio::common::AudioUuid type; + ::aidl::android::media::audio::common::AudioUuid uuid; + std::optional<::aidl::android::media::audio::common::AudioUuid> proxy; + + inline bool operator==(const Identity& _rhs) const { + return std::tie(type, uuid, proxy) == std::tie(_rhs.type, _rhs.uuid, _rhs.proxy); + } + inline bool operator<(const Identity& _rhs) const { + return std::tie(type, uuid, proxy) < std::tie(_rhs.type, _rhs.uuid, _rhs.proxy); + } + inline bool operator!=(const Identity& _rhs) const { + return !(*this == _rhs); + } + inline bool operator>(const Identity& _rhs) const { + return _rhs < *this; + } + inline bool operator>=(const Identity& _rhs) const { + return !(*this < _rhs); + } + inline bool operator<=(const Identity& _rhs) const { + return !(_rhs < *this); + } + }; + class Common { + public: + ::aidl::android::hardware::audio::effect::Descriptor::Identity id; + ::aidl::android::hardware::audio::effect::Flags flags; + int32_t cpuLoad = 0; + int32_t memoryUsage = 0; + std::string name; + std::string implementor; + + inline bool operator==(const Common& _rhs) const { + return std::tie(id, flags, cpuLoad, memoryUsage, name, implementor) == std::tie(_rhs.id, _rhs.flags, _rhs.cpuLoad, _rhs.memoryUsage, _rhs.name, _rhs.implementor); + } + inline bool operator<(const Common& _rhs) const { + return std::tie(id, flags, cpuLoad, memoryUsage, name, implementor) < std::tie(_rhs.id, _rhs.flags, _rhs.cpuLoad, _rhs.memoryUsage, _rhs.name, _rhs.implementor); + } + inline bool operator!=(const Common& _rhs) const { + return !(*this == _rhs); + } + inline bool operator>(const Common& _rhs) const { + return _rhs < *this; + } + inline bool operator>=(const Common& _rhs) const { + return !(*this < _rhs); + } + inline bool operator<=(const Common& _rhs) const { + return !(_rhs < *this); + } + }; + ::aidl::android::hardware::audio::effect::Descriptor::Common common; + /*::aidl::android::hardware::audio::effect::Capability capability;*/ + + inline bool operator==(const Descriptor& _rhs) const { + return std::tie(common/*, capability*/) == std::tie(_rhs.common/*, _rhs.capability*/); + } + inline bool operator<(const Descriptor& _rhs) const { + return std::tie(common/*, capability*/) < std::tie(_rhs.common/*, _rhs.capability*/); + } + inline bool operator!=(const Descriptor& _rhs) const { + return !(*this == _rhs); + } + inline bool operator>(const Descriptor& _rhs) const { + return _rhs < *this; + } + inline bool operator>=(const Descriptor& _rhs) const { + return !(*this < _rhs); + } + inline bool operator<=(const Descriptor& _rhs) const { + return !(_rhs < *this); + } + }; +} // namespace aidl::android::hardware::audio::effect diff --git a/src/include/aidl/android/hardware/audio/effect/Flags.h b/src/include/aidl/android/hardware/audio/effect/Flags.h new file mode 100644 index 0000000..ed863cd --- /dev/null +++ b/src/include/aidl/android/hardware/audio/effect/Flags.h @@ -0,0 +1,72 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace aidl::android::hardware::audio::effect { + class Flags { + public: + enum class Type : int8_t { + INSERT = 0, + AUXILIARY = 1, + REPLACE = 2, + PRE_PROC = 3, + POST_PROC = 4, + }; + + enum class Insert : int8_t { + ANY = 0, + FIRST = 1, + LAST = 2, + EXCLUSIVE = 3, + }; + + enum class Volume : int8_t { + NONE = 0, + CTRL = 1, + IND = 2, + MONITOR = 3, + }; + + enum class HardwareAccelerator : int8_t { + NONE = 0, + SIMPLE = 1, + TUNNEL = 2, + }; + + ::aidl::android::hardware::audio::effect::Flags::Type type = ::aidl::android::hardware::audio::effect::Flags::Type::INSERT; + ::aidl::android::hardware::audio::effect::Flags::Insert insert = ::aidl::android::hardware::audio::effect::Flags::Insert::ANY; + ::aidl::android::hardware::audio::effect::Flags::Volume volume = ::aidl::android::hardware::audio::effect::Flags::Volume::NONE; + ::aidl::android::hardware::audio::effect::Flags::HardwareAccelerator hwAcceleratorMode = ::aidl::android::hardware::audio::effect::Flags::HardwareAccelerator::NONE; + bool offloadIndication = false; + bool deviceIndication = false; + bool audioModeIndication = false; + bool audioSourceIndication = false; + bool bypass = false; + bool sinkMetadataIndication = false; + bool sourceMetadataIndication = false; + + inline bool operator==(const Flags& _rhs) const { + return std::tie(type, insert, volume, hwAcceleratorMode, offloadIndication, deviceIndication, audioModeIndication, audioSourceIndication, bypass, sinkMetadataIndication, sourceMetadataIndication) == std::tie(_rhs.type, _rhs.insert, _rhs.volume, _rhs.hwAcceleratorMode, _rhs.offloadIndication, _rhs.deviceIndication, _rhs.audioModeIndication, _rhs.audioSourceIndication, _rhs.bypass, _rhs.sinkMetadataIndication, _rhs.sourceMetadataIndication); + } + inline bool operator<(const Flags& _rhs) const { + return std::tie(type, insert, volume, hwAcceleratorMode, offloadIndication, deviceIndication, audioModeIndication, audioSourceIndication, bypass, sinkMetadataIndication, sourceMetadataIndication) < std::tie(_rhs.type, _rhs.insert, _rhs.volume, _rhs.hwAcceleratorMode, _rhs.offloadIndication, _rhs.deviceIndication, _rhs.audioModeIndication, _rhs.audioSourceIndication, _rhs.bypass, _rhs.sinkMetadataIndication, _rhs.sourceMetadataIndication); + } + inline bool operator!=(const Flags& _rhs) const { + return !(*this == _rhs); + } + inline bool operator>(const Flags& _rhs) const { + return _rhs < *this; + } + inline bool operator>=(const Flags& _rhs) const { + return !(*this < _rhs); + } + inline bool operator<=(const Flags& _rhs) const { + return !(_rhs < *this); + } + }; +} // namespace aidl::android::hardware::audio::effect diff --git a/src/include/aidl/android/hardware/audio/effect/IEffect.h b/src/include/aidl/android/hardware/audio/effect/IEffect.h new file mode 100644 index 0000000..5b8a7f6 --- /dev/null +++ b/src/include/aidl/android/hardware/audio/effect/IEffect.h @@ -0,0 +1,12 @@ +#pragma once + +#include +#include +#include +#include +#include + +namespace aidl::android::hardware::audio::effect { + class IEffect { + }; +} // namespace aidl::android::hardware::audio::effect diff --git a/src/include/aidl/android/media/audio/common/AudioUuid.h b/src/include/aidl/android/media/audio/common/AudioUuid.h new file mode 100644 index 0000000..8f4f170 --- /dev/null +++ b/src/include/aidl/android/media/audio/common/AudioUuid.h @@ -0,0 +1,37 @@ +#pragma once + +#include +#include +#include +#include +#include + +namespace aidl::android::media::audio::common { + class AudioUuid { + public: + int32_t timeLow = 0; + int32_t timeMid = 0; + int32_t timeHiAndVersion = 0; + int32_t clockSeq = 0; + std::vector node; + + inline bool operator==(const AudioUuid& _rhs) const { + return std::tie(timeLow, timeMid, timeHiAndVersion, clockSeq, node) == std::tie(_rhs.timeLow, _rhs.timeMid, _rhs.timeHiAndVersion, _rhs.clockSeq, _rhs.node); + } + inline bool operator<(const AudioUuid& _rhs) const { + return std::tie(timeLow, timeMid, timeHiAndVersion, clockSeq, node) < std::tie(_rhs.timeLow, _rhs.timeMid, _rhs.timeHiAndVersion, _rhs.clockSeq, _rhs.node); + } + inline bool operator!=(const AudioUuid& _rhs) const { + return !(*this == _rhs); + } + inline bool operator>(const AudioUuid& _rhs) const { + return _rhs < *this; + } + inline bool operator>=(const AudioUuid& _rhs) const { + return !(*this < _rhs); + } + inline bool operator<=(const AudioUuid& _rhs) const { + return !(_rhs < *this); + } + }; +} // namespace aidl::android::media::audio::common