summaryrefslogtreecommitdiff
path: root/libs/gui/BufferQueueConsumer.cpp
diff options
context:
space:
mode:
author Dan Stoza <stoza@google.com> 2014-03-28 15:34:33 -0700
committer Dan Stoza <stoza@google.com> 2014-04-15 10:34:10 -0700
commit99b18b447dec188bcec37b415603b9dd400fc7e1 (patch)
tree7e18575b5e52cffe647323f7e26ea075978a66e6 /libs/gui/BufferQueueConsumer.cpp
parentd9822a3843017444364899afc3c23fb5be6b9cb9 (diff)
BufferQueue: Add StreamSplitter
Adds a StreamSplitter class, that takes one IGraphicBufferConsumer interface and multiple IGraphicBufferProducer interfaces and implements a one-to-many broadcast of GraphicBuffers (while managing fences correctly). Change-Id: I38ecdf3e311ac521bc781c30dde0cc382a4376a3
Diffstat (limited to 'libs/gui/BufferQueueConsumer.cpp')
-rw-r--r--libs/gui/BufferQueueConsumer.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/libs/gui/BufferQueueConsumer.cpp b/libs/gui/BufferQueueConsumer.cpp
index 995ed5e817..e811ee0be6 100644
--- a/libs/gui/BufferQueueConsumer.cpp
+++ b/libs/gui/BufferQueueConsumer.cpp
@@ -243,11 +243,27 @@ status_t BufferQueueConsumer::attachBuffer(int* outSlot,
mSlots[*outSlot].mGraphicBuffer = buffer;
mSlots[*outSlot].mBufferState = BufferSlot::ACQUIRED;
mSlots[*outSlot].mAttachedByConsumer = true;
- mSlots[*outSlot].mAcquireCalled = true;
mSlots[*outSlot].mNeedsCleanupOnRelease = false;
mSlots[*outSlot].mFence = Fence::NO_FENCE;
mSlots[*outSlot].mFrameNumber = 0;
+ // mAcquireCalled tells BufferQueue that it doesn't need to send a valid
+ // GraphicBuffer pointer on the next acquireBuffer call, which decreases
+ // Binder traffic by not un/flattening the GraphicBuffer. However, it
+ // requires that the consumer maintain a cached copy of the slot <--> buffer
+ // mappings, which is why the consumer doesn't need the valid pointer on
+ // acquire.
+ //
+ // The StreamSplitter is one of the primary users of the attach/detach
+ // logic, and while it is running, all buffers it acquires are immediately
+ // detached, and all buffers it eventually releases are ones that were
+ // attached (as opposed to having been obtained from acquireBuffer), so it
+ // doesn't make sense to maintain the slot/buffer mappings, which would
+ // become invalid for every buffer during detach/attach. By setting this to
+ // false, the valid GraphicBuffer pointer will always be sent with acquire
+ // for attached buffers.
+ mSlots[*outSlot].mAcquireCalled = false;
+
return NO_ERROR;
}