* commit 'ee5fb9299b6a7d81af6c2c1e598c4e9fd71a8ba9': Add Fence::waitForever which logs a warning timeout, and use it
This commit is contained in:
commit
c2e3e07549
@ -62,6 +62,13 @@ public:
|
|||||||
// indefinitely for the fence to signal.
|
// indefinitely for the fence to signal.
|
||||||
int wait(unsigned int timeout);
|
int wait(unsigned int timeout);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
// the caller and will be included in the log message.
|
||||||
|
int waitForever(unsigned int warningTimeout, const char* logname);
|
||||||
|
|
||||||
// TIMEOUT_NEVER may be passed to the wait method to indicate that it
|
// TIMEOUT_NEVER may be passed to the wait method to indicate that it
|
||||||
// should wait indefinitely for the fence to signal.
|
// should wait indefinitely for the fence to signal.
|
||||||
enum { TIMEOUT_NEVER = -1 };
|
enum { TIMEOUT_NEVER = -1 };
|
||||||
|
@ -63,7 +63,7 @@ status_t BufferItemConsumer::acquireBuffer(BufferItem *item, bool waitForFence)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (waitForFence && item->mFence.get()) {
|
if (waitForFence && item->mFence.get()) {
|
||||||
err = item->mFence->wait(Fence::TIMEOUT_NEVER);
|
err = item->mFence->waitForever(1000, "BufferItemConsumer::acquireBuffer");
|
||||||
if (err != OK) {
|
if (err != OK) {
|
||||||
BI_LOGE("Failed to wait for fence of acquired buffer: %s (%d)",
|
BI_LOGE("Failed to wait for fence of acquired buffer: %s (%d)",
|
||||||
strerror(-err), err);
|
strerror(-err), err);
|
||||||
|
@ -78,7 +78,7 @@ status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) {
|
|||||||
int buf = b.mBuf;
|
int buf = b.mBuf;
|
||||||
|
|
||||||
if (b.mFence.get()) {
|
if (b.mFence.get()) {
|
||||||
err = b.mFence->wait(Fence::TIMEOUT_NEVER);
|
err = b.mFence->waitForever(1000, "CpuConsumer::lockNextBuffer");
|
||||||
if (err != OK) {
|
if (err != OK) {
|
||||||
CC_LOGE("Failed to wait for fence of acquired buffer: %s (%d)",
|
CC_LOGE("Failed to wait for fence of acquired buffer: %s (%d)",
|
||||||
strerror(-err), err);
|
strerror(-err), err);
|
||||||
|
@ -812,7 +812,8 @@ status_t SurfaceTexture::doGLFenceWaitLocked() const {
|
|||||||
return UNKNOWN_ERROR;
|
return UNKNOWN_ERROR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status_t err = mCurrentFence->wait(Fence::TIMEOUT_NEVER);
|
status_t err = mCurrentFence->waitForever(1000,
|
||||||
|
"SurfaceTexture::doGLFenceWaitLocked");
|
||||||
if (err != NO_ERROR) {
|
if (err != NO_ERROR) {
|
||||||
ST_LOGE("doGLFenceWait: error waiting for fence: %d", err);
|
ST_LOGE("doGLFenceWait: error waiting for fence: %d", err);
|
||||||
return err;
|
return err;
|
||||||
|
@ -129,15 +129,18 @@ int SurfaceTextureClient::hook_queueBuffer(ANativeWindow* window,
|
|||||||
int SurfaceTextureClient::hook_dequeueBuffer_DEPRECATED(ANativeWindow* window,
|
int SurfaceTextureClient::hook_dequeueBuffer_DEPRECATED(ANativeWindow* window,
|
||||||
ANativeWindowBuffer** buffer) {
|
ANativeWindowBuffer** buffer) {
|
||||||
SurfaceTextureClient* c = getSelf(window);
|
SurfaceTextureClient* c = getSelf(window);
|
||||||
|
ANativeWindowBuffer* buf;
|
||||||
int fenceFd = -1;
|
int fenceFd = -1;
|
||||||
int result = c->dequeueBuffer(buffer, &fenceFd);
|
int result = c->dequeueBuffer(&buf, &fenceFd);
|
||||||
sp<Fence> fence(new Fence(fenceFd));
|
sp<Fence> fence(new Fence(fenceFd));
|
||||||
int waitResult = fence->wait(Fence::TIMEOUT_NEVER);
|
int waitResult = fence->waitForever(1000, "dequeueBuffer_DEPRECATED");
|
||||||
if (waitResult != OK) {
|
if (waitResult != OK) {
|
||||||
ALOGE("hook_dequeueBuffer_DEPRECATED: Fence::wait returned an "
|
ALOGE("dequeueBuffer_DEPRECATED: Fence::wait returned an error: %d",
|
||||||
"error: %d", waitResult);
|
waitResult);
|
||||||
|
c->cancelBuffer(buf, -1);
|
||||||
return waitResult;
|
return waitResult;
|
||||||
}
|
}
|
||||||
|
*buffer = buf;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -751,7 +754,7 @@ status_t SurfaceTextureClient::lock(
|
|||||||
sp<GraphicBuffer> backBuffer(GraphicBuffer::getSelf(out));
|
sp<GraphicBuffer> backBuffer(GraphicBuffer::getSelf(out));
|
||||||
sp<Fence> fence(new Fence(fenceFd));
|
sp<Fence> fence(new Fence(fenceFd));
|
||||||
|
|
||||||
err = fence->wait(Fence::TIMEOUT_NEVER);
|
err = fence->waitForever(1000, "SurfaceTextureClient::lock");
|
||||||
if (err != OK) {
|
if (err != OK) {
|
||||||
ALOGE("Fence::wait failed (%s)", strerror(-err));
|
ALOGE("Fence::wait failed (%s)", strerror(-err));
|
||||||
cancelBuffer(out, fenceFd);
|
cancelBuffer(out, fenceFd);
|
||||||
|
@ -50,6 +50,20 @@ int Fence::wait(unsigned int timeout) {
|
|||||||
return sync_wait(mFenceFd, timeout);
|
return sync_wait(mFenceFd, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Fence::waitForever(unsigned int warningTimeout, const char* logname) {
|
||||||
|
ATRACE_CALL();
|
||||||
|
if (mFenceFd == -1) {
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
int err = sync_wait(mFenceFd, warningTimeout);
|
||||||
|
if (err == -ETIME) {
|
||||||
|
ALOGE("%s: fence %d didn't signal in %u ms", logname, mFenceFd,
|
||||||
|
warningTimeout);
|
||||||
|
err = sync_wait(mFenceFd, TIMEOUT_NEVER);
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
sp<Fence> Fence::merge(const String8& name, const sp<Fence>& f1,
|
sp<Fence> Fence::merge(const String8& name, const sp<Fence>& f1,
|
||||||
const sp<Fence>& f2) {
|
const sp<Fence>& f2) {
|
||||||
ATRACE_CALL();
|
ATRACE_CALL();
|
||||||
|
@ -686,7 +686,7 @@ int HWComposer::fbPost(int32_t id,
|
|||||||
return setFramebufferTarget(id, acquireFence, buffer);
|
return setFramebufferTarget(id, acquireFence, buffer);
|
||||||
} else {
|
} else {
|
||||||
if (acquireFence != NULL) {
|
if (acquireFence != NULL) {
|
||||||
acquireFence->wait(Fence::TIMEOUT_NEVER);
|
acquireFence->waitForever(1000, "HWComposer::fbPost");
|
||||||
}
|
}
|
||||||
return mFbDev->post(mFbDev, buffer->handle);
|
return mFbDev->post(mFbDev, buffer->handle);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user