From 893068ad0ca0cce8428f5a358c86b81139399c07 Mon Sep 17 00:00:00 2001 From: Zhijun He Date: Mon, 30 Sep 2013 19:31:39 -0700 Subject: Camera: drop stale callback buffer Sometimes, when preview size is changed and preview callback is enabled, stale callback buffer from previous size could be delivered to callback processor because stop preview doesn't guarantee consumer side buffers are properly cleaned up. We need drop these buffers to avoid sending wrong data to app side. Bug: 11009183 Change-Id: If9281e8c02481f883872ce58dfd8660a06d56a47 --- .../camera/libcameraservice/api1/client2/CallbackProcessor.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'services/camera/libcameraservice/api1') diff --git a/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp b/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp index 9d8c4a1..d2ac79c 100644 --- a/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp +++ b/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp @@ -312,6 +312,16 @@ status_t CallbackProcessor::processNewCallback(sp &client) { return OK; } + if (imgBuffer.width != static_cast(l.mParameters.previewWidth) || + imgBuffer.height != static_cast(l.mParameters.previewHeight)) { + ALOGW("%s: The preview size has changed to %d x %d from %d x %d, this buffer is" + " no longer valid, dropping",__FUNCTION__, + l.mParameters.previewWidth, l.mParameters.previewHeight, + imgBuffer.width, imgBuffer.height); + mCallbackConsumer->unlockBuffer(imgBuffer); + return OK; + } + previewFormat = l.mParameters.previewFormat; useFlexibleYuv = l.mParameters.fastInfo.useFlexibleYuv && (previewFormat == HAL_PIXEL_FORMAT_YCrCb_420_SP || -- cgit v1.1