当前位置: 首页>>代码示例>>C++>>正文


C++ sp::detachNextBuffer方法代码示例

本文整理汇总了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);
}
开发者ID:MIPS,项目名称:frameworks-av,代码行数:31,代码来源:Camera3StreamSplitter.cpp

示例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();
    }
}
开发者ID:020gzh,项目名称:platform_frameworks_base,代码行数:24,代码来源:android_media_ImageWriter.cpp


注:本文中的sp::detachNextBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。