void CameraHandler::closeCameraConnect() { if (camera == NULL) { LOGI("... camera is already NULL"); return; } camera->stopPreview(); camera->disconnect(); camera.clear(); camera = NULL; // ATTENTION!!!!!!!!!!!!!!!!!!!!!!!!!! // When we set // camera=NULL // above, the pointed instance of android::Camera object is destructed, // since this member `camera' has type android::sp<Camera> (android smart pointer template class), // and this is the only pointer to it. // // BUT this instance of CameraHandler is set as a listener for that android::Camera object // (see the function CameraHandler::initCameraConnect above), // so this instance of CameraHandler is pointed from that android::Camera object as // sp<CameraListener> mListener // and there is no other android smart pointers to this. // // It means, when that instance of the android::Camera object is destructed, // it calls destructor for this CameraHandler instance too. // // So, this line `camera=NULL' causes to the call `delete this' // (see destructor of the template class android::sp) // // So, we must not call `delete this' after the line, since it just has been called indeed }
void com_mediatek_effect_FaceBeautyEffect_release(JNIEnv* env, jobject thiz) { MY_LOGI("[%s]", __func__); if (g_effectClientFB != 0) { MY_LOGD("disconnect"); g_effectClientFB->disconnect(); return; } }
/** * Clean up and stop camera module */ int CaptureCommand::capture_cleanup() { if (mHardwareActive) { mCamera->stopPreview(); mLooper->stop(); // Close camera if (NULL != mCamera.get()) { mCamera->disconnect(); mCamera.clear(); } } mHardwareActive = false; notifyCameraEvent("stopped"); return 0; }
/*! */ void camera_deinit(void) { LOGE("%s into",__FUNCTION__); #ifdef VIDEO_SUBDEV if( video_subdev_handle != INVALID_HANDLE ) { ::close (video_subdev_handle); video_subdev_handle = INVALID_HANDLE; } #endif /* Release camera */ if( pCamera != 0 ) { camera_streamoff(); LOGE("Disconnect Camera"); pCamera->disconnect(); pCamera = NULL; } if( pBuffers ) { free(pBuffers); pBuffers = NULL; nNumBuffers = 0; } pthread_mutex_destroy(&accessQueue); #ifdef CAMERA_FOR_SCANNER int temp = 20001; if(fd>=0)write(fd,"20001",5); close(fd); close(fd_scanner1); #endif LOGE("%s exit",__FUNCTION__); }
~AfterConnect() { c->disconnect(); c.clear(); cc.clear(); cs.clear(); }
/*! \return 0 on success, otherwise error code */ int camera_open(void) { LOGE("%s",__FUNCTION__); CameraParameters params; status_t rtn; /* Open video device */ #ifdef CAMERA_FOR_SCANNER //pCamera = CameraScanner::connect(0); #ifdef CAMERA_FOR_SCANNER fd = open("/sys/devices/platform/image_sensor/currDrvIndex",O_RDWR); if(fd<0) { LOGE("Cannot open currDrvIndex\n"); return -1; } int temp = 20002; write(fd,"20002",5); fd_scanner1 = open(SE955_CHANNEL_NAME, O_RDONLY); #endif pCamera = Camera::connect(1); #else pCamera = CameraScanner::connect(ANDROID_CAMERA_ID); //pCamera = CameraScanner::connect(0); #endif if( pCamera == 0) { LOGE("Cannot connect to camera %d of: %i, %s\n", ANDROID_CAMERA_ID, errno, strerror(errno)); return -errno; } LOGE("Camera %d \n", ANDROID_CAMERA_ID); #ifdef CAMERA_FOR_SCANNER pCamera->setListener(&scannerListener); //enable data callback #else pCamera->setScannerListener(&scannerListener); //enable data callback #endif #ifdef VIDEO_SUBDEV /* Open subdevice */ video_subdev_handle = ::open(VIDEO_SUBDEV, O_RDWR); if (video_subdev_handle == -1) { LOGE("ERROR opening %s: %d\n", VIDEO_SUBDEV, errno); return -errno; } LOGE("Subdevice: %s, handle = %d\n", VIDEO_SUBDEV, video_subdev_handle); #endif ImagerProps.width = 256; ImagerProps.height = 64; #ifdef CAMERA_FOR_SCANNER //ImagerProps.width = 624; //ImagerProps.height = 474; ImagerProps.width = 640; ImagerProps.height = 480; ImagerProps.mount = 2; ImagerProps.i2c_addr_sensor = 0x48; ImagerProps.i2c_addr_psoc = 0x40; ImagerProps.i2c_addr_clock = 0x69; #else if( 0 != camera_ioctl(HSM_GET_PROPERTIES, &ImagerProps) ) { pCamera->disconnect(); LOGE("HSM_GET_PROPERTIES error %d\n", errno); return -1; } #endif #ifdef CAMERA_FOR_SCANNER #else LOGE("Image size = %dx%d\n", ImagerProps.width, ImagerProps.height); #endif cbBufLength = ImagerProps.height * ImagerProps.width; params.unflatten(pCamera->getParameters()); params.set("mtk-cam-mode", 1); #if 0 //def CAMERA_FOR_SCANNER #else params.set("scanner-mode", "on"); #endif params.setPreviewSize(ImagerProps.width, ImagerProps.height); //params.setPreviewFormat("yuv422i-yuyv"); // FIXME: "raw" //params.setPreviewFormat("yuv420sp"); // FIXME: "raw" rtn = pCamera->setParameters(params.flatten()); if( rtn != OK ) { LOGE("setParameters error %d\n", rtn); } #ifdef CAMERA_FOR_SCANNER if(fd>=0)write(fd,"20001",5); #endif #if 0 rtn = pCamera->setPreviewTexture(dummy_texture); // FIXME: Is there a dummy texture? if( rtn != OK ) { KIL_ERR("setPreviewDisplay error %d\n", rtn); } #endif return 0; }
JNIEXPORT void JNICALL Java_com_mediatek_ut_SurfaceFlingerTest_disconnect(JNIEnv /**_env*/, jobject /*_this*/, jint id) { LOGD("disconnect"); utProc->disconnect(id); LOGI("disconnect, id=%d, utProc=%p", id, utProc.get()); }