Ejemplo n.º 1
0
sp<PipelineModelBase::HalImageStreamBufferPoolT>
PipelineModelBase::
replaceHalStreamBufferPoolLocked(
    android::sp<IImageStreamInfo> pStreamInfo,
    android::sp<HalImageStreamBufferPoolT> pPool
)
{
    if  ( pStreamInfo == 0 ) {
        MY_LOGE("NULL IImageStreamInfo");
        return NULL;
    }
    //
    if(mHalImageStreamBufferPoolMap.indexOfKey(pStreamInfo->getStreamId()) >= 0)
        mHalImageStreamBufferPoolMap.replaceValueFor(pStreamInfo->getStreamId(), pPool);
    else
        mHalImageStreamBufferPoolMap.add(pStreamInfo->getStreamId(), pPool);
    return pPool;
}
Ejemplo n.º 2
0
sp<PipelineModelBase::HalImageStreamBufferPoolT>
PipelineModelBase::
addHalStreamBufferPoolLocked(
    android::sp<IImageStreamInfo> pStreamInfo
)
{
    if  ( pStreamInfo == 0 ) {
        MY_LOGE("NULL IImageStreamInfo");
        return NULL;
    }
    //
    String8 const name = String8::format("%s:%s", getName(), pStreamInfo->getStreamName());
    //
    IImageStreamInfo::BufPlanes_t const& bufPlanes = pStreamInfo->getBufPlanes();
    size_t bufStridesInBytes[3] = {0};
    size_t bufBoundaryInBytes[3]= {0};
    for (size_t i = 0; i < bufPlanes.size(); i++) {
        bufStridesInBytes[i] = bufPlanes[i].rowStrideInBytes;
    }
    IImageBufferAllocator::ImgParam const imgParam(
        pStreamInfo->getImgFormat(),
        pStreamInfo->getImgSize(),
        bufStridesInBytes, bufBoundaryInBytes,
        bufPlanes.size()
    );
    sp<HalImageStreamBufferPoolT>
    pPool = new HalImageStreamBufferPoolT(
        name.string(),
        HalImageStreamBufferAllocatorT(pStreamInfo.get(), imgParam)
    );
    if  ( pPool == 0 ) {
        MY_LOGE("Fail to new a image pool:%s", name.string());
        return NULL;
    }
    //
    MERROR err = pPool->initPool(getName(), pStreamInfo->getMaxBufNum(), pStreamInfo->getMinInitBufNum());
    if  ( OK != err ) {
        MY_LOGE("%s: initPool err:%d(%s)", name.string(), err, ::strerror(-err));
        return NULL;
    }
    if  ( OK != pPool->commitPool(getName()) ) {
        MY_LOGE("%s: commitPool err:%d(%s)", name.string(), err, ::strerror(-err));
        return NULL;
    }

    //
    mHalImageStreamBufferPoolMap.add(pStreamInfo->getStreamId(), pPool);
    return pPool;
}
Ejemplo n.º 3
0
MERROR
PipelineModelBase::
acquireHalStreamBuffer(
    android::sp<IImageStreamInfo> const pStreamInfo,
    android::sp<HalImageStreamBuffer>& rpStreamBuffer
)   const
{
    RWLock::AutoRLock _l(mRWLock);
    //
    StreamId_T const streamId = pStreamInfo->getStreamId();
    sp<HalImageStreamBufferPoolT> pPool = mHalImageStreamBufferPoolMap.valueFor(streamId);
    MY_LOGE_IF(pPool == 0, "NULL HalImageStreamBufferPool - stream:%#"PRIxPTR"(%s)", streamId, pStreamInfo->getStreamName());
    MERROR err = pPool == 0 ? UNKNOWN_ERROR : pPool->acquireFromPool(__FUNCTION__, rpStreamBuffer, ::s2ns(10));
    MY_LOGA_IF(
        OK!=err || rpStreamBuffer==0,
        "[acquireFromPool] err:%d(%s) pStreamBuffer:%p stream:%#"PRIxPTR"(%s)",
        err, ::strerror(-err), rpStreamBuffer.get(), streamId, pStreamInfo->getStreamName()
    );
    return err;
}