From 25fd3faa260ad1c92ac57d71af46eb4d73ff277c Mon Sep 17 00:00:00 2001 From: Jiwen 'Steve' Cai Date: Mon, 20 Mar 2017 15:30:21 -0700 Subject: [PATCH] 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 --- libs/vr/libbufferhubqueue/Android.bp | 6 +++- .../libbufferhubqueue/buffer_hub_queue_client.cpp | 23 ++++++++------- .../buffer_hub_queue_consumer.cpp | 2 -- .../vr/libbufferhubqueue/buffer_hub_queue_core.cpp | 3 -- .../buffer_hub_queue_producer.cpp | 34 ++++++++++------------ 5 files changed, 33 insertions(+), 35 deletions(-) diff --git a/libs/vr/libbufferhubqueue/Android.bp b/libs/vr/libbufferhubqueue/Android.bp index b97609750a..1c8f2c06c7 100644 --- a/libs/vr/libbufferhubqueue/Android.bp +++ b/libs/vr/libbufferhubqueue/Android.bp @@ -42,7 +42,10 @@ sharedLibraries = [ 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 @@ cc_library { 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 a8077b9fe1..bd6511de5a 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 #include #include @@ -73,7 +71,8 @@ std::unique_ptr BufferHubQueue::CreateConsumerQueue() { 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 @@ bool BufferHubQueue::WaitForBuffers(int timeout) { 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 @@ bool BufferHubQueue::WaitForBuffers(int timeout) { for (int i = 0; i < num_events; i++) { int64_t index = static_cast(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(index), events[i]); @@ -255,7 +254,7 @@ std::shared_ptr BufferHubQueue::Dequeue(int timeout, 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 @@ int ProducerQueue::AllocateBuffer(int width, int height, int format, int usage, // 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 @@ int ConsumerQueue::ImportBuffers() { 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 buffer_consumer = BufferConsumer::Import(std::move(buffer_handle_slot.first)); @@ -473,7 +474,7 @@ int ConsumerQueue::OnBufferAllocated() { } 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 02bca09c74..1ea39946e3 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 b013c85b0b..a108042d01 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 namespace android { diff --git a/libs/vr/libbufferhubqueue/buffer_hub_queue_producer.cpp b/libs/vr/libbufferhubqueue/buffer_hub_queue_producer.cpp index 0deb764892..ddf7fd2330 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 #include @@ -14,7 +12,7 @@ BufferHubQueueProducer::BufferHubQueueProducer( status_t BufferHubQueueProducer::requestBuffer(int slot, sp* buf) { - ALOGD("requestBuffer: slot=%d", slot); + ALOGD_IF(TRACE, "requestBuffer: slot=%d", slot); std::unique_lock lock(core_->mutex_); @@ -35,8 +33,8 @@ status_t BufferHubQueueProducer::requestBuffer(int slot, 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 lock(core_->mutex_); @@ -63,8 +61,8 @@ status_t BufferHubQueueProducer::dequeueBuffer(int* out_slot, 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 lock(core_->mutex_); @@ -134,7 +132,7 @@ status_t BufferHubQueueProducer::dequeueBuffer(int* out_slot, 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::attachBuffer( 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; @@ -220,7 +218,7 @@ status_t BufferHubQueueProducer::queueBuffer(int slot, status_t BufferHubQueueProducer::cancelBuffer(int slot, const sp& fence) { - ALOGD(__FUNCTION__); + ALOGD_IF(TRACE, __FUNCTION__); std::unique_lock lock(core_->mutex_); @@ -241,13 +239,13 @@ status_t BufferHubQueueProducer::cancelBuffer(int slot, 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 lock(core_->mutex_); @@ -278,7 +276,7 @@ status_t BufferHubQueueProducer::query(int what, int* out_value) { 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 @@ status_t BufferHubQueueProducer::connect( 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::allowAllocation(bool /* allow */) { status_t BufferHubQueueProducer::setGenerationNumber( uint32_t generation_number) { - ALOGD(__FUNCTION__); + ALOGD_IF(TRACE, __FUNCTION__); std::unique_lock lock(core_->mutex_); core_->generation_number_ = generation_number; @@ -354,7 +352,7 @@ status_t BufferHubQueueProducer::setAutoRefresh(bool /* auto_refresh */) { } status_t BufferHubQueueProducer::setDequeueTimeout(nsecs_t timeout) { - ALOGD(__FUNCTION__); + ALOGD_IF(TRACE, __FUNCTION__); std::unique_lock lock(core_->mutex_); core_->dequeue_timeout_ms_ = static_cast(timeout / (1000 * 1000)); @@ -374,7 +372,7 @@ void BufferHubQueueProducer::getFrameTimestamps( } status_t BufferHubQueueProducer::getUniqueId(uint64_t* out_id) const { - ALOGD(__FUNCTION__); + ALOGD_IF(TRACE, __FUNCTION__); *out_id = core_->unique_id_; return NO_ERROR; -- 2.11.0