From eec0f7ebac85d3d1b1151e62b2ed0f25c138d447 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 1 Jul 2011 14:53:49 -0700 Subject: return an error code with gralloc buffer allocation failures Change-Id: I471e5d37ea7a42fc8a0f93446ee3b4229da37807 --- libs/gui/IGraphicBufferAlloc.cpp | 13 ++++++++----- libs/gui/SurfaceTexture.cpp | 6 ++++-- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'libs') diff --git a/libs/gui/IGraphicBufferAlloc.cpp b/libs/gui/IGraphicBufferAlloc.cpp index 0cd51da539ed..30f8d003c850 100644 --- a/libs/gui/IGraphicBufferAlloc.cpp +++ b/libs/gui/IGraphicBufferAlloc.cpp @@ -43,7 +43,7 @@ public: } virtual sp createGraphicBuffer(uint32_t w, uint32_t h, - PixelFormat format, uint32_t usage) { + PixelFormat format, uint32_t usage, status_t* error) { Parcel data, reply; data.writeInterfaceToken(IGraphicBufferAlloc::getInterfaceDescriptor()); data.writeInt32(w); @@ -52,14 +52,15 @@ public: data.writeInt32(usage); remote()->transact(CREATE_GRAPHIC_BUFFER, data, &reply); sp graphicBuffer; - bool nonNull = (bool)reply.readInt32(); - if (nonNull) { + status_t result = reply.readInt32(); + if (result == NO_ERROR) { graphicBuffer = new GraphicBuffer(); reply.read(*graphicBuffer); // reply.readStrongBinder(); // here we don't even have to read the BufferReference from // the parcel, it'll die with the parcel. } + *error = result; return graphicBuffer; } }; @@ -91,8 +92,10 @@ status_t BnGraphicBufferAlloc::onTransact( uint32_t h = data.readInt32(); PixelFormat format = data.readInt32(); uint32_t usage = data.readInt32(); - sp result(createGraphicBuffer(w, h, format, usage)); - reply->writeInt32(result != 0); + status_t error; + sp result = + createGraphicBuffer(w, h, format, usage, &error); + reply->writeInt32(error); if (result != 0) { reply->write(*result); // We add a BufferReference to this parcel to make sure the diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp index 3bf6477cf208..886a3fb22263 100644 --- a/libs/gui/SurfaceTexture.cpp +++ b/libs/gui/SurfaceTexture.cpp @@ -352,11 +352,13 @@ status_t SurfaceTexture::dequeueBuffer(int *outBuf, uint32_t w, uint32_t h, ((uint32_t(buffer->usage) & usage) != usage)) { usage |= GraphicBuffer::USAGE_HW_TEXTURE; + status_t error; sp graphicBuffer( - mGraphicBufferAlloc->createGraphicBuffer(w, h, format, usage)); + mGraphicBufferAlloc->createGraphicBuffer( + w, h, format, usage, &error)); if (graphicBuffer == 0) { LOGE("dequeueBuffer: SurfaceComposer::createGraphicBuffer failed"); - return NO_MEMORY; + return error; } if (updateFormat) { mPixelFormat = format; -- cgit v1.2.3-59-g8ed1b