Camera2: Fix prematurely clearing stream request

Zsl handling was clearing the stream request before a capture request
was ready to be sent to the HAL, which would cause capture delays and
timeouts in certain conditions.

Bug: 7259520
Change-Id: Idde8bc4fc58b8b426c6985feac87759740e338ea
diff --git a/services/camera/libcameraservice/camera2/CaptureSequencer.cpp b/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
index c9498c2..98aa380 100644
--- a/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
+++ b/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
@@ -289,13 +289,6 @@
     client->registerFrameListener(mCaptureId,
             this);
 
-    res = client->getCameraDevice()->clearStreamingRequest();
-    if (res != OK) {
-        ALOGE("%s: Camera %d: Unable to stop preview for ZSL capture: "
-                "%s (%d)",
-                __FUNCTION__, client->getCameraId(), strerror(-res), res);
-        return DONE;
-    }
     // TODO: Actually select the right thing here.
     res = processor->pushToReprocess(mCaptureId);
     if (res != OK) {
diff --git a/services/camera/libcameraservice/camera2/ZslProcessor.cpp b/services/camera/libcameraservice/camera2/ZslProcessor.cpp
index 1bcf97e..7977f9d 100644
--- a/services/camera/libcameraservice/camera2/ZslProcessor.cpp
+++ b/services/camera/libcameraservice/camera2/ZslProcessor.cpp
@@ -297,6 +297,14 @@
             return INVALID_OPERATION;
         }
 
+        res = client->getCameraDevice()->clearStreamingRequest();
+        if (res != OK) {
+            ALOGE("%s: Camera %d: Unable to stop preview for ZSL capture: "
+                "%s (%d)",
+                __FUNCTION__, client->getCameraId(), strerror(-res), res);
+            return INVALID_OPERATION;
+        }
+        // TODO: have push-and-clear be atomic
         res = client->getCameraDevice()->pushReprocessBuffer(mZslReprocessStreamId,
                 handle, this);
         if (res != OK) {