Skip to content

Commit d23bbdf

Browse files
committed
Add effect boilerplate code
1 parent c5c4810 commit d23bbdf

File tree

4 files changed

+307
-105
lines changed

4 files changed

+307
-105
lines changed

src/ViPER4Android.cpp

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,6 @@
33
#include "essential.h"
44
#include "viper/constants.h"
55
#include "ViperContext.h"
6-
#include "aidl/android/hardware/audio/effect/Descriptor.h"
7-
#include "aidl/android/hardware/audio/effect/Flags.h"
8-
#include "aidl/android/hardware/audio/effect/IEffect.h"
9-
#include "aidl/android/media/audio/common/AudioUuid.h"
10-
#include <android/binder_status.h>
11-
#include <android/binder_auto_utils.h>
12-
#include "viper_aidl.h"
13-
14-
using aidl::android::hardware::audio::effect::Descriptor;
15-
using aidl::android::hardware::audio::effect::Flags;
16-
using aidl::android::hardware::audio::effect::IEffect;
17-
using aidl::android::media::audio::common::AudioUuid;
186

197
extern "C" {
208
struct ViperHandle {
@@ -92,72 +80,6 @@ static int32_t viperLibraryGetDescriptor(const effect_uuid_t *uuid, effect_descr
9280
}
9381
} // extern "C"
9482

95-
extern "C" binder_exception_t createEffect(const AudioUuid *audio_uuid, std::shared_ptr<IEffect> *instance) {
96-
if (audio_uuid == nullptr || instance == nullptr) {
97-
VIPER_LOGE("createEffect called with null arguments");
98-
return EX_ILLEGAL_ARGUMENT;
99-
}
100-
VIPER_LOGD("createEffect called");
101-
*instance = ndk::SharedRefBase::make<ViPER4AndroidAIDL>();
102-
return EX_NONE;
103-
}
104-
105-
extern "C" binder_exception_t destroyEffect(const std::shared_ptr<IEffect> &instanceSp) {
106-
VIPER_LOGD("destroyEffect called");
107-
return EX_ILLEGAL_STATE;
108-
}
109-
110-
inline AudioUuid stringToUuid(const char* str) {
111-
AudioUuid uuid{};
112-
uint32_t tmp[10];
113-
if (!str || sscanf(str, "%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x", tmp,
114-
tmp + 1, tmp + 2, tmp + 3, tmp + 4, tmp + 5, tmp + 6,
115-
tmp + 7, tmp + 8, tmp + 9) < 10) {
116-
return uuid;
117-
}
118-
119-
uuid.timeLow = (uint32_t)tmp[0];
120-
uuid.timeMid = (uint16_t)tmp[1];
121-
uuid.timeHiAndVersion = (uint16_t)tmp[2];
122-
uuid.clockSeq = (uint16_t)tmp[3];
123-
uuid.node.insert(uuid.node.end(), {(uint8_t)tmp[4], (uint8_t)tmp[5], (uint8_t)tmp[6],
124-
(uint8_t)tmp[7], (uint8_t)tmp[8], (uint8_t)tmp[9]});
125-
return uuid;
126-
}
127-
128-
const AudioUuid kType = stringToUuid("b9bc100c-26cd-42e6-acb6-cad8c3f778de");
129-
const AudioUuid kUuid = stringToUuid("90380da3-8536-4744-a6a3-5731970e640f");
130-
const Descriptor kDescriptor = {
131-
.common = {
132-
.id = {
133-
.type = kType,
134-
.uuid = kUuid,
135-
.proxy = std::nullopt
136-
},
137-
.flags = {
138-
.type = Flags::Type::INSERT,
139-
.insert = Flags::Insert::LAST,
140-
.volume = Flags::Volume::NONE
141-
},
142-
.name = VIPER_NAME,
143-
.implementor = VIPER_AUTHORS,
144-
},
145-
};
146-
147-
extern "C" binder_exception_t queryEffect(const AudioUuid *audio_uuid, Descriptor *descriptor) {
148-
if (audio_uuid == nullptr || descriptor == nullptr) {
149-
VIPER_LOGE("queryEffect called with null arguments");
150-
return EX_ILLEGAL_ARGUMENT;
151-
}
152-
if (*audio_uuid != kUuid) {
153-
VIPER_LOGE("queryEffect called with invalid uuid");
154-
return EX_ILLEGAL_ARGUMENT;
155-
}
156-
VIPER_LOGD("queryEffect: returning descriptor");
157-
*descriptor = kDescriptor;
158-
return EX_NONE;
159-
}
160-
16183
extern "C"
16284
__attribute__((visibility("default")))
16385
audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = {

src/include/log/log.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* Shim for external dependencies */
2+
#include <android/log.h>

0 commit comments

Comments
 (0)