am 0ff4b283: am 6da15f46: fix crashers with wifi/virtual displays

* commit '0ff4b28396d77a0ed2f191836895a891108a8b5b':
  fix crashers with wifi/virtual displays
This commit is contained in:
Mathias Agopian 2013-09-26 12:47:35 -07:00 committed by Android Git Automerger
commit 2b3d0c4079
2 changed files with 17 additions and 0 deletions

View File

@ -258,6 +258,17 @@ status_t VirtualDisplaySurface::dequeueBuffer(int* pslot, sp<Fence>* fence, bool
Source source = fbSourceForCompositionType(mCompositionType); Source source = fbSourceForCompositionType(mCompositionType);
if (source == SOURCE_SINK) { if (source == SOURCE_SINK) {
if (mOutputProducerSlot < 0) {
// Last chance bailout if something bad happened earlier. For example,
// in a GLES configuration, if the sink disappears then dequeueBuffer
// will fail, the GLES driver won't queue a buffer, but SurfaceFlinger
// will soldier on. So we end up here without a buffer. There should
// be lots of scary messages in the log just before this.
VDS_LOGE("dequeueBuffer: no buffer, bailing out");
return NO_MEMORY;
}
// We already dequeued the output buffer. If the GLES driver wants // We already dequeued the output buffer. If the GLES driver wants
// something incompatible, we have to cancel and get a new one. This // something incompatible, we have to cancel and get a new one. This
// will mean that HWC will see a different output buffer between // will mean that HWC will see a different output buffer between

View File

@ -964,6 +964,12 @@ void SurfaceFlinger::postFramebuffer()
hwc.commit(); hwc.commit();
} }
// make the default display current because the VirtualDisplayDevice code cannot
// deal with dequeueBuffer() being called outside of the composition loop; however
// the code below can call glFlush() which is allowed (and does in some case) call
// dequeueBuffer().
getDefaultDisplayDevice()->makeCurrent(mEGLDisplay, mEGLContext);
for (size_t dpy=0 ; dpy<mDisplays.size() ; dpy++) { for (size_t dpy=0 ; dpy<mDisplays.size() ; dpy++) {
sp<const DisplayDevice> hw(mDisplays[dpy]); sp<const DisplayDevice> hw(mDisplays[dpy]);
const Vector< sp<Layer> >& currentLayers(hw->getVisibleLayersSortedByZ()); const Vector< sp<Layer> >& currentLayers(hw->getVisibleLayersSortedByZ());