int StreamAdapter::cancel_buffer(const camera2_stream_ops_t* w, buffer_handle_t* buffer) { int state = static_cast<const StreamAdapter*>(w)->mState; if (state != ACTIVE) { ALOGE("%s: Called when in bad state: %d", __FUNCTION__, state); return INVALID_OPERATION; } ANativeWindow *a = toANW(w); return a->cancelBuffer(a, container_of(buffer, ANativeWindowBuffer, handle), -1); }
int IOMXHWBuffer_Cancel( void *window, void *p_handle ) { ANativeWindow *anw = (ANativeWindow *)window; ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle; status_t err = NO_ERROR; CHECK_ANW(); CHECK_ANB(); #if ANDROID_API >= 18 err = anw->cancelBuffer_DEPRECATED( anw, anb ); #else err = anw->cancelBuffer( anw, anb ); #endif CHECK_ERR(); return 0; }
void OmxDecoder::ReleaseAllPendingVideoBuffersLocked() { Vector<BufferItem> releasingVideoBuffers; { Mutex::Autolock autoLock(mPendingVideoBuffersLock); int size = mPendingVideoBuffers.size(); for (int i = 0; i < size; i++) { releasingVideoBuffers.push(mPendingVideoBuffers[i]); } mPendingVideoBuffers.clear(); } // Free all pending video buffers without holding mPendingVideoBuffersLock. int size = releasingVideoBuffers.size(); for (int i = 0; i < size; i++) { MediaBuffer *buffer; buffer = releasingVideoBuffers[i].mMediaBuffer; #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17 android::sp<Fence> fence; int fenceFd = -1; fence = releasingVideoBuffers[i].mReleaseFenceHandle.mFence; if (fence.get() && fence->isValid()) { fenceFd = fence->dup(); } MOZ_ASSERT(buffer->refcount() == 1); // This code expect MediaBuffer's ref count is 1. // Return gralloc buffer to ANativeWindow ANativeWindow* window = static_cast<ANativeWindow*>(mNativeWindowClient.get()); window->cancelBuffer(window, buffer->graphicBuffer().get(), fenceFd); // Mark MediaBuffer as rendered. // When gralloc buffer is directly returned to ANativeWindow, // this mark is necesary. sp<MetaData> metaData = buffer->meta_data(); metaData->setInt32(kKeyRendered, 1); #endif // Return MediaBuffer to OMXCodec. buffer->release(); } releasingVideoBuffers.clear(); }