分享

camera hal层buffer整理--未完成

 新用户8389DdzY 2021-09-22

问题:

logcat.txt:05-30 21:02:30.304 24824 15469 E QCamera : <HAL><ERROR> enqueueBuffer: 2004: enqueue_buffer failed, err = -38

logcat.txt:05-30 21:02:30.304 24824 15469 E QCamera : <HAL><ERROR> synchronous_stream_cb_routine: 831: Enqueue Buffer failed

logcat.txt:05-30 21:02:30.305 24867 24899 E Surface : queueBuffer: error queuing buffer to SurfaceTexture, -32

log中有这样的报错,所以调查buffer的分配、释放、管理。

enqueueBuffer的分析

int32_t QCameraGrallocMemory::enqueueBuffer(uint32_t index, nsecs_t timeStamp)

{

err = mWindow->enqueue_buffer(mWindow, (buffer_handle_t *)mBufferHandle[index]);

}

mWindow设置在如下函数:

void QCameraGrallocMemory::setWindowInfo(preview_stream_ops_t *window,

        int width, int height, int stride, int scanline, int format, int maxFPS, int usage

{

    mWindow = window;

    mWidth = width;

    mHeight = height;

    mStride = stride;

    mScanline = scanline;

    mFormat = format;

    mUsage = usage;

    setMaxFPS(maxFPS);

}

该函数的调用如下:

QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf(

        cam_stream_type_t stream_type, size_t size, int stride, int scanline,

        uint8_t &bufferCnt)

{

         case CAM_STREAM_TYPE_PREVIEW:

                   {

            if (isNoDisplayMode()) {

                mem = new QCameraStreamMemory(mGetMemory,

                        mCallbackCookie,

                        bCachedMem,

                        (bPoolMem) ? &m_memoryPool : NULL,

                        stream_type);

            } else {

                cam_dimension_t dim;

                int minFPS, maxFPS;

                QCameraGrallocMemory *grallocMemory = NULL;

                grallocMemory = new QCameraGrallocMemory(mGetMemory, mCallbackCookie);

                mParameters.getStreamDimension(stream_type, dim);

                /* we are interested only in maxfps here */

                mParameters.getPreviewFpsRange(&minFPS, &maxFPS);

                int usage = 0;

                if(mParameters.isUBWCEnabled()) {

                    cam_format_t fmt;

                    mParameters.getStreamFormat(CAM_STREAM_TYPE_PREVIEW,fmt);

                    if (fmt == CAM_FORMAT_YUV_420_NV12_UBWC) {

                        usage = GRALLOC_USAGE_PRIVATE_ALLOC_UBWC ;

                    }

                }

                if (grallocMemory) {

                    grallocMemory->setMappable(

                            CAMERA_INITIAL_MAPPABLE_PREVIEW_BUFFERS);

                    grallocMemory->setWindowInfo(mPreviewWindow,

                            dim.width,dim.height, stride, scanline,

                            mParameters.getPreviewHalPixelFormat(),

                            maxFPS, usage);

                    pthread_mutex_lock(&mGrallocLock);

                    if (bufferCnt > CAMERA_INITIAL_MAPPABLE_PREVIEW_BUFFERS) {

                        mEnqueuedBuffers = (bufferCnt -

                                CAMERA_INITIAL_MAPPABLE_PREVIEW_BUFFERS);

                    } else {

                        mEnqueuedBuffers = 0;

                    }

                    pthread_mutex_unlock(&mGrallocLock);

                }

                mem = grallocMemory;

            }

        }

}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多