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

Commit d0b44732 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "libbufferhubqueue: sanitize logs and Android.bp"

parents e7b70278 25fd3faa
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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"]
+12 −11
Original line number Diff line number Diff line
#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 @@ std::unique_ptr<ConsumerQueue> 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<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 @@ std::shared_ptr<BufferHubBuffer> 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,7 +340,8 @@ 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",
  ALOGD_IF(TRACE,
           "ProducerQueue::AllocateBuffer, new buffer, channel_handle: %d",
           buffer_handle.value());

  *out_slot = buffer_slot;
@@ -414,7 +414,8 @@ 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",
    ALOGD_IF(TRACE,
             "ConsumerQueue::ImportBuffers, new buffer, buffer_handle: %d",
             buffer_handle_slot.first.value());

    std::unique_ptr<BufferConsumer> buffer_consumer =
@@ -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;
}

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

//#define LOG_NDEBUG 0

namespace android {
namespace dvr {

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

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

#include <log/log.h>

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

//#define LOG_NDEBUG 0

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

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

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,7 +33,7 @@ status_t BufferHubQueueProducer::requestBuffer(int slot,

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

  std::unique_lock<std::mutex> 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<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.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> fence;
@@ -220,7 +218,7 @@ status_t BufferHubQueueProducer::queueBuffer(int slot,

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 @@ 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<std::mutex> 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<std::mutex> 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<std::mutex> lock(core_->mutex_);
  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 {
  ALOGD(__FUNCTION__);
  ALOGD_IF(TRACE, __FUNCTION__);

  *out_id = core_->unique_id_;
  return NO_ERROR;