Merge change 24642 into eclair
* changes: make sure conditions will return when the status of a surface is not NO_ERROR
This commit is contained in:
@@ -93,12 +93,12 @@ public:
|
|||||||
volatile int32_t available; // number of dequeue-able buffers
|
volatile int32_t available; // number of dequeue-able buffers
|
||||||
volatile int32_t queued; // number of buffers waiting for post
|
volatile int32_t queued; // number of buffers waiting for post
|
||||||
volatile int32_t inUse; // buffer currently in use by SF
|
volatile int32_t inUse; // buffer currently in use by SF
|
||||||
|
volatile status_t status; // surface's status code
|
||||||
|
|
||||||
// not part of the conditions
|
// not part of the conditions
|
||||||
volatile int32_t reallocMask;
|
volatile int32_t reallocMask;
|
||||||
|
|
||||||
int32_t identity; // surface's identity (const)
|
int32_t identity; // surface's identity (const)
|
||||||
status_t status; // surface's status code
|
|
||||||
int32_t reserved32[13];
|
int32_t reserved32[13];
|
||||||
FlatRegion dirtyRegion[NUM_BUFFER_MAX]; // 12*4=48 bytes
|
FlatRegion dirtyRegion[NUM_BUFFER_MAX]; // 12*4=48 bytes
|
||||||
};
|
};
|
||||||
@@ -168,10 +168,11 @@ protected:
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
status_t SharedBufferBase::waitForCondition(T condition)
|
status_t SharedBufferBase::waitForCondition(T condition)
|
||||||
{
|
{
|
||||||
|
const SharedBufferStack& stack( *mSharedStack );
|
||||||
SharedClient& client( *mSharedClient );
|
SharedClient& client( *mSharedClient );
|
||||||
const nsecs_t TIMEOUT = s2ns(1);
|
const nsecs_t TIMEOUT = s2ns(1);
|
||||||
Mutex::Autolock _l(client.lock);
|
Mutex::Autolock _l(client.lock);
|
||||||
while (!condition()) {
|
while ((condition()==false) && (stack.status == NO_ERROR)) {
|
||||||
status_t err = client.cv.waitRelative(client.lock, TIMEOUT);
|
status_t err = client.cv.waitRelative(client.lock, TIMEOUT);
|
||||||
|
|
||||||
// handle errors and timeouts
|
// handle errors and timeouts
|
||||||
@@ -195,7 +196,7 @@ status_t SharedBufferBase::waitForCondition(T condition)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NO_ERROR;
|
return stack.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -265,6 +266,7 @@ public:
|
|||||||
|
|
||||||
ssize_t retireAndLock();
|
ssize_t retireAndLock();
|
||||||
status_t unlock(int buffer);
|
status_t unlock(int buffer);
|
||||||
|
void setStatus(status_t status);
|
||||||
status_t reallocate();
|
status_t reallocate();
|
||||||
status_t assertReallocate(int buffer);
|
status_t assertReallocate(int buffer);
|
||||||
|
|
||||||
@@ -283,6 +285,12 @@ private:
|
|||||||
inline ssize_t operator()();
|
inline ssize_t operator()();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct StatusUpdate : public UpdateBase {
|
||||||
|
const status_t status;
|
||||||
|
inline StatusUpdate(SharedBufferBase* sbb, status_t status);
|
||||||
|
inline ssize_t operator()();
|
||||||
|
};
|
||||||
|
|
||||||
struct ReallocateCondition : public ConditionBase {
|
struct ReallocateCondition : public ConditionBase {
|
||||||
int buf;
|
int buf;
|
||||||
inline ReallocateCondition(SharedBufferBase* sbb, int buf);
|
inline ReallocateCondition(SharedBufferBase* sbb, int buf);
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ status_t SharedClient::setIdentity(size_t token, uint32_t identity) {
|
|||||||
|
|
||||||
|
|
||||||
SharedBufferStack::SharedBufferStack()
|
SharedBufferStack::SharedBufferStack()
|
||||||
: inUse(-1), identity(-1), status(NO_ERROR)
|
: inUse(-1), status(NO_ERROR), identity(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,6 +231,16 @@ ssize_t SharedBufferServer::RetireUpdate::operator()() {
|
|||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SharedBufferServer::StatusUpdate::StatusUpdate(
|
||||||
|
SharedBufferBase* sbb, status_t status)
|
||||||
|
: UpdateBase(sbb), status(status) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t SharedBufferServer::StatusUpdate::operator()() {
|
||||||
|
android_atomic_write(status, &stack.status);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
SharedBufferClient::SharedBufferClient(SharedClient* sharedClient,
|
SharedBufferClient::SharedBufferClient(SharedClient* sharedClient,
|
||||||
@@ -327,6 +337,12 @@ status_t SharedBufferServer::unlock(int buffer)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SharedBufferServer::setStatus(status_t status)
|
||||||
|
{
|
||||||
|
StatusUpdate update(this, status);
|
||||||
|
updateCondition( update );
|
||||||
|
}
|
||||||
|
|
||||||
status_t SharedBufferServer::reallocate()
|
status_t SharedBufferServer::reallocate()
|
||||||
{
|
{
|
||||||
SharedBufferStack& stack( *mSharedStack );
|
SharedBufferStack& stack( *mSharedStack );
|
||||||
|
|||||||
Reference in New Issue
Block a user