本文整理汇总了C++中sp::detachNextBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ sp::detachNextBuffer方法的具体用法?C++ sp::detachNextBuffer怎么用?C++ sp::detachNextBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sp
的用法示例。
在下文中一共展示了sp::detachNextBuffer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onAbandonedLocked
void Camera3StreamSplitter::onBufferReleasedByOutputLocked(
const sp<IGraphicBufferProducer>& from) {
ATRACE_CALL();
sp<GraphicBuffer> buffer;
sp<Fence> fence;
status_t res = from->detachNextBuffer(&buffer, &fence);
if (res == NO_INIT) {
// If we just discovered that this output has been abandoned, note that,
// but we can't do anything else, since buffer is invalid
onAbandonedLocked();
return;
} else if (res == NO_MEMORY) {
SP_LOGV("%s: No free buffers", __FUNCTION__);
return;
} else if (res != OK) {
SP_LOGE("%s: detaching buffer from output failed (%d)", __FUNCTION__, res);
return;
}
BufferTracker& tracker = *(mBuffers[buffer->getId()]);
// Merge the release fence of the incoming buffer so that the fence we send
// back to the input includes all of the outputs' fences
if (fence != nullptr && fence->isValid()) {
tracker.mergeFence(fence);
}
SP_LOGV("detached buffer %" PRId64 " %p from output %p",
buffer->getId(), buffer.get(), from.get());
// Check to see if this is the last outstanding reference to this buffer
decrementBufRefCountLocked(buffer->getId(), from);
}
示例2: onBufferReleased
void JNIImageWriterContext::onBufferReleased() {
ALOGV("%s: buffer released", __FUNCTION__);
bool needsDetach = false;
JNIEnv* env = getJNIEnv(&needsDetach);
if (env != NULL) {
// Detach the buffer every time when a buffer consumption is done,
// need let this callback give a BufferItem, then only detach if it was attached to this
// Writer. Do the detach unconditionally for opaque format now. see b/19977520
if (mFormat == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) {
sp<Fence> fence;
sp<GraphicBuffer> buffer;
ALOGV("%s: One buffer is detached", __FUNCTION__);
mProducer->detachNextBuffer(&buffer, &fence);
}
env->CallStaticVoidMethod(mClazz, gImageWriterClassInfo.postEventFromNative, mWeakThiz);
} else {
ALOGW("onBufferReleased event will not posted");
}
if (needsDetach) {
detachJNI();
}
}