void AudioSquall::loadSound(const char *name, Sound &s) { releaseSound(s); SquallSound &sound = (SquallSound &)s; sound.id = SQUALL_Sample_LoadFile(const_cast<char *>(name), 1, 0); if (sound.id < 0) { fatal("AudioSquall::load(): can`t load sound \"%s\".", name); } }
void SoundManager::removeSound(std::string name) { LookUpIterator it = soundLookup.find(name); if (it != soundLookup.end()) { name = it->second; soundLookup.erase(it); } releaseSound(name); }
sp<ICamera> CameraService::connect( const sp<ICameraClient>& cameraClient, int cameraId) { #ifdef MTK_CAMERAPROFILE_SUPPORT initCameraProfile(); AutoCPTLog cptlog(Event_CS_connect); #endif int callingPid = getCallingPid(); #ifdef VENDOR_EDIT //LiChen@CameraApp, 2013/03/07, Add for IntelligentSleep #ifdef OPPO_INTELLIGENT_SLEEP LOG1("CameraService::connect Intelligent Sleep (pid %d, id %d)", callingPid, cameraId); LOG1("CameraService::connect Intelligent mIntelSleepId %d", mIntelSleepId); switch (cameraId) { case CAMERA_INTELLIGENT_SLEEP: for(int i = 0 ; i < mNumberOfCameras; i ++) { if (mBusy[i]) { return NULL; } } cameraId = 1; mIntelSleepId = CAMERA_INTELLIGENT_SLEEP; break; default: if (mIntelSleepId == CAMERA_INTELLIGENT_SLEEP) { int cnt = 0; while (mClient[1].promote() == NULL && cnt < 10) { usleep(50000); cnt++; } if (mClient[1].promote() != NULL) { mClient[1].promote()->disconnect(); } } mIntelSleepId = -1; break; } #endif #endif /* VENDOR_EDIT */ LOG1("CameraService::connect E (pid %d, id %d)", callingPid, cameraId); if (!mModule) { ALOGE("Camera HAL module not loaded"); return NULL; } sp<Client> client; //!++ #if defined(ATVCHIP_MTK_ENABLE) if (cameraId == 0xFF) { // It's atv, the last cameraId is atv cameraId = mNumberOfCameras - 1; status_t status = setProperty( String8(MtkCameraParameters::PROPERTY_KEY_CLIENT_APPMODE), String8(MtkCameraParameters::APP_MODE_NAME_MTK_ATV) ); ALOGD("connected from atv - cameraId(%d) status(%d) \n", cameraId, status); } else if (cameraId < 0 || cameraId >= (mNumberOfCameras - 1)) { ALOGE("CameraService::connect X (pid %d) rejected (invalid cameraId %d), (mNumberOfCameras-1=%d).", callingPid, cameraId, (mNumberOfCameras-1)); return NULL; } #else if (cameraId < 0 || cameraId >= mNumberOfCameras) { ALOGE("CameraService::connect X (pid %d) rejected (invalid cameraId %d).", callingPid, cameraId); return NULL; } #endif //!-- char value[PROPERTY_VALUE_MAX]; property_get("sys.secpolicy.camera.disabled", value, "0"); if (strcmp(value, "1") == 0) { // Camera is disabled by DevicePolicyManager. ALOGI("Camera is disabled. connect X (pid %d) rejected", callingPid); return NULL; } Mutex::Autolock lock(mServiceLock); if (mClient[cameraId] != 0) { client = mClient[cameraId].promote(); if (client != 0) { if (cameraClient->asBinder() == client->getCameraClient()->asBinder()) { LOG1("CameraService::connect X (pid %d) (the same client)", callingPid); return client; } else { ALOGW("CameraService::connect X (pid %d) rejected (existing client).", callingPid); return NULL; } } mClient[cameraId].clear(); } if (mBusy[cameraId]) { ALOGW("CameraService::connect X (pid %d) rejected" " (camera %d is still busy).", callingPid, cameraId); return NULL; } struct camera_info info; if (mModule->get_camera_info(cameraId, &info) != OK) { ALOGE("Invalid camera id %d", cameraId); return NULL; } int deviceVersion; if (mModule->common.module_api_version == CAMERA_MODULE_API_VERSION_2_0) { deviceVersion = info.device_version; } else { deviceVersion = CAMERA_DEVICE_API_VERSION_1_0; } switch(deviceVersion) { case CAMERA_DEVICE_API_VERSION_1_0: client = new CameraClient(this, cameraClient, cameraId, info.facing, callingPid, getpid()); break; case CAMERA_DEVICE_API_VERSION_2_0: client = new Camera2Client(this, cameraClient, cameraId, info.facing, callingPid, getpid()); break; default: ALOGE("Unknown camera device HAL version: %d", deviceVersion); return NULL; } #ifdef MTK_CAMERA_BSP_SUPPORT // To avoid release/new MediaPlayer when switching between main/sub sensor, and it will reduce the switch time. #ifdef VENDOR_EDIT //LiChen@CameraApp, 2013/04/08, Remove for speeding up the opening camera loadSound(); #endif /* VENDOR_EDIT */ #endif #ifdef MTK_CAMERAPROFILE_SUPPORT CPTLog(Event_CS_newCamHwIF, CPTFlagStart); #endif if (client->initialize(mModule) != OK) { #ifdef MTK_CAMERAPROFILE_SUPPORT CPTLogStr(Event_CS_newCamHwIF, CPTFlagEnd, "new CameraHardwareInterface failed"); #endif #ifdef MTK_CAMERA_BSP_SUPPORT // To avoid release/new MediaPlayer when switching between main/sub sensor, and it will reduce the switch time. releaseSound(); #endif return NULL; } #ifdef MTK_CAMERAPROFILE_SUPPORT CPTLog(Event_CS_newCamHwIF, CPTFlagEnd); #endif cameraClient->asBinder()->linkToDeath(this); mClient[cameraId] = client; LOG1("CameraService::connect X (id %d, this pid is %d)", cameraId, getpid()); return client; }