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
25289ade165e60b5f71734d30e535f16eb1f4313adDan Stozaclass 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
32289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    BufferQueueProducer(const sp<BufferQueueCore>& core);
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
42289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // setBufferCount updates the number of available buffer slots.  If this
43289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // method succeeds, buffer slots will be both unallocated and owned by
44289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // the BufferQueue object (i.e. they are not owned by the producer or
45289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // consumer).
46289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    //
47289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // This will fail if the producer has dequeued any buffers, or if
48289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // bufferCount is invalid.  bufferCount must generally be a value
49289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // between the minimum undequeued buffer count (exclusive) and NUM_BUFFER_SLOTS
50289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // (inclusive).  It may also be set to zero (the default) to indicate
51289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // that the producer does not wish to set a value.  The minimum value
52289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // can be obtained by calling query(NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
53289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // ...).
54289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    //
55289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // This may only be called by the producer.  The consumer will be told
56289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // to discard buffers through the onBuffersReleased callback.
57289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    virtual status_t setBufferCount(int bufferCount);
58289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza
59289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // dequeueBuffer gets the next buffer slot index for the producer to use.
60289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // If a buffer slot is available then that slot index is written to the
61289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // location pointed to by the buf argument and a status of OK is returned.
62289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // If no slot is available then a status of -EBUSY is returned and buf is
63289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // unmodified.
64289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    //
65289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // The outFence parameter will be updated to hold the fence associated with
66289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // the buffer. The contents of the buffer must not be overwritten until the
67289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // fence signals. If the fence is Fence::NO_FENCE, the buffer may be
68289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // written immediately.
69289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    //
70289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // The width and height parameters must be no greater than the minimum of
71289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv).
72289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // An error due to invalid dimensions might not be reported until
73289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // updateTexImage() is called.  If width and height are both zero, the
74289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // default values specified by setDefaultBufferSize() are used instead.
75289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    //
76289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // The pixel formats are enumerated in graphics.h, e.g.
77289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // HAL_PIXEL_FORMAT_RGBA_8888.  If the format is 0, the default format
78289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // will be used.
79289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    //
80289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // The usage argument specifies gralloc buffer usage flags.  The values
81289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // are enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER.  These
82289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // will be merged with the usage flags specified by setConsumerUsageBits.
83289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    //
84289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // The return value may be a negative error value or a non-negative
85289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // collection of flags.  If the flags are set, the return values are
86289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // valid, but additional actions must be performed.
87289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    //
88289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // If IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION is set, the
89289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // producer must discard cached GraphicBuffer references for the slot
90289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // returned in buf.
91289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // If IGraphicBufferProducer::RELEASE_ALL_BUFFERS is set, the producer
92289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // must discard cached GraphicBuffer references for all slots.
93289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    //
94289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // In both cases, the producer will need to call requestBuffer to get a
95289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // GraphicBuffer handle for the returned slot.
96289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    virtual status_t dequeueBuffer(int *outSlot, sp<Fence>* outFence, bool async,
97289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza            uint32_t width, uint32_t height, uint32_t format, uint32_t usage);
98289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza
999f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza    // See IGraphicBufferProducer::detachBuffer
1009f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza    virtual status_t detachBuffer(int slot);
1019f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza
102d9822a3843017444364899afc3c23fb5be6b9cb9Dan Stoza    // See IGraphicBufferProducer::detachNextBuffer
103d9822a3843017444364899afc3c23fb5be6b9cb9Dan Stoza    virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer,
104d9822a3843017444364899afc3c23fb5be6b9cb9Dan Stoza            sp<Fence>* outFence);
105d9822a3843017444364899afc3c23fb5be6b9cb9Dan Stoza
1069f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza    // See IGraphicBufferProducer::attachBuffer
1079f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza    virtual status_t attachBuffer(int* outSlot, const sp<GraphicBuffer>& buffer);
1089f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza
109289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // queueBuffer returns a filled buffer to the BufferQueue.
110289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    //
111289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // Additional data is provided in the QueueBufferInput struct.  Notably,
112289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // a timestamp must be provided for the buffer. The timestamp is in
113289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // nanoseconds, and must be monotonically increasing. Its other semantics
114289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // (zero point, etc) are producer-specific and should be documented by the
115289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // producer.
116289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    //
117289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // The caller may provide a fence that signals when all rendering
118289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // operations have completed.  Alternatively, NO_FENCE may be used,
119289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // indicating that the buffer is ready immediately.
120289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    //
121289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // Some values are returned in the output struct: the current settings
122289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // for default width and height, the current transform hint, and the
123289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // number of queued buffers.
124289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    virtual status_t queueBuffer(int slot,
125289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza            const QueueBufferInput& input, QueueBufferOutput* output);
126289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza
127289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // cancelBuffer returns a dequeued buffer to the BufferQueue, but doesn't
128289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // queue it for use by the consumer.
129289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    //
130289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // The buffer will not be overwritten until the fence signals.  The fence
131289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // will usually be the one obtained from dequeueBuffer.
132289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    virtual void cancelBuffer(int slot, const sp<Fence>& fence);
133289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza
134289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // Query native window attributes.  The "what" values are enumerated in
135289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // window.h (e.g. NATIVE_WINDOW_FORMAT).
136289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    virtual int query(int what, int* outValue);
137289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza
138289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // connect attempts to connect a producer API to the BufferQueue.  This
139289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // must be called before any other IGraphicBufferProducer methods are
140289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // called except for getAllocator.  A consumer must already be connected.
141289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    //
142289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // This method will fail if connect was previously called on the
143289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // BufferQueue and no corresponding disconnect call was made (i.e. if
144289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // it's still connected to a producer).
145289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    //
146289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // APIs are enumerated in window.h (e.g. NATIVE_WINDOW_API_CPU).
147f0eaf25e9247edf4d124bedaeb863f7abdf35a3eDan Stoza    virtual status_t connect(const sp<IProducerListener>& listener,
148289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza            int api, bool producerControlledByApp, QueueBufferOutput* output);
149289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza
150289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // disconnect attempts to disconnect a producer API from the BufferQueue.
151289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // Calling this method will cause any subsequent calls to other
152289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // IGraphicBufferProducer methods to fail except for getAllocator and connect.
153289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // Successfully calling connect after this will allow the other methods to
154289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // succeed again.
155289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    //
156289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // This method will fail if the the BufferQueue is not currently
157289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // connected to the specified producer API.
158289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    virtual status_t disconnect(int api);
159289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza
160399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall    // Attaches a sideband buffer stream to the IGraphicBufferProducer.
161399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall    //
162399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall    // A sideband stream is a device-specific mechanism for passing buffers
163399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall    // from the producer to the consumer without using dequeueBuffer/
164399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall    // queueBuffer. If a sideband stream is present, the consumer can choose
165399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall    // whether to acquire buffers from the sideband stream or from the queued
166399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall    // buffers.
167399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall    //
168399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall    // Passing NULL or a different stream handle will detach the previous
169399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall    // handle if any.
170399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall    virtual status_t setSidebandStream(const sp<NativeHandle>& stream);
171399184a4cd728ea1421fb0bc1722274a29e38f4aJesse Hall
17229a3e90879fd96404c971e7187cd0e05927bbce0Dan Stoza    // See IGraphicBufferProducer::allocateBuffers
17329a3e90879fd96404c971e7187cd0e05927bbce0Dan Stoza    virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
17429a3e90879fd96404c971e7187cd0e05927bbce0Dan Stoza            uint32_t format, uint32_t usage);
17529a3e90879fd96404c971e7187cd0e05927bbce0Dan Stoza
176289ade165e60b5f71734d30e535f16eb1f4313adDan Stozaprivate:
177289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // This is required by the IBinder::DeathRecipient interface
178289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    virtual void binderDied(const wp<IBinder>& who);
179289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza
1809f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza    // waitForFreeSlotThenRelock finds the oldest slot in the FREE state. It may
1819f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza    // block if there are no available slots and we are not in non-blocking
1829f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza    // mode (producer and consumer controlled by the application). If it blocks,
1839f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza    // it will release mCore->mMutex while blocked so that other operations on
1849f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza    // the BufferQueue may succeed.
1859f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza    status_t waitForFreeSlotThenRelock(const char* caller, bool async,
1869f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza            int* found, status_t* returnFlags) const;
1879f3053de78630815d60cf48a2cf2348cc5867c45Dan Stoza
188289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    sp<BufferQueueCore> mCore;
1893e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza
1903e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza    // This references mCore->mSlots. Lock mCore->mMutex while accessing.
1913e96f1982fda358424b0b75f394cbf7c1794a072Dan Stoza    BufferQueueDefs::SlotsType& mSlots;
192289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza
193289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // This is a cached copy of the name stored in the BufferQueueCore.
194289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // It's updated during connect and dequeueBuffer (which should catch
195289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    // most updates).
196289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza    String8 mConsumerName;
197289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza
1981681d95989271f3a9ac0dbb93d10e4a29f2b4444Ruben Brunk    uint32_t mStickyTransform;
1991681d95989271f3a9ac0dbb93d10e4a29f2b4444Ruben Brunk
20099a0afbaee9eddabc2b544e3a5c432901c1d498cEric Penner    // This saves the fence from the last queueBuffer, such that the
20199a0afbaee9eddabc2b544e3a5c432901c1d498cEric Penner    // next queueBuffer call can throttle buffer production. The prior
20299a0afbaee9eddabc2b544e3a5c432901c1d498cEric Penner    // queueBuffer's fence is not nessessarily available elsewhere,
20399a0afbaee9eddabc2b544e3a5c432901c1d498cEric Penner    // since the previous buffer might have already been acquired.
20499a0afbaee9eddabc2b544e3a5c432901c1d498cEric Penner    sp<Fence> mLastQueueBufferFence;
20599a0afbaee9eddabc2b544e3a5c432901c1d498cEric Penner
2068dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza    // Take-a-ticket system for ensuring that onFrame* callbacks are called in
2078dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza    // the order that frames are queued. While the BufferQueue lock
2088dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza    // (mCore->mMutex) is held, a ticket is retained by the producer. After
2098dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza    // dropping the BufferQueue lock, the producer must wait on the condition
2108dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza    // variable until the current callback ticket matches its retained ticket.
2118dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza    Mutex mCallbackMutex;
2128dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza    int mNextCallbackTicket; // Protected by mCore->mMutex
2138dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza    int mCurrentCallbackTicket; // Protected by mCallbackMutex
2148dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza    Condition mCallbackCondition;
2158dc55396fc9bc425b5e2c82e76a38080f2a655ffDan Stoza
216289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza}; // class BufferQueueProducer
217289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza
218289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza} // namespace android
219289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza
220289ade165e60b5f71734d30e535f16eb1f4313adDan Stoza#endif
221