我正在尝试旋转相机捕获的图像。但是,AImageReader_acquireNextImage返回AMEDIA_IMGREADER_NO_BUFFER_AVAILABLE。我检查了该函数的返回值,该返回值表明队列中没有可用的缓冲区空间。我认为这意味着图像读取器的队列已满。有谁知道如何清除队列或解决此问题?源代码如下。 预先谢谢你。
//open camera device
openCamera(0, &mainCameraDevice);
mainNativeWindow = ANativeWindow_fromSurface(env, surface);
AImageReader *yuvReader_;
media_status_t m_status = AImageReader_new(640, 380, AIMAGE_FORMAT_YUV_420_888,
3, &yuvReader_);
if (m_status != AMEDIA_OK) {
LOGE("Failed to create AImageReader");
}
m_status = AImageReader_getWindow(yuvReader_, &mainNativeWindow);
if (m_status != AMEDIA_OK) {
LOGE("Could not get ANativeWindow");
}
ACaptureSessionOutput_create(mainNativeWindow, &mainSessionOutput);
ACaptureSessionOutputContainer_create(&mainCaptureSessionOutputContainer);
ACaptureSessionOutputContainer_add(mainCaptureSessionOutputContainer, mainSessionOutput);
ACameraOutputTarget_create(mainNativeWindow, &mainCameraOutputTarget);
ACameraDevice_createCaptureRequest(mainCameraDevice, TEMPLATE_PREVIEW, &mainCaptureRequest);
ACaptureRequest_addTarget(mainCaptureRequest, mainCameraOutputTarget);
ACameraDevice_createCaptureSession(mainCameraDevice, mainCaptureSessionOutputContainer, &captureSessionStateCallbacks, &mainCaptureSession);
ACameraCaptureSession_setRepeatingRequest(mainCaptureSession, NULL, 1, &mainCaptureRequest, NULL);
AImage *image;
m_status = AImageReader_acquireNextImage(yuvReader_, &image);
if (m_status == AMEDIA_IMGREADER_NO_BUFFER_AVAILABLE ) {
LOGI("invalid parameter");
}
if (m_status != AMEDIA_OK ) {
LOGI("invalid parameter");
}
AImage_delete(image);