SurfaceTextureClient.cpp revision 5bfc24515bb5c8ea7975f72d538df37753733a2f
1/* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#define LOG_TAG "SurfaceTextureClient" 18//#define LOG_NDEBUG 0 19 20#include <gui/SurfaceTextureClient.h> 21 22#include <utils/Log.h> 23 24namespace android { 25 26SurfaceTextureClient::SurfaceTextureClient( 27 const sp<ISurfaceTexture>& surfaceTexture) 28{ 29 SurfaceTextureClient::init(); 30 SurfaceTextureClient::setISurfaceTexture(surfaceTexture); 31} 32 33SurfaceTextureClient::SurfaceTextureClient() { 34 SurfaceTextureClient::init(); 35} 36 37void SurfaceTextureClient::init() { 38 // Initialize the ANativeWindow function pointers. 39 ANativeWindow::setSwapInterval = hook_setSwapInterval; 40 ANativeWindow::dequeueBuffer = hook_dequeueBuffer; 41 ANativeWindow::cancelBuffer = hook_cancelBuffer; 42 ANativeWindow::lockBuffer = hook_lockBuffer; 43 ANativeWindow::queueBuffer = hook_queueBuffer; 44 ANativeWindow::query = hook_query; 45 ANativeWindow::perform = hook_perform; 46 47 const_cast<int&>(ANativeWindow::minSwapInterval) = 0; 48 const_cast<int&>(ANativeWindow::maxSwapInterval) = 1; 49 50 mReqWidth = 0; 51 mReqHeight = 0; 52 mReqFormat = 0; 53 mReqUsage = 0; 54 mTimestamp = NATIVE_WINDOW_TIMESTAMP_AUTO; 55 mDefaultWidth = 0; 56 mDefaultHeight = 0; 57 mTransformHint = 0; 58 mConnectedToCpu = false; 59} 60 61void SurfaceTextureClient::setISurfaceTexture( 62 const sp<ISurfaceTexture>& surfaceTexture) 63{ 64 mSurfaceTexture = surfaceTexture; 65} 66 67sp<ISurfaceTexture> SurfaceTextureClient::getISurfaceTexture() const { 68 return mSurfaceTexture; 69} 70 71int SurfaceTextureClient::hook_setSwapInterval(ANativeWindow* window, int interval) { 72 SurfaceTextureClient* c = getSelf(window); 73 return c->setSwapInterval(interval); 74} 75 76int SurfaceTextureClient::hook_dequeueBuffer(ANativeWindow* window, 77 ANativeWindowBuffer** buffer) { 78 SurfaceTextureClient* c = getSelf(window); 79 return c->dequeueBuffer(buffer); 80} 81 82int SurfaceTextureClient::hook_cancelBuffer(ANativeWindow* window, 83 ANativeWindowBuffer* buffer) { 84 SurfaceTextureClient* c = getSelf(window); 85 return c->cancelBuffer(buffer); 86} 87 88int SurfaceTextureClient::hook_lockBuffer(ANativeWindow* window, 89 ANativeWindowBuffer* buffer) { 90 SurfaceTextureClient* c = getSelf(window); 91 return c->lockBuffer(buffer); 92} 93 94int SurfaceTextureClient::hook_queueBuffer(ANativeWindow* window, 95 ANativeWindowBuffer* buffer) { 96 SurfaceTextureClient* c = getSelf(window); 97 return c->queueBuffer(buffer); 98} 99 100int SurfaceTextureClient::hook_query(const ANativeWindow* window, 101 int what, int* value) { 102 const SurfaceTextureClient* c = getSelf(window); 103 return c->query(what, value); 104} 105 106int SurfaceTextureClient::hook_perform(ANativeWindow* window, int operation, ...) { 107 va_list args; 108 va_start(args, operation); 109 SurfaceTextureClient* c = getSelf(window); 110 return c->perform(operation, args); 111} 112 113int SurfaceTextureClient::setSwapInterval(int interval) { 114 // EGL specification states: 115 // interval is silently clamped to minimum and maximum implementation 116 // dependent values before being stored. 117 // Although we don't have to, we apply the same logic here. 118 119 if (interval < minSwapInterval) 120 interval = minSwapInterval; 121 122 if (interval > maxSwapInterval) 123 interval = maxSwapInterval; 124 125 status_t res = mSurfaceTexture->setSynchronousMode(interval ? true : false); 126 127 return res; 128} 129 130int SurfaceTextureClient::dequeueBuffer(android_native_buffer_t** buffer) { 131 LOGV("SurfaceTextureClient::dequeueBuffer"); 132 Mutex::Autolock lock(mMutex); 133 int buf = -1; 134 status_t result = mSurfaceTexture->dequeueBuffer(&buf, mReqWidth, mReqHeight, 135 mReqFormat, mReqUsage); 136 if (result < 0) { 137 LOGV("dequeueBuffer: ISurfaceTexture::dequeueBuffer(%d, %d, %d, %d)" 138 "failed: %d", mReqWidth, mReqHeight, mReqFormat, mReqUsage, 139 result); 140 return result; 141 } 142 sp<GraphicBuffer>& gbuf(mSlots[buf]); 143 if (result & ISurfaceTexture::RELEASE_ALL_BUFFERS) { 144 freeAllBuffers(); 145 } 146 147 if ((result & ISurfaceTexture::BUFFER_NEEDS_REALLOCATION) || gbuf == 0) { 148 result = mSurfaceTexture->requestBuffer(buf, &gbuf); 149 if (result != NO_ERROR) { 150 LOGE("dequeueBuffer: ISurfaceTexture::requestBuffer failed: %d", 151 result); 152 return result; 153 } 154 } 155 *buffer = gbuf.get(); 156 return OK; 157} 158 159int SurfaceTextureClient::cancelBuffer(android_native_buffer_t* buffer) { 160 LOGV("SurfaceTextureClient::cancelBuffer"); 161 Mutex::Autolock lock(mMutex); 162 int i = getSlotFromBufferLocked(buffer); 163 if (i < 0) { 164 return i; 165 } 166 mSurfaceTexture->cancelBuffer(i); 167 return OK; 168} 169 170int SurfaceTextureClient::getSlotFromBufferLocked( 171 android_native_buffer_t* buffer) const { 172 bool dumpedState = false; 173 for (int i = 0; i < NUM_BUFFER_SLOTS; i++) { 174 // XXX: Dump the slots whenever we hit a NULL entry while searching for 175 // a buffer. 176 if (mSlots[i] == NULL) { 177 if (!dumpedState) { 178 LOGD("getSlotFromBufferLocked: encountered NULL buffer in slot %d " 179 "looking for buffer %p", i, buffer->handle); 180 for (int j = 0; j < NUM_BUFFER_SLOTS; j++) { 181 if (mSlots[j] == NULL) { 182 LOGD("getSlotFromBufferLocked: %02d: NULL", j); 183 } else { 184 LOGD("getSlotFromBufferLocked: %02d: %p", j, mSlots[j]->handle); 185 } 186 } 187 dumpedState = true; 188 } 189 } 190 191 if (mSlots[i] != NULL && mSlots[i]->handle == buffer->handle) { 192 return i; 193 } 194 } 195 LOGE("getSlotFromBufferLocked: unknown buffer: %p", buffer->handle); 196 return BAD_VALUE; 197} 198 199int SurfaceTextureClient::lockBuffer(android_native_buffer_t* buffer) { 200 LOGV("SurfaceTextureClient::lockBuffer"); 201 Mutex::Autolock lock(mMutex); 202 return OK; 203} 204 205int SurfaceTextureClient::queueBuffer(android_native_buffer_t* buffer) { 206 LOGV("SurfaceTextureClient::queueBuffer"); 207 Mutex::Autolock lock(mMutex); 208 int64_t timestamp; 209 if (mTimestamp == NATIVE_WINDOW_TIMESTAMP_AUTO) { 210 timestamp = systemTime(SYSTEM_TIME_MONOTONIC); 211 LOGV("SurfaceTextureClient::queueBuffer making up timestamp: %.2f ms", 212 timestamp / 1000000.f); 213 } else { 214 timestamp = mTimestamp; 215 } 216 int i = getSlotFromBufferLocked(buffer); 217 if (i < 0) { 218 return i; 219 } 220 mSurfaceTexture->queueBuffer(i, timestamp, 221 &mDefaultWidth, &mDefaultHeight, &mTransformHint); 222 return OK; 223} 224 225int SurfaceTextureClient::query(int what, int* value) const { 226 LOGV("SurfaceTextureClient::query"); 227 { // scope for the lock 228 Mutex::Autolock lock(mMutex); 229 switch (what) { 230 case NATIVE_WINDOW_FORMAT: 231 if (mReqFormat) { 232 *value = mReqFormat; 233 return NO_ERROR; 234 } 235 break; 236 case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER: 237 *value = 0; 238 return NO_ERROR; 239 case NATIVE_WINDOW_CONCRETE_TYPE: 240 *value = NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT; 241 return NO_ERROR; 242 case NATIVE_WINDOW_DEFAULT_WIDTH: 243 *value = mDefaultWidth; 244 return NO_ERROR; 245 case NATIVE_WINDOW_DEFAULT_HEIGHT: 246 *value = mDefaultHeight; 247 return NO_ERROR; 248 case NATIVE_WINDOW_TRANSFORM_HINT: 249 *value = mTransformHint; 250 return NO_ERROR; 251 } 252 } 253 return mSurfaceTexture->query(what, value); 254} 255 256int SurfaceTextureClient::perform(int operation, va_list args) 257{ 258 int res = NO_ERROR; 259 switch (operation) { 260 case NATIVE_WINDOW_CONNECT: 261 // deprecated. must return NO_ERROR. 262 break; 263 case NATIVE_WINDOW_DISCONNECT: 264 // deprecated. must return NO_ERROR. 265 break; 266 case NATIVE_WINDOW_SET_USAGE: 267 res = dispatchSetUsage(args); 268 break; 269 case NATIVE_WINDOW_SET_CROP: 270 res = dispatchSetCrop(args); 271 break; 272 case NATIVE_WINDOW_SET_BUFFER_COUNT: 273 res = dispatchSetBufferCount(args); 274 break; 275 case NATIVE_WINDOW_SET_BUFFERS_GEOMETRY: 276 res = dispatchSetBuffersGeometry(args); 277 break; 278 case NATIVE_WINDOW_SET_BUFFERS_TRANSFORM: 279 res = dispatchSetBuffersTransform(args); 280 break; 281 case NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP: 282 res = dispatchSetBuffersTimestamp(args); 283 break; 284 case NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS: 285 res = dispatchSetBuffersDimensions(args); 286 break; 287 case NATIVE_WINDOW_SET_BUFFERS_FORMAT: 288 res = dispatchSetBuffersFormat(args); 289 break; 290 case NATIVE_WINDOW_LOCK: 291 res = dispatchLock(args); 292 break; 293 case NATIVE_WINDOW_UNLOCK_AND_POST: 294 res = dispatchUnlockAndPost(args); 295 break; 296 case NATIVE_WINDOW_SET_SCALING_MODE: 297 res = dispatchSetScalingMode(args); 298 break; 299 case NATIVE_WINDOW_API_CONNECT: 300 res = dispatchConnect(args); 301 break; 302 case NATIVE_WINDOW_API_DISCONNECT: 303 res = dispatchDisconnect(args); 304 break; 305 default: 306 res = NAME_NOT_FOUND; 307 break; 308 } 309 return res; 310} 311 312int SurfaceTextureClient::dispatchConnect(va_list args) { 313 int api = va_arg(args, int); 314 return connect(api); 315} 316 317int SurfaceTextureClient::dispatchDisconnect(va_list args) { 318 int api = va_arg(args, int); 319 return disconnect(api); 320} 321 322int SurfaceTextureClient::dispatchSetUsage(va_list args) { 323 int usage = va_arg(args, int); 324 return setUsage(usage); 325} 326 327int SurfaceTextureClient::dispatchSetCrop(va_list args) { 328 android_native_rect_t const* rect = va_arg(args, android_native_rect_t*); 329 return setCrop(reinterpret_cast<Rect const*>(rect)); 330} 331 332int SurfaceTextureClient::dispatchSetBufferCount(va_list args) { 333 size_t bufferCount = va_arg(args, size_t); 334 return setBufferCount(bufferCount); 335} 336 337int SurfaceTextureClient::dispatchSetBuffersGeometry(va_list args) { 338 int w = va_arg(args, int); 339 int h = va_arg(args, int); 340 int f = va_arg(args, int); 341 int err = setBuffersDimensions(w, h); 342 if (err != 0) { 343 return err; 344 } 345 return setBuffersFormat(f); 346} 347 348int SurfaceTextureClient::dispatchSetBuffersDimensions(va_list args) { 349 int w = va_arg(args, int); 350 int h = va_arg(args, int); 351 return setBuffersDimensions(w, h); 352} 353 354int SurfaceTextureClient::dispatchSetBuffersFormat(va_list args) { 355 int f = va_arg(args, int); 356 return setBuffersFormat(f); 357} 358 359int SurfaceTextureClient::dispatchSetScalingMode(va_list args) { 360 int m = va_arg(args, int); 361 return setScalingMode(m); 362} 363 364int SurfaceTextureClient::dispatchSetBuffersTransform(va_list args) { 365 int transform = va_arg(args, int); 366 return setBuffersTransform(transform); 367} 368 369int SurfaceTextureClient::dispatchSetBuffersTimestamp(va_list args) { 370 int64_t timestamp = va_arg(args, int64_t); 371 return setBuffersTimestamp(timestamp); 372} 373 374int SurfaceTextureClient::dispatchLock(va_list args) { 375 ANativeWindow_Buffer* outBuffer = va_arg(args, ANativeWindow_Buffer*); 376 ARect* inOutDirtyBounds = va_arg(args, ARect*); 377 return lock(outBuffer, inOutDirtyBounds); 378} 379 380int SurfaceTextureClient::dispatchUnlockAndPost(va_list args) { 381 return unlockAndPost(); 382} 383 384 385int SurfaceTextureClient::connect(int api) { 386 LOGV("SurfaceTextureClient::connect"); 387 Mutex::Autolock lock(mMutex); 388 int err = mSurfaceTexture->connect(api, 389 &mDefaultWidth, &mDefaultHeight, &mTransformHint); 390 if (!err && api == NATIVE_WINDOW_API_CPU) { 391 mConnectedToCpu = true; 392 } 393 return err; 394} 395 396int SurfaceTextureClient::disconnect(int api) { 397 LOGV("SurfaceTextureClient::disconnect"); 398 Mutex::Autolock lock(mMutex); 399 int err = mSurfaceTexture->disconnect(api); 400 if (!err && api == NATIVE_WINDOW_API_CPU) { 401 mConnectedToCpu = false; 402 } 403 return err; 404} 405 406int SurfaceTextureClient::setUsage(uint32_t reqUsage) 407{ 408 LOGV("SurfaceTextureClient::setUsage"); 409 Mutex::Autolock lock(mMutex); 410 mReqUsage = reqUsage; 411 return OK; 412} 413 414int SurfaceTextureClient::setCrop(Rect const* rect) 415{ 416 LOGV("SurfaceTextureClient::setCrop"); 417 Mutex::Autolock lock(mMutex); 418 419 Rect realRect; 420 if (rect == NULL || rect->isEmpty()) { 421 realRect = Rect(0, 0); 422 } else { 423 realRect = *rect; 424 } 425 426 status_t err = mSurfaceTexture->setCrop(*rect); 427 LOGE_IF(err, "ISurfaceTexture::setCrop(...) returned %s", strerror(-err)); 428 429 return err; 430} 431 432int SurfaceTextureClient::setBufferCount(int bufferCount) 433{ 434 LOGV("SurfaceTextureClient::setBufferCount"); 435 Mutex::Autolock lock(mMutex); 436 437 status_t err = mSurfaceTexture->setBufferCount(bufferCount); 438 LOGE_IF(err, "ISurfaceTexture::setBufferCount(%d) returned %s", 439 bufferCount, strerror(-err)); 440 441 if (err == NO_ERROR) { 442 freeAllBuffers(); 443 } 444 445 return err; 446} 447 448int SurfaceTextureClient::setBuffersDimensions(int w, int h) 449{ 450 LOGV("SurfaceTextureClient::setBuffersDimensions"); 451 Mutex::Autolock lock(mMutex); 452 453 if (w<0 || h<0) 454 return BAD_VALUE; 455 456 if ((w && !h) || (!w && h)) 457 return BAD_VALUE; 458 459 mReqWidth = w; 460 mReqHeight = h; 461 462 status_t err = mSurfaceTexture->setCrop(Rect(0, 0)); 463 LOGE_IF(err, "ISurfaceTexture::setCrop(...) returned %s", strerror(-err)); 464 465 return err; 466} 467 468int SurfaceTextureClient::setBuffersFormat(int format) 469{ 470 LOGV("SurfaceTextureClient::setBuffersFormat"); 471 Mutex::Autolock lock(mMutex); 472 473 if (format<0) 474 return BAD_VALUE; 475 476 mReqFormat = format; 477 478 return NO_ERROR; 479} 480 481int SurfaceTextureClient::setScalingMode(int mode) 482{ 483 LOGV("SurfaceTextureClient::setScalingMode(%d)", mode); 484 Mutex::Autolock lock(mMutex); 485 // mode is validated on the server 486 status_t err = mSurfaceTexture->setScalingMode(mode); 487 LOGE_IF(err, "ISurfaceTexture::setScalingMode(%d) returned %s", 488 mode, strerror(-err)); 489 490 return err; 491} 492 493int SurfaceTextureClient::setBuffersTransform(int transform) 494{ 495 LOGV("SurfaceTextureClient::setBuffersTransform"); 496 Mutex::Autolock lock(mMutex); 497 status_t err = mSurfaceTexture->setTransform(transform); 498 return err; 499} 500 501int SurfaceTextureClient::setBuffersTimestamp(int64_t timestamp) 502{ 503 LOGV("SurfaceTextureClient::setBuffersTimestamp"); 504 Mutex::Autolock lock(mMutex); 505 mTimestamp = timestamp; 506 return NO_ERROR; 507} 508 509void SurfaceTextureClient::freeAllBuffers() { 510 for (int i = 0; i < NUM_BUFFER_SLOTS; i++) { 511 mSlots[i] = 0; 512 } 513} 514 515// ---------------------------------------------------------------------- 516// the lock/unlock APIs must be used from the same thread 517 518static status_t copyBlt( 519 const sp<GraphicBuffer>& dst, 520 const sp<GraphicBuffer>& src, 521 const Region& reg) 522{ 523 // src and dst with, height and format must be identical. no verification 524 // is done here. 525 status_t err; 526 uint8_t const * src_bits = NULL; 527 err = src->lock(GRALLOC_USAGE_SW_READ_OFTEN, reg.bounds(), (void**)&src_bits); 528 LOGE_IF(err, "error locking src buffer %s", strerror(-err)); 529 530 uint8_t* dst_bits = NULL; 531 err = dst->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, reg.bounds(), (void**)&dst_bits); 532 LOGE_IF(err, "error locking dst buffer %s", strerror(-err)); 533 534 Region::const_iterator head(reg.begin()); 535 Region::const_iterator tail(reg.end()); 536 if (head != tail && src_bits && dst_bits) { 537 const size_t bpp = bytesPerPixel(src->format); 538 const size_t dbpr = dst->stride * bpp; 539 const size_t sbpr = src->stride * bpp; 540 541 while (head != tail) { 542 const Rect& r(*head++); 543 ssize_t h = r.height(); 544 if (h <= 0) continue; 545 size_t size = r.width() * bpp; 546 uint8_t const * s = src_bits + (r.left + src->stride * r.top) * bpp; 547 uint8_t * d = dst_bits + (r.left + dst->stride * r.top) * bpp; 548 if (dbpr==sbpr && size==sbpr) { 549 size *= h; 550 h = 1; 551 } 552 do { 553 memcpy(d, s, size); 554 d += dbpr; 555 s += sbpr; 556 } while (--h > 0); 557 } 558 } 559 560 if (src_bits) 561 src->unlock(); 562 563 if (dst_bits) 564 dst->unlock(); 565 566 return err; 567} 568 569// ---------------------------------------------------------------------------- 570 571status_t SurfaceTextureClient::lock( 572 ANativeWindow_Buffer* outBuffer, ARect* inOutDirtyBounds) 573{ 574 if (mLockedBuffer != 0) { 575 LOGE("Surface::lock failed, already locked"); 576 return INVALID_OPERATION; 577 } 578 579 if (!mConnectedToCpu) { 580 int err = SurfaceTextureClient::connect(NATIVE_WINDOW_API_CPU); 581 if (err) { 582 return err; 583 } 584 // we're intending to do software rendering from this point 585 setUsage(GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN); 586 } 587 588 ANativeWindowBuffer* out; 589 status_t err = dequeueBuffer(&out); 590 LOGE_IF(err, "dequeueBuffer failed (%s)", strerror(-err)); 591 if (err == NO_ERROR) { 592 sp<GraphicBuffer> backBuffer(GraphicBuffer::getSelf(out)); 593 err = lockBuffer(backBuffer.get()); 594 LOGE_IF(err, "lockBuffer (handle=%p) failed (%s)", 595 backBuffer->handle, strerror(-err)); 596 if (err == NO_ERROR) { 597 const Rect bounds(backBuffer->width, backBuffer->height); 598 599 Region newDirtyRegion; 600 if (inOutDirtyBounds) { 601 newDirtyRegion.set(static_cast<Rect const&>(*inOutDirtyBounds)); 602 newDirtyRegion.andSelf(bounds); 603 } else { 604 newDirtyRegion.set(bounds); 605 } 606 607 // figure out if we can copy the frontbuffer back 608 const sp<GraphicBuffer>& frontBuffer(mPostedBuffer); 609 const bool canCopyBack = (frontBuffer != 0 && 610 backBuffer->width == frontBuffer->width && 611 backBuffer->height == frontBuffer->height && 612 backBuffer->format == frontBuffer->format); 613 614 if (canCopyBack) { 615 // copy the area that is invalid and not repainted this round 616 const Region copyback(mOldDirtyRegion.subtract(newDirtyRegion)); 617 if (!copyback.isEmpty()) 618 copyBlt(backBuffer, frontBuffer, copyback); 619 } else { 620 // if we can't copy-back anything, modify the user's dirty 621 // region to make sure they redraw the whole buffer 622 newDirtyRegion.set(bounds); 623 } 624 625 // keep track of the are of the buffer that is "clean" 626 // (ie: that will be redrawn) 627 mOldDirtyRegion = newDirtyRegion; 628 629 if (inOutDirtyBounds) { 630 *inOutDirtyBounds = newDirtyRegion.getBounds(); 631 } 632 633 void* vaddr; 634 status_t res = backBuffer->lock( 635 GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN, 636 newDirtyRegion.bounds(), &vaddr); 637 638 LOGW_IF(res, "failed locking buffer (handle = %p)", 639 backBuffer->handle); 640 641 mLockedBuffer = backBuffer; 642 outBuffer->width = backBuffer->width; 643 outBuffer->height = backBuffer->height; 644 outBuffer->stride = backBuffer->stride; 645 outBuffer->format = backBuffer->format; 646 outBuffer->bits = vaddr; 647 } 648 } 649 return err; 650} 651 652status_t SurfaceTextureClient::unlockAndPost() 653{ 654 if (mLockedBuffer == 0) { 655 LOGE("Surface::unlockAndPost failed, no locked buffer"); 656 return INVALID_OPERATION; 657 } 658 659 status_t err = mLockedBuffer->unlock(); 660 LOGE_IF(err, "failed unlocking buffer (%p)", mLockedBuffer->handle); 661 662 err = queueBuffer(mLockedBuffer.get()); 663 LOGE_IF(err, "queueBuffer (handle=%p) failed (%s)", 664 mLockedBuffer->handle, strerror(-err)); 665 666 mPostedBuffer = mLockedBuffer; 667 mLockedBuffer = 0; 668 return err; 669} 670 671}; // namespace android 672