libbufferhubqueue: sanitize logs and Android.bp
1/ Use ALOGD_IF(TRACE, "xxx") and proper clags to enable/display verbose
debugging message.
2/ Make sure that tests targets are visible to Soong.
Bug: 36446316
Test: Built and ran libbufferhubqueue_test, no more spam.
Change-Id: I1b7fc5410dc0c07d8edb6d9cf788e6e5f97afd14
diff --git a/libs/vr/libbufferhubqueue/Android.bp b/libs/vr/libbufferhubqueue/Android.bp
index b976097..1c8f2c0 100644
--- a/libs/vr/libbufferhubqueue/Android.bp
+++ b/libs/vr/libbufferhubqueue/Android.bp
@@ -42,7 +42,10 @@
cc_library {
name: "libbufferhubqueue",
- cflags = [ "-DLOGTAG=\"libbufferhubqueue\"" ],
+ cflags = [
+ "-DLOGTAG=\"libbufferhubqueue\"",
+ "-DTRACE=0",
+ ],
srcs: sourceFiles,
export_include_dirs: includeFiles,
export_static_lib_headers: staticLibraries,
@@ -50,3 +53,4 @@
shared_libs: sharedLibraries,
}
+subdirs = ["tests"]
diff --git a/libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp b/libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp
index a8077b9..bd6511d 100644
--- a/libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp
+++ b/libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp
@@ -1,7 +1,5 @@
#include "include/private/dvr/buffer_hub_queue_client.h"
-//#define LOG_NDEBUG 0
-
#include <inttypes.h>
#include <log/log.h>
#include <sys/epoll.h>
@@ -73,7 +71,8 @@
auto return_value = status.take();
- ALOGD("CreateConsumerQueue: meta_size_bytes=%zu", return_value.second);
+ ALOGD_IF(TRACE, "BufferHubQueue::CreateConsumerQueue: meta_size_bytes=%zu",
+ return_value.second);
return ConsumerQueue::Create(std::move(return_value.first),
return_value.second);
}
@@ -85,7 +84,7 @@
int ret = epoll_fd_.Wait(events.data(), events.size(), timeout);
if (ret == 0) {
- ALOGD("Wait on epoll returns nothing before timeout.");
+ ALOGD_IF(TRACE, "Wait on epoll returns nothing before timeout.");
return false;
}
@@ -102,7 +101,7 @@
for (int i = 0; i < num_events; i++) {
int64_t index = static_cast<int64_t>(events[i].data.u64);
- ALOGD("New BufferHubQueue event %d: index=%" PRId64, i, index);
+ ALOGD_IF(TRACE, "New BufferHubQueue event %d: index=%" PRId64, i, index);
if (is_buffer_event_index(index)) {
HandleBufferEvent(static_cast<size_t>(index), events[i]);
@@ -255,7 +254,7 @@
size_t* slot,
void* meta,
LocalHandle* fence) {
- ALOGD("Dequeue: count=%zu, timeout=%d", count(), timeout);
+ ALOGD_IF(TRACE, "Dequeue: count=%zu, timeout=%d", count(), timeout);
if (count() == 0 && !WaitForBuffers(timeout))
return nullptr;
@@ -341,8 +340,9 @@
// We only allocate one buffer at a time.
auto& buffer_handle = buffer_handle_slots[0].first;
size_t buffer_slot = buffer_handle_slots[0].second;
- ALOGD("ProducerQueue::AllocateBuffer, new buffer, channel_handle: %d",
- buffer_handle.value());
+ ALOGD_IF(TRACE,
+ "ProducerQueue::AllocateBuffer, new buffer, channel_handle: %d",
+ buffer_handle.value());
*out_slot = buffer_slot;
return AddBuffer(BufferProducer::Import(std::move(buffer_handle)),
@@ -414,8 +414,9 @@
auto buffer_handle_slots = status.take();
for (auto& buffer_handle_slot : buffer_handle_slots) {
- ALOGD("ConsumerQueue::ImportBuffers, new buffer, buffer_handle: %d",
- buffer_handle_slot.first.value());
+ ALOGD_IF(TRACE,
+ "ConsumerQueue::ImportBuffers, new buffer, buffer_handle: %d",
+ buffer_handle_slot.first.value());
std::unique_ptr<BufferConsumer> buffer_consumer =
BufferConsumer::Import(std::move(buffer_handle_slot.first));
@@ -473,7 +474,7 @@
} else if (ret < 0) {
ALOGE("Failed to import buffers on buffer allocated event.");
}
- ALOGD("Imported %d consumer buffers.", ret);
+ ALOGD_IF(TRACE, "Imported %d consumer buffers.", ret);
return ret;
}
diff --git a/libs/vr/libbufferhubqueue/buffer_hub_queue_consumer.cpp b/libs/vr/libbufferhubqueue/buffer_hub_queue_consumer.cpp
index 02bca09..1ea3994 100644
--- a/libs/vr/libbufferhubqueue/buffer_hub_queue_consumer.cpp
+++ b/libs/vr/libbufferhubqueue/buffer_hub_queue_consumer.cpp
@@ -1,7 +1,5 @@
#include "include/private/dvr/buffer_hub_queue_consumer.h"
-//#define LOG_NDEBUG 0
-
namespace android {
namespace dvr {
diff --git a/libs/vr/libbufferhubqueue/buffer_hub_queue_core.cpp b/libs/vr/libbufferhubqueue/buffer_hub_queue_core.cpp
index b013c85..a108042 100644
--- a/libs/vr/libbufferhubqueue/buffer_hub_queue_core.cpp
+++ b/libs/vr/libbufferhubqueue/buffer_hub_queue_core.cpp
@@ -1,8 +1,5 @@
#include "include/private/dvr/buffer_hub_queue_core.h"
-//#define LOG_NDEBUG 0
-#define LOG_TAG "BufferHubQueueCore"
-
#include <log/log.h>
namespace android {
diff --git a/libs/vr/libbufferhubqueue/buffer_hub_queue_producer.cpp b/libs/vr/libbufferhubqueue/buffer_hub_queue_producer.cpp
index 0deb764..ddf7fd2 100644
--- a/libs/vr/libbufferhubqueue/buffer_hub_queue_producer.cpp
+++ b/libs/vr/libbufferhubqueue/buffer_hub_queue_producer.cpp
@@ -1,7 +1,5 @@
#include "include/private/dvr/buffer_hub_queue_producer.h"
-//#define LOG_NDEBUG 0
-
#include <inttypes.h>
#include <log/log.h>
@@ -14,7 +12,7 @@
status_t BufferHubQueueProducer::requestBuffer(int slot,
sp<GraphicBuffer>* buf) {
- ALOGD("requestBuffer: slot=%d", slot);
+ ALOGD_IF(TRACE, "requestBuffer: slot=%d", slot);
std::unique_lock<std::mutex> lock(core_->mutex_);
@@ -35,8 +33,8 @@
status_t BufferHubQueueProducer::setMaxDequeuedBufferCount(
int max_dequeued_buffers) {
- ALOGD("setMaxDequeuedBufferCount: max_dequeued_buffers=%d",
- max_dequeued_buffers);
+ ALOGD_IF(TRACE, "setMaxDequeuedBufferCount: max_dequeued_buffers=%d",
+ max_dequeued_buffers);
std::unique_lock<std::mutex> lock(core_->mutex_);
@@ -63,8 +61,8 @@
PixelFormat format,
uint32_t usage,
FrameEventHistoryDelta* /* outTimestamps */) {
- ALOGD("dequeueBuffer: w=%u, h=%u, format=%d, usage=%u", width, height, format,
- usage);
+ ALOGD_IF(TRACE, "dequeueBuffer: w=%u, h=%u, format=%d, usage=%u", width,
+ height, format, usage);
status_t ret;
std::unique_lock<std::mutex> lock(core_->mutex_);
@@ -134,7 +132,7 @@
core_->buffers_[slot].mBufferState.freeQueued();
core_->buffers_[slot].mBufferState.dequeue();
- ALOGD("dequeueBuffer: slot=%zu", slot);
+ ALOGD_IF(TRACE, "dequeueBuffer: slot=%zu", slot);
// TODO(jwcai) Handle fence properly. |BufferHub| has full fence support, we
// just need to exopose that through |BufferHubQueue| once we need fence.
@@ -173,7 +171,7 @@
status_t BufferHubQueueProducer::queueBuffer(int slot,
const QueueBufferInput& input,
QueueBufferOutput* /* output */) {
- ALOGD("queueBuffer: slot %d", slot);
+ ALOGD_IF(TRACE, "queueBuffer: slot %d", slot);
int64_t timestamp;
sp<Fence> fence;
@@ -220,7 +218,7 @@
status_t BufferHubQueueProducer::cancelBuffer(int slot,
const sp<Fence>& fence) {
- ALOGD(__FUNCTION__);
+ ALOGD_IF(TRACE, __FUNCTION__);
std::unique_lock<std::mutex> lock(core_->mutex_);
@@ -241,13 +239,13 @@
core_->producer_->Enqueue(buffer_producer, slot);
core_->buffers_[slot].mBufferState.cancel();
core_->buffers_[slot].mFence = fence;
- ALOGD("cancelBuffer: slot %d", slot);
+ ALOGD_IF(TRACE, "cancelBuffer: slot %d", slot);
return NO_ERROR;
}
status_t BufferHubQueueProducer::query(int what, int* out_value) {
- ALOGD(__FUNCTION__);
+ ALOGD_IF(TRACE, __FUNCTION__);
std::unique_lock<std::mutex> lock(core_->mutex_);
@@ -278,7 +276,7 @@
return BAD_VALUE;
}
- ALOGD("query: key=%d, v=%d", what, value);
+ ALOGD_IF(TRACE, "query: key=%d, v=%d", what, value);
*out_value = value;
return NO_ERROR;
}
@@ -288,14 +286,14 @@
bool /* producer_controlled_by_app */, QueueBufferOutput* /* output */) {
// Consumer interaction are actually handled by buffer hub, and we need
// to maintain consumer operations here. Hence |connect| is a NO-OP.
- ALOGD(__FUNCTION__);
+ ALOGD_IF(TRACE, __FUNCTION__);
return NO_ERROR;
}
status_t BufferHubQueueProducer::disconnect(int /* api */, DisconnectMode /* mode */) {
// Consumer interaction are actually handled by buffer hub, and we need
// to maintain consumer operations here. Hence |disconnect| is a NO-OP.
- ALOGD(__FUNCTION__);
+ ALOGD_IF(TRACE, __FUNCTION__);
return NO_ERROR;
}
@@ -327,7 +325,7 @@
status_t BufferHubQueueProducer::setGenerationNumber(
uint32_t generation_number) {
- ALOGD(__FUNCTION__);
+ ALOGD_IF(TRACE, __FUNCTION__);
std::unique_lock<std::mutex> lock(core_->mutex_);
core_->generation_number_ = generation_number;
@@ -354,7 +352,7 @@
}
status_t BufferHubQueueProducer::setDequeueTimeout(nsecs_t timeout) {
- ALOGD(__FUNCTION__);
+ ALOGD_IF(TRACE, __FUNCTION__);
std::unique_lock<std::mutex> lock(core_->mutex_);
core_->dequeue_timeout_ms_ = static_cast<int>(timeout / (1000 * 1000));
@@ -374,7 +372,7 @@
}
status_t BufferHubQueueProducer::getUniqueId(uint64_t* out_id) const {
- ALOGD(__FUNCTION__);
+ ALOGD_IF(TRACE, __FUNCTION__);
*out_id = core_->unique_id_;
return NO_ERROR;