diff options
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 42a5507..3b4939e 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 815cc55..3aa4df2 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 { |