diff options
author | Yin-Chia Yeh <yinchiayeh@google.com> | 2014-11-19 18:09:30 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-11-19 18:09:31 +0000 |
commit | 03181012beab17e145ca8b9bedbcc08d117df1cb (patch) | |
tree | 3daf671d6fa40318dee8fb5d0ee73eab2fe68ffe /services/camera | |
parent | bbda5ce4782b20f3ed75482e5f73b8d999223438 (diff) | |
parent | 092d49c26d77fafad5170bf709c2a716ec335855 (diff) | |
download | frameworks_av-03181012beab17e145ca8b9bedbcc08d117df1cb.zip frameworks_av-03181012beab17e145ca8b9bedbcc08d117df1cb.tar.gz frameworks_av-03181012beab17e145ca8b9bedbcc08d117df1cb.tar.bz2 |
Merge "Camera2Client: remove recording stream if necessary" into lmp-mr1-dev
Diffstat (limited to 'services/camera')
3 files changed, 56 insertions, 7 deletions
diff --git a/services/camera/libcameraservice/api1/Camera2Client.cpp b/services/camera/libcameraservice/api1/Camera2Client.cpp index f3a88a1..6e7824e 100644 --- a/services/camera/libcameraservice/api1/Camera2Client.cpp +++ b/services/camera/libcameraservice/api1/Camera2Client.cpp @@ -929,13 +929,6 @@ void Camera2Client::stopPreviewL() { "stop preview: %s (%d)", __FUNCTION__, mCameraId, strerror(-res), res); } - { - // Ideally we should recover the override after recording stopped, but - // right now recording stream will live until here, so we are forced to - // recover here. TODO: find a better way to handle that (b/17495165) - SharedParameters::Lock l(mParameters); - l.mParameters.recoverOverriddenJpegSize(); - } // no break case Parameters::WAITING_FOR_PREVIEW_WINDOW: { SharedParameters::Lock l(mParameters); @@ -1206,6 +1199,28 @@ void Camera2Client::stopRecording() { mCameraService->playSound(CameraService::SOUND_RECORDING); + // Remove recording stream to prevent it from slowing down takePicture later + if (!l.mParameters.recordingHint && l.mParameters.isJpegSizeOverridden()) { + res = stopStream(); + if (res != OK) { + ALOGE("%s: Camera %d: Can't stop streaming: %s (%d)", + __FUNCTION__, mCameraId, strerror(-res), res); + } + res = mDevice->waitUntilDrained(); + if (res != OK) { + ALOGE("%s: Camera %d: Waiting to stop streaming failed: %s (%d)", + __FUNCTION__, mCameraId, strerror(-res), res); + } + // Clean up recording stream + res = mStreamingProcessor->deleteRecordingStream(); + if (res != OK) { + ALOGE("%s: Camera %d: Unable to delete recording stream before " + "stop preview: %s (%d)", + __FUNCTION__, mCameraId, strerror(-res), res); + } + l.mParameters.recoverOverriddenJpegSize(); + } + res = startPreviewL(l.mParameters, true); if (res != OK) { ALOGE("%s: Camera %d: Unable to return to preview", @@ -1388,6 +1403,34 @@ status_t Camera2Client::takePicture(int msgType) { return res; } l.mParameters.state = Parameters::STILL_CAPTURE; + + // Remove recording stream to prevent video snapshot jpeg logic kicking in + if (l.mParameters.isJpegSizeOverridden() && + mStreamingProcessor->getRecordingStreamId() != NO_STREAM) { + res = mStreamingProcessor->togglePauseStream(/*pause*/true); + if (res != OK) { + ALOGE("%s: Camera %d: Can't pause streaming: %s (%d)", + __FUNCTION__, mCameraId, strerror(-res), res); + } + res = mDevice->waitUntilDrained(); + if (res != OK) { + ALOGE("%s: Camera %d: Waiting to stop streaming failed: %s (%d)", + __FUNCTION__, mCameraId, strerror(-res), res); + } + // Clean up recording stream + res = mStreamingProcessor->deleteRecordingStream(); + if (res != OK) { + ALOGE("%s: Camera %d: Unable to delete recording stream before " + "stop preview: %s (%d)", + __FUNCTION__, mCameraId, strerror(-res), res); + } + res = mStreamingProcessor->togglePauseStream(/*pause*/false); + if (res != OK) { + ALOGE("%s: Camera %d: Can't unpause streaming: %s (%d)", + __FUNCTION__, mCameraId, strerror(-res), res); + } + l.mParameters.recoverOverriddenJpegSize(); + } break; case Parameters::RECORD: // Good to go for video snapshot diff --git a/services/camera/libcameraservice/api1/client2/Parameters.cpp b/services/camera/libcameraservice/api1/client2/Parameters.cpp index 74bbb9d..234247b 100644 --- a/services/camera/libcameraservice/api1/client2/Parameters.cpp +++ b/services/camera/libcameraservice/api1/client2/Parameters.cpp @@ -2203,6 +2203,10 @@ status_t Parameters::recoverOverriddenJpegSize() { return OK; } +bool Parameters::isJpegSizeOverridden() { + return pictureSizeOverriden; +} + const char* Parameters::getStateName(State state) { #define CASE_ENUM_TO_CHAR(x) case x: return(#x); break; switch(state) { diff --git a/services/camera/libcameraservice/api1/client2/Parameters.h b/services/camera/libcameraservice/api1/client2/Parameters.h index 389cb92..7e5be84 100644 --- a/services/camera/libcameraservice/api1/client2/Parameters.h +++ b/services/camera/libcameraservice/api1/client2/Parameters.h @@ -266,6 +266,8 @@ struct Parameters { status_t overrideJpegSizeByVideoSize(); // Recover overridden jpeg size. Called during stopRecording. status_t recoverOverriddenJpegSize(); + // if video snapshot size is currently overridden + bool isJpegSizeOverridden(); // Calculate the crop region rectangle based on current stream sizes struct CropRegion { |