make the warning timout of Fence::waitForever() implicit and longer

- timeout is now 3 seconds instead of 1
- simplifies the API a bit
- allows us to change/tweak this timeout globaly

Bug: 8988871

Change-Id: I8d3c6ec43a372f602fb3f29856710339f86c0ec9
This commit is contained in:
Mathias Agopian 2013-05-16 18:03:22 -07:00
parent f743e3db27
commit ea74d3b78d
7 changed files with 11 additions and 9 deletions

View File

@ -70,9 +70,10 @@ public:
// waitForever is a convenience function for waiting forever for a fence to
// signal (just like wait(TIMEOUT_NEVER)), but issuing an error to the
// system log and fence state to the kernel log if the wait lasts longer
// than warningTimeout. The logname argument should be a string identifying
// than a warning timeout.
// The logname argument should be a string identifying
// the caller and will be included in the log message.
status_t waitForever(unsigned int warningTimeout, const char* logname);
status_t waitForever(const char* logname);
// merge combines two Fence objects, creating a new Fence object that
// becomes signaled when both f1 and f2 are signaled (even if f1 or f2 is

View File

@ -63,7 +63,7 @@ status_t BufferItemConsumer::acquireBuffer(BufferItem *item, bool waitForFence)
}
if (waitForFence) {
err = item->mFence->waitForever(1000, "BufferItemConsumer::acquireBuffer");
err = item->mFence->waitForever("BufferItemConsumer::acquireBuffer");
if (err != OK) {
BI_LOGE("Failed to wait for fence of acquired buffer: %s (%d)",
strerror(-err), err);

View File

@ -80,7 +80,7 @@ status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) {
int buf = b.mBuf;
if (b.mFence.get()) {
err = b.mFence->waitForever(1000, "CpuConsumer::lockNextBuffer");
err = b.mFence->waitForever("CpuConsumer::lockNextBuffer");
if (err != OK) {
CC_LOGE("Failed to wait for fence of acquired buffer: %s (%d)",
strerror(-err), err);

View File

@ -821,7 +821,7 @@ status_t GLConsumer::doGLFenceWaitLocked() const {
return UNKNOWN_ERROR;
}
} else {
status_t err = mCurrentFence->waitForever(1000,
status_t err = mCurrentFence->waitForever(
"GLConsumer::doGLFenceWaitLocked");
if (err != NO_ERROR) {
ST_LOGE("doGLFenceWait: error waiting for fence: %d", err);

View File

@ -113,7 +113,7 @@ int Surface::hook_dequeueBuffer_DEPRECATED(ANativeWindow* window,
int fenceFd = -1;
int result = c->dequeueBuffer(&buf, &fenceFd);
sp<Fence> fence(new Fence(fenceFd));
int waitResult = fence->waitForever(1000, "dequeueBuffer_DEPRECATED");
int waitResult = fence->waitForever("dequeueBuffer_DEPRECATED");
if (waitResult != OK) {
ALOGE("dequeueBuffer_DEPRECATED: Fence::wait returned an error: %d",
waitResult);
@ -734,7 +734,7 @@ status_t Surface::lock(
sp<GraphicBuffer> backBuffer(GraphicBuffer::getSelf(out));
sp<Fence> fence(new Fence(fenceFd));
err = fence->waitForever(1000, "Surface::lock");
err = fence->waitForever("Surface::lock");
if (err != OK) {
ALOGE("Fence::wait failed (%s)", strerror(-err));
cancelBuffer(out, fenceFd);

View File

@ -54,11 +54,12 @@ status_t Fence::wait(unsigned int timeout) {
return err < 0 ? -errno : status_t(NO_ERROR);
}
status_t Fence::waitForever(unsigned int warningTimeout, const char* logname) {
status_t Fence::waitForever(const char* logname) {
ATRACE_CALL();
if (mFenceFd == -1) {
return NO_ERROR;
}
unsigned int warningTimeout = 3000;
int err = sync_wait(mFenceFd, warningTimeout);
if (err < 0 && errno == ETIME) {
ALOGE("%s: fence %d didn't signal in %u ms", logname, mFenceFd,

View File

@ -750,7 +750,7 @@ int HWComposer::fbPost(int32_t id,
if (mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
return setFramebufferTarget(id, acquireFence, buffer);
} else {
acquireFence->waitForever(1000, "HWComposer::fbPost");
acquireFence->waitForever("HWComposer::fbPost");
return mFbDev->post(mFbDev, buffer->handle);
}
}