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

Commit ab0fb1be authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 24947 into eclair

* changes:
  make sure to update the tail pointer when undoing a dequeue
parents abff9f77 c7d56010
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -229,6 +229,8 @@ private:
    friend struct DequeueCondition;
    friend struct LockCondition;
    
    int32_t computeTail() const;

    struct QueueUpdate : public UpdateBase {
        inline QueueUpdate(SharedBufferBase* sbb);
        inline ssize_t operator()();
+15 −5
Original line number Diff line number Diff line
@@ -245,20 +245,27 @@ ssize_t SharedBufferServer::StatusUpdate::operator()() {
SharedBufferClient::SharedBufferClient(SharedClient* sharedClient,
        int surface, int num)
    : SharedBufferBase(sharedClient, surface, num), tail(0)
{
    tail = computeTail();
}

int32_t SharedBufferClient::computeTail() const
{
    SharedBufferStack& stack( *mSharedStack );
    int32_t avail;
    int32_t head;
    // we need to make sure we read available and head coherently,
    // w.r.t RetireUpdate.
    int32_t newTail;
    int32_t avail;
    int32_t head;
    do {
        avail = stack.available;
        head = stack.head;
    } while (stack.available != avail);
    tail = head - avail + 1;
    if (tail < 0) {
        tail += num;
    newTail = head - avail + 1;
    if (newTail < 0) {
        newTail += mNumBuffers;
    }
    return newTail;
}

ssize_t SharedBufferClient::dequeue()
@@ -296,6 +303,9 @@ status_t SharedBufferClient::undoDequeue(int buf)
{
    UndoDequeueUpdate update(this);
    status_t err = updateCondition( update );
    if (err == NO_ERROR) {
        tail = computeTail();
    }
    return err;
}