diff options
author | Jason Sams <rjsams@android.com> | 2010-08-18 12:38:03 -0700 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2010-08-18 12:38:03 -0700 |
commit | d0cb106ff27d535365215ac3830c67239c7b5ced (patch) | |
tree | dd0cc7cc7bb5e312388a22c7fa05a4def54fcd43 /libs | |
parent | d78be37d81f6c1aba75180c7608753a027a881ee (diff) | |
download | frameworks_base-d0cb106ff27d535365215ac3830c67239c7b5ced.zip frameworks_base-d0cb106ff27d535365215ac3830c67239c7b5ced.tar.gz frameworks_base-d0cb106ff27d535365215ac3830c67239c7b5ced.tar.bz2 |
Fix bug looping non-blocking fifos.
Change-Id: I33dcf575466bfef672af4e113ad692397b5213e9
Diffstat (limited to 'libs')
-rw-r--r-- | libs/rs/rsContext.cpp | 2 | ||||
-rw-r--r-- | libs/rs/rsLocklessFifo.cpp | 27 | ||||
-rw-r--r-- | libs/rs/rsLocklessFifo.h | 1 |
3 files changed, 28 insertions, 2 deletions
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index 1a7c5ad..08dd57b 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -744,7 +744,7 @@ bool Context::sendMessageToClient(void *data, uint32_t cmdID, size_t len, bool w return false; } if (!waitForSpace) { - if (mIO.mToClient.getFreeSpace() <= (len + 8)) { + if (!mIO.mToClient.makeSpaceNonBlocking(len + 8)) { // Not enough room, and not waiting. return false; } diff --git a/libs/rs/rsLocklessFifo.cpp b/libs/rs/rsLocklessFifo.cpp index 76ca32e..019ea72 100644 --- a/libs/rs/rsLocklessFifo.cpp +++ b/libs/rs/rsLocklessFifo.cpp @@ -169,6 +169,30 @@ void LocklessCommandFifo::next() //dumpState("next"); } +bool LocklessCommandFifo::makeSpaceNonBlocking(uint32_t bytes) +{ + //dumpState("make space non-blocking"); + if ((mPut+bytes) > mEnd) { + // Need to loop regardless of where get is. + if((mGet > mPut) && (mBuffer+4 >= mGet)) { + return false; + } + + // Toss in a reset then the normal wait for space will do the rest. + reinterpret_cast<uint16_t *>(mPut)[0] = 0; + reinterpret_cast<uint16_t *>(mPut)[1] = 0; + mPut = mBuffer; + mSignalToWorker.set(); + } + + // it will fit here so we just need to wait for space. + if(getFreeSpace() < bytes) { + return false; + } + + return true; +} + void LocklessCommandFifo::makeSpace(uint32_t bytes) { //dumpState("make space"); @@ -182,6 +206,7 @@ void LocklessCommandFifo::makeSpace(uint32_t bytes) reinterpret_cast<uint16_t *>(mPut)[0] = 0; reinterpret_cast<uint16_t *>(mPut)[1] = 0; mPut = mBuffer; + mSignalToWorker.set(); } // it will fit here so we just need to wait for space. @@ -193,6 +218,6 @@ void LocklessCommandFifo::makeSpace(uint32_t bytes) void LocklessCommandFifo::dumpState(const char *s) const { - LOGV("%s put %p, get %p, buf %p, end %p", s, mPut, mGet, mBuffer, mEnd); + LOGV("%s %p put %p, get %p, buf %p, end %p", s, this, mPut, mGet, mBuffer, mEnd); } diff --git a/libs/rs/rsLocklessFifo.h b/libs/rs/rsLocklessFifo.h index ae906ca..b8ceeed 100644 --- a/libs/rs/rsLocklessFifo.h +++ b/libs/rs/rsLocklessFifo.h @@ -62,6 +62,7 @@ public: void next(); void makeSpace(uint32_t bytes); + bool makeSpaceNonBlocking(uint32_t bytes); bool isEmpty() const; uint32_t getFreeSpace() const; |