From: Jesse Hall Date: Tue, 29 Apr 2014 23:14:14 +0000 (-0700) Subject: Handle failed requestBuffer after successful dequeueBuffer X-Git-Tag: android-x86-6.0-r1~811^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=0b63cd105cae094c21aafaa2bac8322427e75827;p=android-x86%2Fframeworks-native.git Handle failed requestBuffer after successful dequeueBuffer If the virtual display consumer disconnects after the VirtualDisplaySurface dequeues a buffer but before it requests it, the request will fail. Previously the error was ignored, and the caller would get a success result but a NULL buffer. Now the dequeued buffer is cancelled and the error propagated to the caller. Bug: 14140551 Change-Id: I91547885c2cf6063dc7a8f02d97f2df282cdde2c --- diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp index 1362ae83e4..c415560321 100644 --- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp +++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp @@ -302,7 +302,12 @@ status_t VirtualDisplaySurface::dequeueBuffer(Source source, } } if (result & BUFFER_NEEDS_REALLOCATION) { - mSource[source]->requestBuffer(*sslot, &mProducerBuffers[pslot]); + result = mSource[source]->requestBuffer(*sslot, &mProducerBuffers[pslot]); + if (result < 0) { + mProducerBuffers[pslot].clear(); + mSource[source]->cancelBuffer(*sslot, *fence); + return result; + } VDS_LOGV("dequeueBuffer(%s): buffers[%d]=%p fmt=%d usage=%#x", dbgSourceStr(source), pslot, mProducerBuffers[pslot].get(), mProducerBuffers[pslot]->getPixelFormat(),