Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 25fd3faa authored by Jiwen 'Steve' Cai's avatar Jiwen 'Steve' Cai
Browse files

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
parent b0ae9c12
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -42,7 +42,10 @@ sharedLibraries = [


cc_library {
cc_library {
    name: "libbufferhubqueue",
    name: "libbufferhubqueue",
    cflags = [ "-DLOGTAG=\"libbufferhubqueue\"" ],
    cflags = [
        "-DLOGTAG=\"libbufferhubqueue\"",
        "-DTRACE=0",
    ],
    srcs: sourceFiles,
    srcs: sourceFiles,
    export_include_dirs: includeFiles,
    export_include_dirs: includeFiles,
    export_static_lib_headers: staticLibraries,
    export_static_lib_headers: staticLibraries,
@@ -50,3 +53,4 @@ cc_library {
    shared_libs: sharedLibraries,
    shared_libs: sharedLibraries,
}
}


subdirs = ["tests"]
+12 −11
Original line number Original line Diff line number Diff line
#include "include/private/dvr/buffer_hub_queue_client.h"
#include "include/private/dvr/buffer_hub_queue_client.h"


//#define LOG_NDEBUG 0

#include <inttypes.h>
#include <inttypes.h>
#include <log/log.h>
#include <log/log.h>
#include <sys/epoll.h>
#include <sys/epoll.h>
@@ -73,7 +71,8 @@ std::unique_ptr<ConsumerQueue> BufferHubQueue::CreateConsumerQueue() {


  auto return_value = status.take();
  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 ConsumerQueue::Create(std::move(return_value.first),
                               return_value.second);
                               return_value.second);
}
}
@@ -85,7 +84,7 @@ bool BufferHubQueue::WaitForBuffers(int timeout) {
    int ret = epoll_fd_.Wait(events.data(), events.size(), timeout);
    int ret = epoll_fd_.Wait(events.data(), events.size(), timeout);


    if (ret == 0) {
    if (ret == 0) {
      ALOGD("Wait on epoll returns nothing before timeout.");
      ALOGD_IF(TRACE, "Wait on epoll returns nothing before timeout.");
      return false;
      return false;
    }
    }


@@ -102,7 +101,7 @@ bool BufferHubQueue::WaitForBuffers(int timeout) {
    for (int i = 0; i < num_events; i++) {
    for (int i = 0; i < num_events; i++) {
      int64_t index = static_cast<int64_t>(events[i].data.u64);
      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)) {
      if (is_buffer_event_index(index)) {
        HandleBufferEvent(static_cast<size_t>(index), events[i]);
        HandleBufferEvent(static_cast<size_t>(index), events[i]);
@@ -255,7 +254,7 @@ std::shared_ptr<BufferHubBuffer> BufferHubQueue::Dequeue(int timeout,
                                                         size_t* slot,
                                                         size_t* slot,
                                                         void* meta,
                                                         void* meta,
                                                         LocalHandle* fence) {
                                                         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))
  if (count() == 0 && !WaitForBuffers(timeout))
    return nullptr;
    return nullptr;
@@ -341,7 +340,8 @@ int ProducerQueue::AllocateBuffer(int width, int height, int format, int usage,
  // We only allocate one buffer at a time.
  // We only allocate one buffer at a time.
  auto& buffer_handle = buffer_handle_slots[0].first;
  auto& buffer_handle = buffer_handle_slots[0].first;
  size_t buffer_slot = buffer_handle_slots[0].second;
  size_t buffer_slot = buffer_handle_slots[0].second;
  ALOGD("ProducerQueue::AllocateBuffer, new buffer, channel_handle: %d",
  ALOGD_IF(TRACE,
           "ProducerQueue::AllocateBuffer, new buffer, channel_handle: %d",
           buffer_handle.value());
           buffer_handle.value());


  *out_slot = buffer_slot;
  *out_slot = buffer_slot;
@@ -414,7 +414,8 @@ int ConsumerQueue::ImportBuffers() {


  auto buffer_handle_slots = status.take();
  auto buffer_handle_slots = status.take();
  for (auto& buffer_handle_slot : buffer_handle_slots) {
  for (auto& buffer_handle_slot : buffer_handle_slots) {
    ALOGD("ConsumerQueue::ImportBuffers, new buffer, buffer_handle: %d",
    ALOGD_IF(TRACE,
             "ConsumerQueue::ImportBuffers, new buffer, buffer_handle: %d",
             buffer_handle_slot.first.value());
             buffer_handle_slot.first.value());


    std::unique_ptr<BufferConsumer> buffer_consumer =
    std::unique_ptr<BufferConsumer> buffer_consumer =
@@ -473,7 +474,7 @@ int ConsumerQueue::OnBufferAllocated() {
  } else if (ret < 0) {
  } else if (ret < 0) {
    ALOGE("Failed to import buffers on buffer allocated event.");
    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;
  return ret;
}
}


+0 −2
Original line number Original line Diff line number Diff line
#include "include/private/dvr/buffer_hub_queue_consumer.h"
#include "include/private/dvr/buffer_hub_queue_consumer.h"


//#define LOG_NDEBUG 0

namespace android {
namespace android {
namespace dvr {
namespace dvr {


+0 −3
Original line number Original line Diff line number Diff line
#include "include/private/dvr/buffer_hub_queue_core.h"
#include "include/private/dvr/buffer_hub_queue_core.h"


//#define LOG_NDEBUG 0
#define LOG_TAG "BufferHubQueueCore"

#include <log/log.h>
#include <log/log.h>


namespace android {
namespace android {
+16 −18
Original line number Original line Diff line number Diff line
#include "include/private/dvr/buffer_hub_queue_producer.h"
#include "include/private/dvr/buffer_hub_queue_producer.h"


//#define LOG_NDEBUG 0

#include <inttypes.h>
#include <inttypes.h>
#include <log/log.h>
#include <log/log.h>


@@ -14,7 +12,7 @@ BufferHubQueueProducer::BufferHubQueueProducer(


status_t BufferHubQueueProducer::requestBuffer(int slot,
status_t BufferHubQueueProducer::requestBuffer(int slot,
                                               sp<GraphicBuffer>* buf) {
                                               sp<GraphicBuffer>* buf) {
  ALOGD("requestBuffer: slot=%d", slot);
  ALOGD_IF(TRACE, "requestBuffer: slot=%d", slot);


  std::unique_lock<std::mutex> lock(core_->mutex_);
  std::unique_lock<std::mutex> lock(core_->mutex_);


@@ -35,7 +33,7 @@ status_t BufferHubQueueProducer::requestBuffer(int slot,


status_t BufferHubQueueProducer::setMaxDequeuedBufferCount(
status_t BufferHubQueueProducer::setMaxDequeuedBufferCount(
    int max_dequeued_buffers) {
    int max_dequeued_buffers) {
  ALOGD("setMaxDequeuedBufferCount: max_dequeued_buffers=%d",
  ALOGD_IF(TRACE, "setMaxDequeuedBufferCount: max_dequeued_buffers=%d",
           max_dequeued_buffers);
           max_dequeued_buffers);


  std::unique_lock<std::mutex> lock(core_->mutex_);
  std::unique_lock<std::mutex> lock(core_->mutex_);
@@ -63,8 +61,8 @@ status_t BufferHubQueueProducer::dequeueBuffer(int* out_slot,
                                               PixelFormat format,
                                               PixelFormat format,
                                               uint32_t usage,
                                               uint32_t usage,
                                               FrameEventHistoryDelta* /* outTimestamps */) {
                                               FrameEventHistoryDelta* /* outTimestamps */) {
  ALOGD("dequeueBuffer: w=%u, h=%u, format=%d, usage=%u", width, height, format,
  ALOGD_IF(TRACE, "dequeueBuffer: w=%u, h=%u, format=%d, usage=%u", width,
        usage);
           height, format, usage);


  status_t ret;
  status_t ret;
  std::unique_lock<std::mutex> lock(core_->mutex_);
  std::unique_lock<std::mutex> lock(core_->mutex_);
@@ -134,7 +132,7 @@ status_t BufferHubQueueProducer::dequeueBuffer(int* out_slot,


  core_->buffers_[slot].mBufferState.freeQueued();
  core_->buffers_[slot].mBufferState.freeQueued();
  core_->buffers_[slot].mBufferState.dequeue();
  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
  // TODO(jwcai) Handle fence properly. |BufferHub| has full fence support, we
  // just need to exopose that through |BufferHubQueue| once we need fence.
  // 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,
status_t BufferHubQueueProducer::queueBuffer(int slot,
                                             const QueueBufferInput& input,
                                             const QueueBufferInput& input,
                                             QueueBufferOutput* /* output */) {
                                             QueueBufferOutput* /* output */) {
  ALOGD("queueBuffer: slot %d", slot);
  ALOGD_IF(TRACE, "queueBuffer: slot %d", slot);


  int64_t timestamp;
  int64_t timestamp;
  sp<Fence> fence;
  sp<Fence> fence;
@@ -220,7 +218,7 @@ status_t BufferHubQueueProducer::queueBuffer(int slot,


status_t BufferHubQueueProducer::cancelBuffer(int slot,
status_t BufferHubQueueProducer::cancelBuffer(int slot,
                                              const sp<Fence>& fence) {
                                              const sp<Fence>& fence) {
  ALOGD(__FUNCTION__);
  ALOGD_IF(TRACE, __FUNCTION__);


  std::unique_lock<std::mutex> lock(core_->mutex_);
  std::unique_lock<std::mutex> lock(core_->mutex_);


@@ -241,13 +239,13 @@ status_t BufferHubQueueProducer::cancelBuffer(int slot,
  core_->producer_->Enqueue(buffer_producer, slot);
  core_->producer_->Enqueue(buffer_producer, slot);
  core_->buffers_[slot].mBufferState.cancel();
  core_->buffers_[slot].mBufferState.cancel();
  core_->buffers_[slot].mFence = fence;
  core_->buffers_[slot].mFence = fence;
  ALOGD("cancelBuffer: slot %d", slot);
  ALOGD_IF(TRACE, "cancelBuffer: slot %d", slot);


  return NO_ERROR;
  return NO_ERROR;
}
}


status_t BufferHubQueueProducer::query(int what, int* out_value) {
status_t BufferHubQueueProducer::query(int what, int* out_value) {
  ALOGD(__FUNCTION__);
  ALOGD_IF(TRACE, __FUNCTION__);


  std::unique_lock<std::mutex> lock(core_->mutex_);
  std::unique_lock<std::mutex> lock(core_->mutex_);


@@ -278,7 +276,7 @@ status_t BufferHubQueueProducer::query(int what, int* out_value) {
      return BAD_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;
  *out_value = value;
  return NO_ERROR;
  return NO_ERROR;
}
}
@@ -288,14 +286,14 @@ status_t BufferHubQueueProducer::connect(
    bool /* producer_controlled_by_app */, QueueBufferOutput* /* output */) {
    bool /* producer_controlled_by_app */, QueueBufferOutput* /* output */) {
  // Consumer interaction are actually handled by buffer hub, and we need
  // Consumer interaction are actually handled by buffer hub, and we need
  // to maintain consumer operations here. Hence |connect| is a NO-OP.
  // to maintain consumer operations here. Hence |connect| is a NO-OP.
  ALOGD(__FUNCTION__);
  ALOGD_IF(TRACE, __FUNCTION__);
  return NO_ERROR;
  return NO_ERROR;
}
}


status_t BufferHubQueueProducer::disconnect(int /* api */, DisconnectMode /* mode */) {
status_t BufferHubQueueProducer::disconnect(int /* api */, DisconnectMode /* mode */) {
  // Consumer interaction are actually handled by buffer hub, and we need
  // Consumer interaction are actually handled by buffer hub, and we need
  // to maintain consumer operations here. Hence |disconnect| is a NO-OP.
  // to maintain consumer operations here. Hence |disconnect| is a NO-OP.
  ALOGD(__FUNCTION__);
  ALOGD_IF(TRACE, __FUNCTION__);
  return NO_ERROR;
  return NO_ERROR;
}
}


@@ -327,7 +325,7 @@ status_t BufferHubQueueProducer::allowAllocation(bool /* allow */) {


status_t BufferHubQueueProducer::setGenerationNumber(
status_t BufferHubQueueProducer::setGenerationNumber(
    uint32_t generation_number) {
    uint32_t generation_number) {
  ALOGD(__FUNCTION__);
  ALOGD_IF(TRACE, __FUNCTION__);


  std::unique_lock<std::mutex> lock(core_->mutex_);
  std::unique_lock<std::mutex> lock(core_->mutex_);
  core_->generation_number_ = generation_number;
  core_->generation_number_ = generation_number;
@@ -354,7 +352,7 @@ status_t BufferHubQueueProducer::setAutoRefresh(bool /* auto_refresh */) {
}
}


status_t BufferHubQueueProducer::setDequeueTimeout(nsecs_t timeout) {
status_t BufferHubQueueProducer::setDequeueTimeout(nsecs_t timeout) {
  ALOGD(__FUNCTION__);
  ALOGD_IF(TRACE, __FUNCTION__);


  std::unique_lock<std::mutex> lock(core_->mutex_);
  std::unique_lock<std::mutex> lock(core_->mutex_);
  core_->dequeue_timeout_ms_ = static_cast<int>(timeout / (1000 * 1000));
  core_->dequeue_timeout_ms_ = static_cast<int>(timeout / (1000 * 1000));
@@ -374,7 +372,7 @@ void BufferHubQueueProducer::getFrameTimestamps(
}
}


status_t BufferHubQueueProducer::getUniqueId(uint64_t* out_id) const {
status_t BufferHubQueueProducer::getUniqueId(uint64_t* out_id) const {
  ALOGD(__FUNCTION__);
  ALOGD_IF(TRACE, __FUNCTION__);


  *out_id = core_->unique_id_;
  *out_id = core_->unique_id_;
  return NO_ERROR;
  return NO_ERROR;