From e2d83756cb088db15fda73616ca097b8d190e1a1 Mon Sep 17 00:00:00 2001 From: Zhijun He Date: Mon, 23 Jun 2014 10:22:37 -0700 Subject: Camera: Clear ZSL buffer queue when jpeg size is changed Bug: 15284653 Change-Id: I4778e8443945d918801102ba600874568bde12dc --- services/camera/libcameraservice/api1/Camera2Client.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/services/camera/libcameraservice/api1/Camera2Client.cpp b/services/camera/libcameraservice/api1/Camera2Client.cpp index a6f5a6c..0b6ad92 100644 --- a/services/camera/libcameraservice/api1/Camera2Client.cpp +++ b/services/camera/libcameraservice/api1/Camera2Client.cpp @@ -753,6 +753,7 @@ status_t Camera2Client::startPreviewL(Parameters ¶ms, bool restart) { // ever take a picture. // TODO: Find a better compromise, though this likely would involve HAL // changes. + int lastJpegStreamId = mJpegProcessor->getStreamId(); res = updateProcessorStream(mJpegProcessor, params); if (res != OK) { ALOGE("%s: Camera %d: Can't pre-configure still image " @@ -760,6 +761,7 @@ status_t Camera2Client::startPreviewL(Parameters ¶ms, bool restart) { __FUNCTION__, mCameraId, strerror(-res), res); return res; } + bool jpegStreamChanged = mJpegProcessor->getStreamId() != lastJpegStreamId; Vector outputStreams; bool callbacksEnabled = (params.previewCallbackFlags & @@ -815,6 +817,12 @@ status_t Camera2Client::startPreviewL(Parameters ¶ms, bool restart) { __FUNCTION__, mCameraId, strerror(-res), res); return res; } + + if (jpegStreamChanged) { + ALOGV("%s: Camera %d: Clear ZSL buffer queue when Jpeg size is changed", + __FUNCTION__, mCameraId); + mZslProcessor->clearZslQueue(); + } outputStreams.push(getZslStreamId()); } else { mZslProcessor->deleteStream(); @@ -1268,6 +1276,7 @@ status_t Camera2Client::takePicture(int msgType) { ALOGV("%s: Camera %d: Starting picture capture", __FUNCTION__, mCameraId); + int lastJpegStreamId = mJpegProcessor->getStreamId(); res = updateProcessorStream(mJpegProcessor, l.mParameters); if (res != OK) { ALOGE("%s: Camera %d: Can't set up still image stream: %s (%d)", @@ -1275,6 +1284,14 @@ status_t Camera2Client::takePicture(int msgType) { return res; } takePictureCounter = ++l.mParameters.takePictureCounter; + + // Clear ZSL buffer queue when Jpeg size is changed. + bool jpegStreamChanged = mJpegProcessor->getStreamId() != lastJpegStreamId; + if (l.mParameters.zslMode && jpegStreamChanged) { + ALOGV("%s: Camera %d: Clear ZSL buffer queue when Jpeg size is changed", + __FUNCTION__, mCameraId); + mZslProcessor->clearZslQueue(); + } } ATRACE_ASYNC_BEGIN(kTakepictureLabel, takePictureCounter); -- cgit v1.1