From 2cec0dfa9f97b87733b8b250b49729fc6bb3a60a Mon Sep 17 00:00:00 2001 From: Ruchit Sharma Date: Wed, 20 Aug 2014 16:02:08 -0400 Subject: Camera2Client: flush requests in stopPreviewL Requests queued in the pipeline have little meaning after the app calls stopPreview(). Flushing will help improve the switch KPI. bug 17340914 Change-Id: I899d69aa3b0fd41f028760290a81013297712fed --- services/camera/libcameraservice/api1/Camera2Client.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/services/camera/libcameraservice/api1/Camera2Client.cpp b/services/camera/libcameraservice/api1/Camera2Client.cpp index 6e7824e..dcab4ad 100644 --- a/services/camera/libcameraservice/api1/Camera2Client.cpp +++ b/services/camera/libcameraservice/api1/Camera2Client.cpp @@ -917,6 +917,15 @@ void Camera2Client::stopPreviewL() { ALOGE("%s: Camera %d: Can't stop streaming: %s (%d)", __FUNCTION__, mCameraId, strerror(-res), res); } + + // Flush all in-process captures and buffer in order to stop + // preview faster. + res = mDevice->flush(); + if (res != OK) { + ALOGE("%s: Camera %d: Unable to flush pending requests: %s (%d)", + __FUNCTION__, mCameraId, strerror(-res), res); + } + res = mDevice->waitUntilDrained(); if (res != OK) { ALOGE("%s: Camera %d: Waiting to stop streaming failed: %s (%d)", -- cgit v1.1