summaryrefslogtreecommitdiff
path: root/libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp
diff options
context:
space:
mode:
authorTianyu <tianyuj@google.com>2018-09-20 15:57:17 -0700
committerTianyu <tianyuj@google.com>2018-09-20 18:48:49 -0700
commita6e33a1ac51817a9b14c9bf4e63f73ef2619a5bb (patch)
tree20c54371179fa69fb602d283b68ed858724b492c /libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp
parentab19909a2a5ee41950e5685925346b805e6831ae (diff)
Return error when error occurs in buffer allocation.
Previously, the allocate buffer does not return error if it runs out of memory. This change adds the error in returned status. Test: buffer_hub_queue-test passes on Vega on oc-dr1-daydream-dev branch. Test: build and visually check on Vega on oc-dr1-daydream-dev branch. Test: buffer_hub_queue-test passes on Marlin on master branch. Change-Id: Ie226e506ff47d122cd4eef6071b44abedcd4be56
Diffstat (limited to 'libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp')
-rw-r--r--libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp b/libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp
index 1f2c51765d..44276bada0 100644
--- a/libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp
+++ b/libs/vr/libbufferhubqueue/buffer_hub_queue_client.cpp
@@ -440,6 +440,10 @@ ProducerQueue::ProducerQueue(const ProducerQueueConfig& config,
Status<std::vector<size_t>> ProducerQueue::AllocateBuffers(
uint32_t width, uint32_t height, uint32_t layer_count, uint32_t format,
uint64_t usage, size_t buffer_count) {
+ if (buffer_count == 0) {
+ return {std::vector<size_t>()};
+ }
+
if (capacity() + buffer_count > kMaxQueueCapacity) {
ALOGE(
"ProducerQueue::AllocateBuffers: queue is at capacity: %zu, cannot "
@@ -481,10 +485,13 @@ Status<std::vector<size_t>> ProducerQueue::AllocateBuffers(
}
}
- if (buffer_slots.size() == 0) {
- // Error out if no buffer is allocated and improted.
- ALOGE_IF(TRACE, "ProducerQueue::AllocateBuffers: no buffer allocated.");
- ErrorStatus(ENOMEM);
+ if (buffer_slots.size() != buffer_count) {
+ // Error out if the count of imported buffer(s) is not correct.
+ ALOGE(
+ "ProducerQueue::AllocateBuffers: requested to import %zu "
+ "buffers, but actually imported %zu buffers.",
+ buffer_count, buffer_slots.size());
+ return ErrorStatus(ENOMEM);
}
return {std::move(buffer_slots)};
@@ -503,11 +510,6 @@ Status<size_t> ProducerQueue::AllocateBuffer(uint32_t width, uint32_t height,
return status.error_status();
}
- if (status.get().size() == 0) {
- ALOGE_IF(TRACE, "ProducerQueue::AllocateBuffer: no buffer allocated.");
- ErrorStatus(ENOMEM);
- }
-
return {status.get()[0]};
}