diff options
author | Yin-Chia Yeh <yinchiayeh@google.com> | 2014-11-19 18:21:27 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-11-19 18:21:27 +0000 |
commit | a848844f5451d8e01c00b613daccbb901372779d (patch) | |
tree | 28618419fd09e2d4e9b5d6354a6f3ee461d94bf0 /services/camera | |
parent | 57426fc6486c6c2fa27f4bc6fcf3349282c3fdd7 (diff) | |
parent | cb79b3dbd377b1a3b6da2f58dfa49050400815ae (diff) | |
download | frameworks_av-a848844f5451d8e01c00b613daccbb901372779d.zip frameworks_av-a848844f5451d8e01c00b613daccbb901372779d.tar.gz frameworks_av-a848844f5451d8e01c00b613daccbb901372779d.tar.bz2 |
am cb79b3db: am 03181012: Merge "Camera2Client: remove recording stream if necessary" into lmp-mr1-dev
* commit 'cb79b3dbd377b1a3b6da2f58dfa49050400815ae':
Camera2Client: remove recording stream if necessary
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 3bdeab2..60939f9 100644 --- a/services/camera/libcameraservice/api1/Camera2Client.cpp +++ b/services/camera/libcameraservice/api1/Camera2Client.cpp @@ -930,13 +930,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); @@ -1207,6 +1200,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", @@ -1389,6 +1404,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 { |