BufferQueueProducer.h revision d6927fb1143398370c0885844bfb58923ef740b7
1289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza/* 2289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza * Copyright 2014 The Android Open Source Project 3289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza * 4289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza * Licensed under the Apache License, Version 2.0 (the "License"); 5289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza * you may not use this file except in compliance with the License. 6289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza * You may obtain a copy of the License at 7289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza * 8289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza * http://www.apache.org/licenses/LICENSE-2.0 9289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza * 10289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza * Unless required by applicable law or agreed to in writing, software 11289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza * distributed under the License is distributed on an "AS IS" BASIS, 12289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza * See the License for the specific language governing permissions and 14289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza * limitations under the License. 15289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza */ 16289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 17289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#ifndef ANDROID_GUI_BUFFERQUEUEPRODUCER_H 18289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#define ANDROID_GUI_BUFFERQUEUEPRODUCER_H 19289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 203e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza#include <gui/BufferQueueDefs.h> 21289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#include <gui/IGraphicBufferProducer.h> 22289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 23289ade165e60b5f71734d30e535f16eb1f4313adDan Stozanamespace android { 24289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 2589702476bb4e450ab8b312f886658728c02f98c0Colin Crossstruct BufferSlot; 26289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 27289ade165e60b5f71734d30e535f16eb1f4313adDan Stozaclass BufferQueueProducer : public BnGraphicBufferProducer, 28289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza private IBinder::DeathRecipient { 29289ade165e60b5f71734d30e535f16eb1f4313adDan Stozapublic: 303e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza friend class BufferQueue; // Needed to access binderDied 313e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 32468051e20be19130572231266db306396a56402bIrvel BufferQueueProducer(const sp<BufferQueueCore>& core, bool consumerIsSurfaceFlinger = false); 33289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza virtual ~BufferQueueProducer(); 34289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 35289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // requestBuffer returns the GraphicBuffer for slot N. 36289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // 37289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // In normal operation, this is called the first time slot N is returned 38289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // by dequeueBuffer. It must be called again if dequeueBuffer returns 39289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // flags indicating that previously-returned buffers are no longer valid. 40289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf); 41289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 42fa455354557f6283ff3a7d76979e52fd251c155fPablo Ceballos // see IGraphicsBufferProducer::setMaxDequeuedBufferCount 43fa455354557f6283ff3a7d76979e52fd251c155fPablo Ceballos virtual status_t setMaxDequeuedBufferCount(int maxDequeuedBuffers); 44fa455354557f6283ff3a7d76979e52fd251c155fPablo Ceballos 45fa455354557f6283ff3a7d76979e52fd251c155fPablo Ceballos // see IGraphicsBufferProducer::setAsyncMode 46fa455354557f6283ff3a7d76979e52fd251c155fPablo Ceballos virtual status_t setAsyncMode(bool async); 47fa455354557f6283ff3a7d76979e52fd251c155fPablo Ceballos 48289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // dequeueBuffer gets the next buffer slot index for the producer to use. 49289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // If a buffer slot is available then that slot index is written to the 50289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // location pointed to by the buf argument and a status of OK is returned. 51289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // If no slot is available then a status of -EBUSY is returned and buf is 52289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // unmodified. 53289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // 54289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // The outFence parameter will be updated to hold the fence associated with 55289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // the buffer. The contents of the buffer must not be overwritten until the 56289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // fence signals. If the fence is Fence::NO_FENCE, the buffer may be 57289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // written immediately. 58289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // 59289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // The width and height parameters must be no greater than the minimum of 60289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv). 61289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // An error due to invalid dimensions might not be reported until 62289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // updateTexImage() is called. If width and height are both zero, the 63289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // default values specified by setDefaultBufferSize() are used instead. 64289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // 653be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza // If the format is 0, the default format will be used. 66289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // 67289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // The usage argument specifies gralloc buffer usage flags. The values 68289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // are enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER. These 69289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // will be merged with the usage flags specified by setConsumerUsageBits. 70289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // 71289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // The return value may be a negative error value or a non-negative 72289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // collection of flags. If the flags are set, the return values are 73289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // valid, but additional actions must be performed. 74289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // 75289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // If IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION is set, the 76289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // producer must discard cached GraphicBuffer references for the slot 77289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // returned in buf. 78289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // If IGraphicBufferProducer::RELEASE_ALL_BUFFERS is set, the producer 79289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // must discard cached GraphicBuffer references for all slots. 80289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // 81289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // In both cases, the producer will need to call requestBuffer to get a 82289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // GraphicBuffer handle for the returned slot. 833be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza virtual status_t dequeueBuffer(int *outSlot, sp<Fence>* outFence, 84567dbbb6dd42be5013fcde0dadb3316d85f2fa0dPablo Ceballos uint32_t width, uint32_t height, PixelFormat format, 853be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza uint32_t usage); 86289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 879f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza // See IGraphicBufferProducer::detachBuffer 889f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza virtual status_t detachBuffer(int slot); 899f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza 90d9822a3843017444364899afc3c23fb5be6b9cb9Dan Stoza // See IGraphicBufferProducer::detachNextBuffer 91d9822a3843017444364899afc3c23fb5be6b9cb9Dan Stoza virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer, 92d9822a3843017444364899afc3c23fb5be6b9cb9Dan Stoza sp<Fence>* outFence); 93d9822a3843017444364899afc3c23fb5be6b9cb9Dan Stoza 949f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza // See IGraphicBufferProducer::attachBuffer 959f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza virtual status_t attachBuffer(int* outSlot, const sp<GraphicBuffer>& buffer); 969f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza 97289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // queueBuffer returns a filled buffer to the BufferQueue. 98289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // 99289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // Additional data is provided in the QueueBufferInput struct. Notably, 100289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // a timestamp must be provided for the buffer. The timestamp is in 101289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // nanoseconds, and must be monotonically increasing. Its other semantics 102289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // (zero point, etc) are producer-specific and should be documented by the 103289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // producer. 104289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // 105289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // The caller may provide a fence that signals when all rendering 106289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // operations have completed. Alternatively, NO_FENCE may be used, 107289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // indicating that the buffer is ready immediately. 108289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // 109289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // Some values are returned in the output struct: the current settings 110289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // for default width and height, the current transform hint, and the 111289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // number of queued buffers. 112289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza virtual status_t queueBuffer(int slot, 113289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza const QueueBufferInput& input, QueueBufferOutput* output); 114289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 115289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // cancelBuffer returns a dequeued buffer to the BufferQueue, but doesn't 116289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // queue it for use by the consumer. 117289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // 118289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // The buffer will not be overwritten until the fence signals. The fence 119289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // will usually be the one obtained from dequeueBuffer. 120583b1b32191992d6ada58b3c61c71932a71c0c4bPablo Ceballos virtual status_t cancelBuffer(int slot, const sp<Fence>& fence); 121289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 122289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // Query native window attributes. The "what" values are enumerated in 123289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // window.h (e.g. NATIVE_WINDOW_FORMAT). 124289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza virtual int query(int what, int* outValue); 125289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 126289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // connect attempts to connect a producer API to the BufferQueue. This 127289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // must be called before any other IGraphicBufferProducer methods are 128289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // called except for getAllocator. A consumer must already be connected. 129289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // 130289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // This method will fail if connect was previously called on the 131289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // BufferQueue and no corresponding disconnect call was made (i.e. if 132289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // it's still connected to a producer). 133289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // 134289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // APIs are enumerated in window.h (e.g. NATIVE_WINDOW_API_CPU). 135f0eaf25e9247edf4d124bedaeb863f7abdf35a3eDan Stoza virtual status_t connect(const sp<IProducerListener>& listener, 136289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza int api, bool producerControlledByApp, QueueBufferOutput* output); 137289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 13897b9c86338e2d364d47ea7522c2d81a8014f0e07Robert Carr // See IGraphicBufferProducer::disconnect 13997b9c86338e2d364d47ea7522c2d81a8014f0e07Robert Carr virtual status_t disconnect(int api, DisconnectMode mode = DisconnectMode::Api); 140289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 141399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall // Attaches a sideband buffer stream to the IGraphicBufferProducer. 142399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall // 143399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall // A sideband stream is a device-specific mechanism for passing buffers 144399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall // from the producer to the consumer without using dequeueBuffer/ 145399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall // queueBuffer. If a sideband stream is present, the consumer can choose 146399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall // whether to acquire buffers from the sideband stream or from the queued 147399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall // buffers. 148399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall // 149399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall // Passing NULL or a different stream handle will detach the previous 150399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall // handle if any. 151399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall virtual status_t setSidebandStream(const sp<NativeHandle>& stream); 152399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall 15329a3e90879fd96404c971e7187cd0e05927bbce0Dan Stoza // See IGraphicBufferProducer::allocateBuffers 154567dbbb6dd42be5013fcde0dadb3316d85f2fa0dPablo Ceballos virtual void allocateBuffers(uint32_t width, uint32_t height, 1553be1c6b60a188dc10025e2ce156c11fac050625dDan Stoza PixelFormat format, uint32_t usage); 15629a3e90879fd96404c971e7187cd0e05927bbce0Dan Stoza 1579de7293b0a1b01ebe6fb1ab4a498f144adc8029fDan Stoza // See IGraphicBufferProducer::allowAllocation 1589de7293b0a1b01ebe6fb1ab4a498f144adc8029fDan Stoza virtual status_t allowAllocation(bool allow); 1599de7293b0a1b01ebe6fb1ab4a498f144adc8029fDan Stoza 160812ed0644f8f8f71ca403f4e5793f0dbc1fcf9b2Dan Stoza // See IGraphicBufferProducer::setGenerationNumber 161812ed0644f8f8f71ca403f4e5793f0dbc1fcf9b2Dan Stoza virtual status_t setGenerationNumber(uint32_t generationNumber); 162812ed0644f8f8f71ca403f4e5793f0dbc1fcf9b2Dan Stoza 163c6f30bdee1f634eb90d68cb76efe935b6535a1e8Dan Stoza // See IGraphicBufferProducer::getConsumerName 164c6f30bdee1f634eb90d68cb76efe935b6535a1e8Dan Stoza virtual String8 getConsumerName() const override; 165c6f30bdee1f634eb90d68cb76efe935b6535a1e8Dan Stoza 1663559fbf93801e2c0d9d8fb246fb9b867a361b464Pablo Ceballos // See IGraphicBufferProducer::setSharedBufferMode 1673559fbf93801e2c0d9d8fb246fb9b867a361b464Pablo Ceballos virtual status_t setSharedBufferMode(bool sharedBufferMode) override; 168127fc63e8a15366b4395f1363e8e18eb058d1709Dan Stoza 169ff95aabbcc6e8606acbd7933c90eeb9b8b382a21Pablo Ceballos // See IGraphicBufferProducer::setAutoRefresh 170ff95aabbcc6e8606acbd7933c90eeb9b8b382a21Pablo Ceballos virtual status_t setAutoRefresh(bool autoRefresh) override; 171ff95aabbcc6e8606acbd7933c90eeb9b8b382a21Pablo Ceballos 172127fc63e8a15366b4395f1363e8e18eb058d1709Dan Stoza // See IGraphicBufferProducer::setDequeueTimeout 173127fc63e8a15366b4395f1363e8e18eb058d1709Dan Stoza virtual status_t setDequeueTimeout(nsecs_t timeout) override; 174ccdfd60d79a8b7f1ed6401d0f2e8e29166a10584Pablo Ceballos 17550101d02a8eae555887282a5f761fdec57bdaf30Dan Stoza // See IGraphicBufferProducer::getLastQueuedBuffer 17650101d02a8eae555887282a5f761fdec57bdaf30Dan Stoza virtual status_t getLastQueuedBuffer(sp<GraphicBuffer>* outBuffer, 1771a61da5e28fa16ad556a58193c8bbeb32a5f636dJohn Reck sp<Fence>* outFence, float outTransformMatrix[16]) override; 17850101d02a8eae555887282a5f761fdec57bdaf30Dan Stoza 179ce796e78a57018f186b062199c75d94545318acaPablo Ceballos // See IGraphicBufferProducer::getFrameTimestamps 180ce796e78a57018f186b062199c75d94545318acaPablo Ceballos virtual bool getFrameTimestamps(uint64_t frameNumber, 181d6927fb1143398370c0885844bfb58923ef740b7Brian Anderson FrameTimestamps* outTimestamps) override; 182ce796e78a57018f186b062199c75d94545318acaPablo Ceballos 1838e3e92b906db431c4fa822f21242977d4ee99942Pablo Ceballos // See IGraphicBufferProducer::getUniqueId 1848e3e92b906db431c4fa822f21242977d4ee99942Pablo Ceballos virtual status_t getUniqueId(uint64_t* outId) const override; 1858e3e92b906db431c4fa822f21242977d4ee99942Pablo Ceballos 186289ade165e60b5f71734d30e535f16eb1f4313adDan Stozaprivate: 187289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // This is required by the IBinder::DeathRecipient interface 188289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza virtual void binderDied(const wp<IBinder>& who); 189289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 1905ecfb68ffd63d352df0392dca6e95ef67a66c679Dan Stoza // Returns the slot of the next free buffer if one is available or 1915ecfb68ffd63d352df0392dca6e95ef67a66c679Dan Stoza // BufferQueueCore::INVALID_BUFFER_SLOT otherwise 1925ecfb68ffd63d352df0392dca6e95ef67a66c679Dan Stoza int getFreeBufferLocked() const; 1935ecfb68ffd63d352df0392dca6e95ef67a66c679Dan Stoza 19423b4abe024ea88c45e0b94c80e1fb537a573b143Pablo Ceballos // Returns the next free slot if one is available or 19523b4abe024ea88c45e0b94c80e1fb537a573b143Pablo Ceballos // BufferQueueCore::INVALID_BUFFER_SLOT otherwise 19623b4abe024ea88c45e0b94c80e1fb537a573b143Pablo Ceballos int getFreeSlotLocked() const; 1975ecfb68ffd63d352df0392dca6e95ef67a66c679Dan Stoza 198d6927fb1143398370c0885844bfb58923ef740b7Brian Anderson bool addAndGetFrameTimestamps( 199d6927fb1143398370c0885844bfb58923ef740b7Brian Anderson const NewFrameEventsEntry* newTimestamps, 200d6927fb1143398370c0885844bfb58923ef740b7Brian Anderson uint64_t frameNumber, FrameTimestamps* outTimestamps); 201d6927fb1143398370c0885844bfb58923ef740b7Brian Anderson 2029f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza // waitForFreeSlotThenRelock finds the oldest slot in the FREE state. It may 2039f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza // block if there are no available slots and we are not in non-blocking 2049f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza // mode (producer and consumer controlled by the application). If it blocks, 2059f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza // it will release mCore->mMutex while blocked so that other operations on 2069f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza // the BufferQueue may succeed. 2075ecfb68ffd63d352df0392dca6e95ef67a66c679Dan Stoza enum class FreeSlotCaller { 2085ecfb68ffd63d352df0392dca6e95ef67a66c679Dan Stoza Dequeue, 2095ecfb68ffd63d352df0392dca6e95ef67a66c679Dan Stoza Attach, 2105ecfb68ffd63d352df0392dca6e95ef67a66c679Dan Stoza }; 21123b4abe024ea88c45e0b94c80e1fb537a573b143Pablo Ceballos status_t waitForFreeSlotThenRelock(FreeSlotCaller caller, int* found) const; 2129f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza 213289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza sp<BufferQueueCore> mCore; 2143e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 2153e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // This references mCore->mSlots. Lock mCore->mMutex while accessing. 2163e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza BufferQueueDefs::SlotsType& mSlots; 217289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 218289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // This is a cached copy of the name stored in the BufferQueueCore. 219289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // It's updated during connect and dequeueBuffer (which should catch 220289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // most updates). 221289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza String8 mConsumerName; 222289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 2231681d95989271f3a9ac0dbb93d10e4a29f2b4444Ruben Brunk uint32_t mStickyTransform; 2241681d95989271f3a9ac0dbb93d10e4a29f2b4444Ruben Brunk 225468051e20be19130572231266db306396a56402bIrvel // This controls whether the GraphicBuffer pointer in the BufferItem is 226468051e20be19130572231266db306396a56402bIrvel // cleared after being queued 227468051e20be19130572231266db306396a56402bIrvel bool mConsumerIsSurfaceFlinger; 228468051e20be19130572231266db306396a56402bIrvel 22999a0afbaee9eddabc2b544e3a5c432901c1d498cEric Penner // This saves the fence from the last queueBuffer, such that the 23099a0afbaee9eddabc2b544e3a5c432901c1d498cEric Penner // next queueBuffer call can throttle buffer production. The prior 23199a0afbaee9eddabc2b544e3a5c432901c1d498cEric Penner // queueBuffer's fence is not nessessarily available elsewhere, 23299a0afbaee9eddabc2b544e3a5c432901c1d498cEric Penner // since the previous buffer might have already been acquired. 23399a0afbaee9eddabc2b544e3a5c432901c1d498cEric Penner sp<Fence> mLastQueueBufferFence; 23499a0afbaee9eddabc2b544e3a5c432901c1d498cEric Penner 2351a61da5e28fa16ad556a58193c8bbeb32a5f636dJohn Reck Rect mLastQueuedCrop; 2361a61da5e28fa16ad556a58193c8bbeb32a5f636dJohn Reck uint32_t mLastQueuedTransform; 2371a61da5e28fa16ad556a58193c8bbeb32a5f636dJohn Reck 2388dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza // Take-a-ticket system for ensuring that onFrame* callbacks are called in 2398dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza // the order that frames are queued. While the BufferQueue lock 2408dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza // (mCore->mMutex) is held, a ticket is retained by the producer. After 2418dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza // dropping the BufferQueue lock, the producer must wait on the condition 2428dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza // variable until the current callback ticket matches its retained ticket. 2438dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza Mutex mCallbackMutex; 2448dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza int mNextCallbackTicket; // Protected by mCore->mMutex 2458dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza int mCurrentCallbackTicket; // Protected by mCallbackMutex 2468dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza Condition mCallbackCondition; 2478dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza 248127fc63e8a15366b4395f1363e8e18eb058d1709Dan Stoza // Sets how long dequeueBuffer or attachBuffer will block if a buffer or 249127fc63e8a15366b4395f1363e8e18eb058d1709Dan Stoza // slot is not yet available. 250127fc63e8a15366b4395f1363e8e18eb058d1709Dan Stoza nsecs_t mDequeueTimeout; 251127fc63e8a15366b4395f1363e8e18eb058d1709Dan Stoza 252289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza}; // class BufferQueueProducer 253289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 254289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza} // namespace android 255289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 256289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#endif 257