diff options
Diffstat (limited to 'services/camera/libcameraservice/CameraService.cpp')
-rw-r--r-- | services/camera/libcameraservice/CameraService.cpp | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index b178fd9..f306e4a 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -133,6 +133,8 @@ status_t CameraService::getCameraInfo(int cameraId, sp<ICamera> CameraService::connect( const sp<ICameraClient>& cameraClient, int cameraId) { int callingPid = getCallingPid(); + sp<CameraHardwareInterface> hardware = NULL; + LOG1("CameraService::connect E (pid %d, id %d)", callingPid, cameraId); if (!mModule) { @@ -187,10 +189,13 @@ sp<ICamera> CameraService::connect( char camera_device_name[10]; snprintf(camera_device_name, sizeof(camera_device_name), "%d", cameraId); - client = new Client(this, cameraClient, - new CameraHardwareInterface(&mModule->common, - camera_device_name), - cameraId, info.facing, callingPid); + hardware = new CameraHardwareInterface(camera_device_name); + if (hardware->initialize(&mModule->common) != OK) { + hardware.clear(); + return NULL; + } + + client = new Client(this, cameraClient, hardware, cameraId, info.facing, callingPid); mClient[cameraId] = client; LOG1("CameraService::connect X"); return client; @@ -278,9 +283,20 @@ void CameraService::setCameraFree(int cameraId) { // media players. static MediaPlayer* newMediaPlayer(const char *file) { + // Read the system property to determine if we have need to use the + // AUDIO_STREAM_ENFORCED_AUDIBLE type. + char value[PROPERTY_VALUE_MAX]; + property_get("ro.camera.sound.forced", value, "0"); + int audioStreamType; + if (strcmp(value, "0") != 0) { + audioStreamType = AUDIO_STREAM_ENFORCED_AUDIBLE; + } else { + audioStreamType = AUDIO_STREAM_MUSIC; + } + MediaPlayer* mp = new MediaPlayer(); if (mp->setDataSource(file, NULL) == NO_ERROR) { - mp->setAudioStreamType(AUDIO_STREAM_ENFORCED_AUDIBLE); + mp->setAudioStreamType(audioStreamType); mp->prepare(); } else { LOGE("Failed to load CameraService sounds: %s", file); @@ -849,16 +865,16 @@ status_t CameraService::Client::sendCommand(int32_t cmd, int32_t arg1, int32_t a if (result != NO_ERROR) return result; if (cmd == CAMERA_CMD_SET_DISPLAY_ORIENTATION) { - // The orientation cannot be set during preview. - if (mHardware->previewEnabled()) { - return INVALID_OPERATION; - } // Mirror the preview if the camera is front-facing. orientation = getOrientation(arg1, mCameraFacing == CAMERA_FACING_FRONT); if (orientation == -1) return BAD_VALUE; if (mOrientation != orientation) { mOrientation = orientation; + if (mPreviewWindow != 0) { + native_window_set_buffers_transform(mPreviewWindow.get(), + mOrientation); + } } return OK; } else if (cmd == CAMERA_CMD_ENABLE_SHUTTER_SOUND) { |