BufferQueueCore.h revision 399184a4cd728ea1421fb0bc1722274a29e38f4a
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_BUFFERQUEUECORE_H 18289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#define ANDROID_GUI_BUFFERQUEUECORE_H 19289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 203e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza#include <gui/BufferQueueDefs.h> 21289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#include <gui/BufferSlot.h> 22289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 23289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#include <utils/Condition.h> 24289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#include <utils/Mutex.h> 25399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall#include <utils/NativeHandle.h> 26289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#include <utils/RefBase.h> 27289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#include <utils/String8.h> 28289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#include <utils/StrongPointer.h> 29289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#include <utils/Trace.h> 30289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#include <utils/Vector.h> 31289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 32289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#define BQ_LOGV(x, ...) ALOGV("[%s] "x, mConsumerName.string(), ##__VA_ARGS__) 33289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#define BQ_LOGD(x, ...) ALOGD("[%s] "x, mConsumerName.string(), ##__VA_ARGS__) 34289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#define BQ_LOGI(x, ...) ALOGI("[%s] "x, mConsumerName.string(), ##__VA_ARGS__) 35289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#define BQ_LOGW(x, ...) ALOGW("[%s] "x, mConsumerName.string(), ##__VA_ARGS__) 36289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#define BQ_LOGE(x, ...) ALOGE("[%s] "x, mConsumerName.string(), ##__VA_ARGS__) 37289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 38289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#define ATRACE_BUFFER_INDEX(index) \ 39289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza if (ATRACE_ENABLED()) { \ 40289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza char ___traceBuf[1024]; \ 41289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza snprintf(___traceBuf, 1024, "%s: %d", \ 42289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza mCore->mConsumerName.string(), (index)); \ 43289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza android::ScopedTrace ___bufTracer(ATRACE_TAG, ___traceBuf); \ 44289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza } 45289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 46289ade165e60b5f71734d30e535f16eb1f4313adDan Stozanamespace android { 47289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 48289ade165e60b5f71734d30e535f16eb1f4313adDan Stozaclass BufferItem; 49289ade165e60b5f71734d30e535f16eb1f4313adDan Stozaclass IBinder; 50289ade165e60b5f71734d30e535f16eb1f4313adDan Stozaclass IConsumerListener; 51289ade165e60b5f71734d30e535f16eb1f4313adDan Stozaclass IGraphicBufferAlloc; 52289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 53289ade165e60b5f71734d30e535f16eb1f4313adDan Stozaclass BufferQueueCore : public virtual RefBase { 54289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 55289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza friend class BufferQueueProducer; 56289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza friend class BufferQueueConsumer; 57289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 58289ade165e60b5f71734d30e535f16eb1f4313adDan Stozapublic: 59289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // Used as a placeholder slot number when the value isn't pointing to an 60289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // existing buffer. 61289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza enum { INVALID_BUFFER_SLOT = -1 }; // TODO: Extract from IGBC::BufferItem 62289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 63289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // We reserve two slots in order to guarantee that the producer and 64289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // consumer can run asynchronously. 653e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza enum { MAX_MAX_ACQUIRED_BUFFERS = BufferQueueDefs::NUM_BUFFER_SLOTS - 2 }; 66289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 67289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // The default API number used to indicate that no producer is connected 68289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza enum { NO_CONNECTED_API = 0 }; 69289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 70289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza typedef Vector<BufferItem> Fifo; 71289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 72289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // BufferQueueCore manages a pool of gralloc memory slots to be used by 73289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // producers and consumers. allocator is used to allocate all the needed 74289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza // gralloc buffers. 75289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator = NULL); 76289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza virtual ~BufferQueueCore(); 77289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 78289ade165e60b5f71734d30e535f16eb1f4313adDan Stozaprivate: 793e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // Dump our state in a string 80289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza void dump(String8& result, const char* prefix) const; 81289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 823e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // getMinUndequeuedBufferCountLocked returns the minimum number of buffers 833e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // that must remain in a state other than DEQUEUED. The async parameter 843e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // tells whether we're in asynchronous mode. 85289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza int getMinUndequeuedBufferCountLocked(bool async) const; 863e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 873e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // getMinMaxBufferCountLocked returns the minimum number of buffers allowed 883e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // given the current BufferQueue state. The async parameter tells whether 893e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // we're in asynchonous mode. 90289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza int getMinMaxBufferCountLocked(bool async) const; 913e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 923e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // getMaxBufferCountLocked returns the maximum number of buffers that can be 933e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // allocated at once. This value depends on the following member variables: 943e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // 953e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mDequeueBufferCannotBlock 963e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mMaxAcquiredBufferCount 973e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mDefaultMaxBufferCount 983e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mOverrideMaxBufferCount 993e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // async parameter 1003e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // 1013e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // Any time one of these member variables is changed while a producer is 1023e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // connected, mDequeueCondition must be broadcast. 103289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza int getMaxBufferCountLocked(bool async) const; 1043e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 1053e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // setDefaultMaxBufferCountLocked sets the maximum number of buffer slots 1063e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // that will be used if the producer does not override the buffer slot 1073e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // count. The count must be between 2 and NUM_BUFFER_SLOTS, inclusive. The 1083e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // initial default is 2. 109289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza status_t setDefaultMaxBufferCountLocked(int count); 1103e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 1113e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // freeBufferLocked frees the GraphicBuffer and sync resources for the 1123e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // given slot. 113289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza void freeBufferLocked(int slot); 1143e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 1153e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // freeAllBuffersLocked frees the GraphicBuffer and sync resources for 1163e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // all slots. 117289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza void freeAllBuffersLocked(); 1183e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 1193e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // stillTracking returns true iff the buffer item is still being tracked 1203e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // in one of the slots. 121289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza bool stillTracking(const BufferItem* item) const; 122289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 1233e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mAllocator is the connection to SurfaceFlinger that is used to allocate 1243e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // new GraphicBuffer objects. 1253e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza sp<IGraphicBufferAlloc> mAllocator; 1263e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 1273e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mMutex is the mutex used to prevent concurrent access to the member 1283e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // variables of BufferQueueCore objects. It must be locked whenever any 1293e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // member variable is accessed. 130289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza mutable Mutex mMutex; 1313e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 1323e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mIsAbandoned indicates that the BufferQueue will no longer be used to 1333e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // consume image buffers pushed to it using the IGraphicBufferProducer 1343e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // interface. It is initialized to false, and set to true in the 1353e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // consumerDisconnect method. A BufferQueue that is abandoned will return 1363e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // the NO_INIT error from all IGraphicBufferProducer methods capable of 1373e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // returning an error. 138289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza bool mIsAbandoned; 1393e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 1403e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mConsumerControlledByApp indicates whether the connected consumer is 1413e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // controlled by the application. 142289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza bool mConsumerControlledByApp; 1433e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 1443e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mConsumerName is a string used to identify the BufferQueue in log 1453e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // messages. It is set by the IGraphicBufferConsumer::setConsumerName 1463e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // method. 147289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza String8 mConsumerName; 1483e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 1493e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mConsumerListener is used to notify the connected consumer of 1503e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // asynchronous events that it may wish to react to. It is initially 1513e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // set to NULL and is written by consumerConnect and consumerDisconnect. 152289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza sp<IConsumerListener> mConsumerListener; 1533e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 1543e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mConsumerUsageBits contains flags that the consumer wants for 1553e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // GraphicBuffers. 156289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza uint32_t mConsumerUsageBits; 1573e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 1583e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mConnectedApi indicates the producer API that is currently connected 1593e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // to this BufferQueue. It defaults to NO_CONNECTED_API, and gets updated 1603e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // by the connect and disconnect methods. 161289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza int mConnectedApi; 1623e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 1633e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mConnectedProducerToken is used to set a binder death notification on 1643e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // the producer. 165289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza sp<IBinder> mConnectedProducerToken; 1663e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 1673e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mSlots is an array of buffer slots that must be mirrored on the producer 1683e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // side. This allows buffer ownership to be transferred between the producer 1693e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // and consumer without sending a GraphicBuffer over Binder. The entire 1703e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // array is initialized to NULL at construction time, and buffers are 1713e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // allocated for a slot when requestBuffer is called with that slot's index. 1723e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza BufferQueueDefs::SlotsType mSlots; 1733e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 1743e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mQueue is a FIFO of queued buffers used in synchronous mode. 175289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza Fifo mQueue; 1763e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 1773e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mOverrideMaxBufferCount is the limit on the number of buffers that will 1783e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // be allocated at one time. This value is set by the producer by calling 1793e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // setBufferCount. The default is 0, which means that the producer doesn't 1803e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // care about the number of buffers in the pool. In that case, 1813e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mDefaultMaxBufferCount is used as the limit. 182289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza int mOverrideMaxBufferCount; 1833e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 1843e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mDequeueCondition is a condition variable used for dequeueBuffer in 1853e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // synchronous mode. 186289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza mutable Condition mDequeueCondition; 1873e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 1883e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mUseAsyncBuffer indicates whether an extra buffer is used in async mode 1893e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // to prevent dequeueBuffer from blocking. 190289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza bool mUseAsyncBuffer; 1913e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 1923e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mDequeueBufferCannotBlock indicates whether dequeueBuffer is allowed to 1933e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // block. This flag is set during connect when both the producer and 1943e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // consumer are controlled by the application. 195289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza bool mDequeueBufferCannotBlock; 1963e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 1973e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mDefaultBufferFormat can be set so it will override the buffer format 1983e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // when it isn't specified in dequeueBuffer. 199289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza uint32_t mDefaultBufferFormat; 2003e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 2013e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mDefaultWidth holds the default width of allocated buffers. It is used 2023e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // in dequeueBuffer if a width and height of 0 are specified. 203289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza int mDefaultWidth; 2043e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 2053e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mDefaultHeight holds the default height of allocated buffers. It is used 2063e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // in dequeueBuffer if a width and height of 0 are specified. 207289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza int mDefaultHeight; 2083e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 2093e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mDefaultMaxBufferCount is the default limit on the number of buffers that 2103e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // will be allocated at one time. This default limit is set by the consumer. 2113e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // The limit (as opposed to the default limit) may be overriden by the 2123e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // producer. 213289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza int mDefaultMaxBufferCount; 2143e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 2153e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mMaxAcquiredBufferCount is the number of buffers that the consumer may 2163e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // acquire at one time. It defaults to 1, and can be changed by the consumer 2173e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // via setMaxAcquiredBufferCount, but this may only be done while no 2183e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // producer is connected to the BufferQueue. This value is used to derive 2193e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // the value returned for the MIN_UNDEQUEUED_BUFFERS query to the producer. 220289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza int mMaxAcquiredBufferCount; 2213e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 2223e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mBufferHasBeenQueued is true once a buffer has been queued. It is reset 2233e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // when something causes all buffers to be freed (e.g., changing the buffer 2243e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // count). 225289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza bool mBufferHasBeenQueued; 2263e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 2273e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mFrameCounter is the free running counter, incremented on every 2283e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // successful queueBuffer call and buffer allocation. 229289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza uint64_t mFrameCounter; 2303e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza 2313e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza // mTransformHint is used to optimize for screen rotations. 232289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza uint32_t mTransformHint; 233289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 234399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall // mSidebandStream is a handle to the sideband buffer stream, if any 235399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall sp<NativeHandle> mSidebandStream; 236399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall 237289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza}; // class BufferQueueCore 238289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 239289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza} // namespace android 240289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza 241289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#endif 242