Merge "gui: Surface::dequeueBuffer no locker holds mutex while blocking in binder"

This commit is contained in:
Igor Murashkin 2014-03-03 21:11:54 +00:00 committed by Android (Google) Code Review
commit c0308d7600

View File

@ -178,19 +178,38 @@ int Surface::setSwapInterval(int interval) {
int Surface::dequeueBuffer(android_native_buffer_t** buffer, int* fenceFd) { int Surface::dequeueBuffer(android_native_buffer_t** buffer, int* fenceFd) {
ATRACE_CALL(); ATRACE_CALL();
ALOGV("Surface::dequeueBuffer"); ALOGV("Surface::dequeueBuffer");
int reqW;
int reqH;
bool swapIntervalZero;
uint32_t reqFormat;
uint32_t reqUsage;
{
Mutex::Autolock lock(mMutex); Mutex::Autolock lock(mMutex);
reqW = mReqWidth ? mReqWidth : mUserWidth;
reqH = mReqHeight ? mReqHeight : mUserHeight;
swapIntervalZero = mSwapIntervalZero;
reqFormat = mReqFormat;
reqUsage = mReqUsage;
} // Drop the lock so that we can still touch the Surface while blocking in IGBP::dequeueBuffer
int buf = -1; int buf = -1;
int reqW = mReqWidth ? mReqWidth : mUserWidth;
int reqH = mReqHeight ? mReqHeight : mUserHeight;
sp<Fence> fence; sp<Fence> fence;
status_t result = mGraphicBufferProducer->dequeueBuffer(&buf, &fence, mSwapIntervalZero, status_t result = mGraphicBufferProducer->dequeueBuffer(&buf, &fence, swapIntervalZero,
reqW, reqH, mReqFormat, mReqUsage); reqW, reqH, reqFormat, reqUsage);
if (result < 0) { if (result < 0) {
ALOGV("dequeueBuffer: IGraphicBufferProducer::dequeueBuffer(%d, %d, %d, %d)" ALOGV("dequeueBuffer: IGraphicBufferProducer::dequeueBuffer(%d, %d, %d, %d, %d)"
"failed: %d", mReqWidth, mReqHeight, mReqFormat, mReqUsage, "failed: %d", swapIntervalZero, reqW, reqH, reqFormat, reqUsage,
result); result);
return result; return result;
} }
Mutex::Autolock lock(mMutex);
sp<GraphicBuffer>& gbuf(mSlots[buf].buffer); sp<GraphicBuffer>& gbuf(mSlots[buf].buffer);
// this should never happen // this should never happen