Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa455354 authored by Pablo Ceballos's avatar Pablo Ceballos
Browse files

BQ: add setMaxDequeuedBufferCount

Adds the new setMaxDequeuedBufferCount() function to
BufferQueueProducer. This will eventually replace setBufferCount.

Also add setAsyncMode.

Bug 13174928

Change-Id: Iea1adcd5d74a75f67d8e9dde06d521695628ad5a
parent 8d8e33ac
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -242,6 +242,11 @@ private:
    // the value returned for the MIN_UNDEQUEUED_BUFFERS query to the producer.
    int mMaxAcquiredBufferCount;

    // mMaxDequeuedBufferCount is the number of buffers that the producer may
    // dequeue at one time. It defaults to 1, and can be changed by the producer
    // via setMaxDequeuedBufferCount.
    int mMaxDequeuedBufferCount;

    // mBufferHasBeenQueued is true once a buffer has been queued. It is reset
    // when something causes all buffers to be freed (e.g., changing the buffer
    // count).
@@ -280,6 +285,11 @@ private:
    // number will fail.
    uint32_t mGenerationNumber;

    // mAsyncMode indicates whether or not async mode is enabled.
    // In async mode an extra buffer will be allocated to allow the producer to
    // enqueue buffers without blocking.
    bool mAsyncMode;

}; // class BufferQueueCore

} // namespace android
+6 −0
Original line number Diff line number Diff line
@@ -56,6 +56,12 @@ public:
    // to discard buffers through the onBuffersReleased callback.
    virtual status_t setBufferCount(int bufferCount);

    // see IGraphicsBufferProducer::setMaxDequeuedBufferCount
    virtual status_t setMaxDequeuedBufferCount(int maxDequeuedBuffers);

    // see IGraphicsBufferProducer::setAsyncMode
    virtual status_t setAsyncMode(bool async);

    // dequeueBuffer gets the next buffer slot index for the producer to use.
    // If a buffer slot is available then that slot index is written to the
    // location pointed to by the buf argument and a status of OK is returned.
+39 −0
Original line number Diff line number Diff line
@@ -102,6 +102,45 @@ public:
    //              * client has one or more buffers dequeued
    virtual status_t setBufferCount(int bufferCount) = 0;

    // setMaxDequeuedBufferCount sets the maximum number of buffers that can be
    // dequeued by the producer at one time. If this method succeeds, buffer
    // slots will be both unallocated and owned by the BufferQueue object (i.e.
    // they are not owned by the producer or consumer). Calling this will also
    // cause all buffer slots to be emptied. If the caller is caching the
    // contents of the buffer slots, it should empty that cache after calling
    // this method.
    //
    // This function should not be called when there are any currently dequeued
    // buffer slots. Doing so will result in a BAD_VALUE error.
    //
    // The buffer count should be at least 1 (inclusive), but at most
    // (NUM_BUFFER_SLOTS - the minimum undequeued buffer count) (exclusive). The
    // minimum undequeued buffer count can be obtained by calling
    // query(NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS).
    //
    // Return of a value other than NO_ERROR means an error has occurred:
    // * NO_INIT - the buffer queue has been abandoned.
    // * BAD_VALUE - one of the below conditions occurred:
    //              * bufferCount was out of range (see above)
    //              * client has one or more buffers dequeued
    virtual status_t setMaxDequeuedBufferCount(int maxDequeuedBuffers) = 0;

    // Set the async flag if the producer intends to asynchronously queue
    // buffers without blocking. Typically this is used for triple-buffering
    // and/or when the swap interval is set to zero.
    //
    // Enabling async mode will internally allocate an additional buffer to
    // allow for the asynchronous behavior. If it is not enabled queue/dequeue
    // calls may block.
    //
    // This function should not be called when there are any currently dequeued
    // buffer slots, doing so will result in a BAD_VALUE error.
    //
    // Return of a value other than NO_ERROR means an error has occurred:
    // * NO_INIT - the buffer queue has been abandoned.
    // * BAD_VALUE - client has one or more buffers dequeued
    virtual status_t setAsyncMode(bool async) = 0;

    // dequeueBuffer requests a new buffer slot for the client to use. Ownership
    // of the slot is transfered to the client, meaning that the server will not
    // use the contents of the buffer associated with that slot.
+2 −0
Original line number Diff line number Diff line
@@ -170,6 +170,8 @@ protected:
    virtual int connect(int api);
    virtual int disconnect(int api);
    virtual int setBufferCount(int bufferCount);
    virtual int setMaxDequeuedBufferCount(int maxDequeuedBuffers);
    virtual int setAsyncMode(bool async);
    virtual int setBuffersDimensions(uint32_t width, uint32_t height);
    virtual int setBuffersUserDimensions(uint32_t width, uint32_t height);
    virtual int setBuffersFormat(PixelFormat format);
+9 −6
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) :
    mDefaultBufferDataSpace(HAL_DATASPACE_UNKNOWN),
    mDefaultMaxBufferCount(2),
    mMaxAcquiredBufferCount(1),
    mMaxDequeuedBufferCount(1),
    mBufferHasBeenQueued(false),
    mFrameCounter(0),
    mTransformHint(0),
@@ -72,7 +73,8 @@ BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) :
    mIsAllocatingCondition(),
    mAllowAllocation(true),
    mBufferAge(0),
    mGenerationNumber(0)
    mGenerationNumber(0),
    mAsyncMode(false)
{
    if (allocator == NULL) {
        sp<ISurfaceComposer> composer(ComposerService::getComposerService());
@@ -104,11 +106,12 @@ void BufferQueueCore::dump(String8& result, const char* prefix) const {
    }

    result.appendFormat("%s-BufferQueue mMaxAcquiredBufferCount=%d, "
            "mDequeueBufferCannotBlock=%d, default-size=[%dx%d], "
            "default-format=%d, transform-hint=%02x, FIFO(%zu)={%s}\n",
            prefix, mMaxAcquiredBufferCount, mDequeueBufferCannotBlock,
            mDefaultWidth, mDefaultHeight, mDefaultBufferFormat, mTransformHint,
            mQueue.size(), fifo.string());
            "mMaxDequeuedBufferCount=%d, mDequeueBufferCannotBlock=%d, "
            "default-size=[%dx%d], default-format=%d, transform-hint=%02x, "
            "FIFO(%zu)={%s}\n",
            prefix, mMaxAcquiredBufferCount, mMaxDequeuedBufferCount,
            mDequeueBufferCannotBlock, mDefaultWidth, mDefaultHeight,
            mDefaultBufferFormat, mTransformHint, mQueue.size(), fifo.string());

    // Trim the free buffers so as to not spam the dump
    int maxBufferCount = 0;
Loading