Skip to content

Commit b65dd9f

Browse files
committed
Add verbose logging
1 parent d2aeef3 commit b65dd9f

File tree

2 files changed

+80
-16
lines changed

2 files changed

+80
-16
lines changed

src/shim.cpp

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,42 @@ static void init_libcutils() {
2929
}
3030

3131
ashmem_create_region = dlsym(libcutils, "ashmem_create_region");
32+
if (ashmem_create_region == nullptr) {
33+
ALOGE("Failed to load symbol ashmem_create_region from libcutils.so");
34+
goto exit;
35+
}
36+
3237
ashmem_set_prot_region = dlsym(libcutils, "ashmem_set_prot_region");
38+
if (ashmem_set_prot_region == nullptr) {
39+
ALOGE("Failed to load symbol ashmem_set_prot_region from libcutils.so");
40+
goto exit;
41+
}
3342

3443
native_handle_create = dlsym(libcutils, "native_handle_create");
44+
if (native_handle_create == nullptr) {
45+
ALOGE("Failed to load symbol native_handle_create from libcutils.so");
46+
goto exit;
47+
}
48+
3549
native_handle_close = dlsym(libcutils, "native_handle_close");
36-
native_handle_delete = dlsym(libcutils, "native_handle_delete");
50+
if (native_handle_close == nullptr) {
51+
ALOGE("Failed to load symbol native_handle_close from libcutils.so");
52+
goto exit;
53+
}
3754

38-
if (ashmem_create_region == nullptr ||
39-
ashmem_set_prot_region == nullptr ||
40-
native_handle_create == nullptr ||
41-
native_handle_close == nullptr ||
42-
native_handle_delete == nullptr) {
43-
ALOGE("Failed to load symbols from libcutils.so");
55+
native_handle_delete = dlsym(libcutils, "native_handle_delete");
56+
if (native_handle_delete == nullptr) {
57+
ALOGE("Failed to load symbol native_handle_delete from libcutils.so");
58+
goto exit;
4459
}
4560

61+
ALOGD("ashmem_create_region: %p", ashmem_create_region);
62+
ALOGD("ashmem_set_prot_region: %p", ashmem_set_prot_region);
63+
ALOGD("native_handle_create: %p", native_handle_create);
64+
ALOGD("native_handle_close: %p", native_handle_close);
65+
ALOGD("native_handle_delete: %p", native_handle_delete);
66+
67+
exit:
4668
dlclose(libcutils);
4769
}
4870

@@ -54,26 +76,42 @@ static void init_libfmq() {
5476
}
5577

5678
_ZN7android8hardware7details5checkEbPKc = dlsym(libfmq, "_ZN7android8hardware7details5checkEbPKc");
79+
if (_ZN7android8hardware7details5checkEbPKc == nullptr) {
80+
ALOGE("Failed to load symbol _ZN7android8hardware7details5checkEbPKc from libfmq.so");
81+
goto exit;
82+
}
83+
5784
// ndk variant, real symbol: _ZN7android8hardware7details8logErrorERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE
5885
_ZN7android8hardware7details8logErrorERKNSt6__ndk112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE = dlsym(libfmq, "_ZN7android8hardware7details8logErrorERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE");
86+
if (_ZN7android8hardware7details8logErrorERKNSt6__ndk112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE == nullptr) {
87+
ALOGE("Failed to load symbol _ZN7android8hardware7details8logErrorERKNSt6__ndk112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE from libfmq.so");
88+
goto exit;
89+
}
90+
5991
// ndk variant, real symbol: _ZN7android8hardware9EventFlag15createEventFlagEPNSt3__16atomicIjEEPPS1_
6092
_ZN7android8hardware9EventFlag15createEventFlagEPNSt6__ndk16atomicIjEEPPS1_ = dlsym(libfmq, "_ZN7android8hardware9EventFlag15createEventFlagEPNSt3__16atomicIjEEPPS1_");
61-
_ZN7android8hardware9EventFlag15deleteEventFlagEPPS1_ = dlsym(libfmq, "_ZN7android8hardware9EventFlag15deleteEventFlagEPPS1_");
93+
if (_ZN7android8hardware9EventFlag15createEventFlagEPNSt6__ndk16atomicIjEEPPS1_ == nullptr) {
94+
ALOGE("Failed to load symbol _ZN7android8hardware9EventFlag15createEventFlagEPNSt3__16atomicIjEEPPS1_ from libfmq.so");
95+
goto exit;
96+
}
6297

63-
if (_ZN7android8hardware7details5checkEbPKc == nullptr ||
64-
_ZN7android8hardware7details8logErrorERKNSt6__ndk112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE == nullptr ||
65-
_ZN7android8hardware9EventFlag15createEventFlagEPNSt6__ndk16atomicIjEEPPS1_ == nullptr ||
66-
_ZN7android8hardware9EventFlag15deleteEventFlagEPPS1_ == nullptr) {
67-
ALOGE("Failed to load symbols from libfmq.so");
98+
_ZN7android8hardware9EventFlag15deleteEventFlagEPPS1_ = dlsym(libfmq, "_ZN7android8hardware9EventFlag15deleteEventFlagEPPS1_");
99+
if (_ZN7android8hardware9EventFlag15deleteEventFlagEPPS1_ == nullptr) {
100+
ALOGE("Failed to load symbol _ZN7android8hardware9EventFlag15deleteEventFlagEPPS1_ from libfmq.so");
101+
goto exit;
68102
}
69103

104+
ALOGD("_ZN7android8hardware7details5checkEbPKc: %p", _ZN7android8hardware7details5checkEbPKc);
105+
ALOGD("_ZN7android8hardware7details8logErrorERKNSt6__ndk112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE: %p", _ZN7android8hardware7details8logErrorERKNSt6__ndk112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE);
106+
ALOGD("_ZN7android8hardware9EventFlag15createEventFlagEPNSt6__ndk16atomicIjEEPPS1_: %p", _ZN7android8hardware9EventFlag15createEventFlagEPNSt6__ndk16atomicIjEEPPS1_);
107+
ALOGD("_ZN7android8hardware9EventFlag15deleteEventFlagEPPS1_: %p", _ZN7android8hardware9EventFlag15deleteEventFlagEPPS1_);
108+
109+
exit:
70110
dlclose(libfmq);
71111
}
72112

73113
__attribute__((constructor))
74114
void shim_init() {
75-
ALOGD("shim_init");
76115
init_libcutils();
77116
init_libfmq();
78-
ALOGD("shim_init done");
79117
}

src/viper_aidl.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,17 @@ constexpr size_t getFrameSizeInBytes(
129129
ndk::ScopedAStatus ViPER4AndroidAIDL::open(const Parameter::Common &common,
130130
const std::optional<Parameter::Specific> &specific,
131131
IEffect::OpenEffectReturn *ret) {
132-
if (common.input.base.format.pcm != PcmType::FLOAT_32_BIT) {
132+
ALOGD("open called");
133+
if (common.input.base.format.pcm != PcmType::FLOAT_32_BIT ||
134+
common.output.base.format.pcm != PcmType::FLOAT_32_BIT) {
133135
ALOGE("open called with invalid PCM type");
134136
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
135137
}
136138

137139
std::lock_guard lg(mImplMutex);
138140

141+
ALOGD("mImplMutex locked");
142+
139143
if (mState != State::INIT) {
140144
ALOGD("open: already opened");
141145
return ndk::ScopedAStatus::ok();
@@ -149,11 +153,23 @@ ndk::ScopedAStatus ViPER4AndroidAIDL::open(const Parameter::Common &common,
149153
size_t inBufferSizeInFloat = common.input.frameCount * mInputFrameSize / sizeof(float);
150154
size_t outBufferSizeInFloat = common.output.frameCount * mOutputFrameSize / sizeof(float);
151155

156+
ALOGD("open: inBufferSizeInFloat %zu, outBufferSizeInFloat %zu", inBufferSizeInFloat,
157+
outBufferSizeInFloat);
158+
152159
// only status FMQ use the EventFlag
153160
mStatusMQ = std::make_shared<StatusMQ>(1, true /*configureEventFlagWord*/);
154161
mInputMQ = std::make_shared<DataMQ>(inBufferSizeInFloat);
155162
mOutputMQ = std::make_shared<DataMQ>(outBufferSizeInFloat);
156163

164+
if (!mStatusMQ || !mInputMQ || !mOutputMQ) {
165+
ALOGE("open: failed to create message queues");
166+
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
167+
}
168+
169+
ALOGD("message queues created");
170+
ALOGD("open: mStatusMQ %p, mInputMQ %p, mOutputMQ %p", mStatusMQ.get(), mInputMQ.get(),
171+
mOutputMQ.get());
172+
157173
if (!mStatusMQ->isValid() || !mInputMQ->isValid() || !mOutputMQ->isValid()) {
158174
ALOGE("open: failed to create message queues");
159175
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
@@ -166,23 +182,33 @@ ndk::ScopedAStatus ViPER4AndroidAIDL::open(const Parameter::Common &common,
166182
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
167183
}
168184

185+
ALOGD("open: event flag created");
186+
169187
mWorkBuffer.resize(std::max(inBufferSizeInFloat, outBufferSizeInFloat));
170188

189+
ALOGD("open: work buffer size %zu", mWorkBuffer.size());
190+
171191
if (specific.has_value()) {
172192
ALOGD("open: specific parameters provided, ignoring for now...");
173193
}
174194

175195
mState = State::IDLE;
176196

197+
ALOGD("open: state set to IDLE");
198+
177199
ret->statusMQ = mStatusMQ->dupeDesc();
178200
ret->inputDataMQ = mInputMQ->dupeDesc();
179201
ret->outputDataMQ = mOutputMQ->dupeDesc();
180202

203+
ALOGD("open: mq descriptors set");
204+
181205
if (createThread(VIPER_NAME) != RetCode::SUCCESS) {
182206
ALOGE("open: failed to create thread");
183207
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
184208
}
185209

210+
ALOGD("open: thread created");
211+
186212
return ndk::ScopedAStatus::ok();
187213
}
188214

0 commit comments

Comments
 (0)