void* TestThreadFunc(void *arg) { ::prctl(PR_SET_NAME,"TestThread", 0, 0, 0); MUINT32 sensorId = reinterpret_cast<MUINT32>(arg); // uint32_t sensorArray[1]; IHalSensorList* const pHalSensorList = IHalSensorList::get(); IHalSensor* pSensorHalObj = pHalSensorList->createSensor(LOG_TAG, sensorId); if(pSensorHalObj == NULL) { MY_LOGE("mpSensorHalObj is NULL"); } // sensorArray[0] = sensorId; pSensorHalObj->powerOn(LOG_TAG, 1, &sensorArray[0]); // IHal3A* pHal3a = IHal3A::createInstance(IHal3A::E_Camera_1, sensorId, LOG_TAG); sp<ICamAdapter> pAdapter = createMtkDefaultCamAdapter(String8("Default"), sensorId, NULL); // MY_LOGD("init (%d)", sensorId); pAdapter->init(); MY_LOGD("startPreview (%d)", sensorId); pAdapter->startPreview(); // ::sem_wait(&g_semTestThreadStart); // usleep(10000000); // MY_LOGD("stopPreview (%d)", sensorId); pAdapter->stopPreview(); MY_LOGD("uninit (%d)", sensorId); pAdapter->uninit(); // ::sem_post(&g_semTestThreadEnd); // pHal3a->destroyInstance(LOG_TAG); // if(pSensorHalObj) { pSensorHalObj->powerOff(LOG_TAG, 1, &sensorArray[0]); pSensorHalObj->destroyInstance(LOG_TAG); pSensorHalObj = NULL; } return NULL; }
int test_pip_preview(int argc, char** argv) { int ret = 0; if( argc < 2 ) { printf("Usage: camtest 1(PIP preview) <open_id>\n"); printf("open_id: 0(main->sub), 1(sub->main) \n"); return -1; } // MY_LOGD("Sensor:list get"); uint32_t sensorArray[1]; IHalSensorList* const pHalSensorList = IHalSensorList::get(); MY_LOGD("Sensor:search"); pHalSensorList->searchSensors(); // MUINT32 sensorId = atoi(argv[1]); // IHalSensor* pSensorHalObj = pHalSensorList->createSensor(LOG_TAG, sensorId); if(pSensorHalObj == NULL) { MY_LOGE("mpSensorHalObj is NULL"); } // sensorArray[0] = sensorId; pSensorHalObj->powerOn(LOG_TAG, 1, &sensorArray[0]); // IHal3A* pHal3a = IHal3A::createInstance(IHal3A::E_Camera_1, sensorId, LOG_TAG); // sp<ICamAdapter> pAdapter = createMtkDefaultCamAdapter(String8("Default"), sensorId, NULL); // sem_init(&g_semTestThreadStart, 0, 0); sem_init(&g_semTestThreadEnd, 0, 0); pthread_attr_t const attr = {0, NULL, 1024 * 1024, 4096, SCHED_RR, 90}; pthread_create(&g_TestThread, &attr, TestThreadFunc, (sensorId == 0) ? (void*)1 : (void*)0); // MY_LOGD("init (%d)", sensorId); pAdapter->init(); MY_LOGD("startPreview (%d)", sensorId); pAdapter->startPreview(); // ::sem_post(&g_semTestThreadStart); // usleep(10000000); // ::sem_wait(&g_semTestThreadEnd); // MY_LOGD("stopPreview (%d)", sensorId); pAdapter->stopPreview(); MY_LOGD("uninit (%d)", sensorId); pAdapter->uninit(); // pHal3a->destroyInstance(LOG_TAG); // if(pSensorHalObj) { pSensorHalObj->powerOff(LOG_TAG, 1, &sensorArray[0]); pSensorHalObj->destroyInstance(LOG_TAG); pSensorHalObj = NULL; } // return ret; }