@@ -138,6 +138,45 @@ public abstract class CameraCaptureSession implements AutoCloseable {
138138 */
139139 public abstract void prepare (@ NonNull Surface surface ) throws CameraAccessException ;
140140
141+
142+ /**
143+ * <p>Free all buffers allocated for an output Surface.</p>
144+ *
145+ * <p>Normally, once allocated, the image buffers for a given output Surface remain allocated
146+ * for the lifetime of the capture session, to minimize latency of captures and to reduce
147+ * memory allocation overhead.</p>
148+ *
149+ * <p>However, in some cases, it may be desirable for allocated buffers to be freed to reduce
150+ * the application's memory consumption, if the particular output Surface will not be used by
151+ * the application for some time.</p>
152+ *
153+ * <p>The tearDown() method can be used to perform this operation. After the call finishes, all
154+ * unfilled image buffers will have been freed. Any future use of the target Surface may require
155+ * allocation of additional buffers, as if the session had just been created. Buffers being
156+ * held by the application (either explicitly as Image objects from ImageReader, or implicitly
157+ * as the current texture in a SurfaceTexture or the current contents of a RS Allocation, will
158+ * remain valid and allocated even when tearDown is invoked.</p>
159+ *
160+ * <p>A Surface that has had tearDown() called on it is eligible to have prepare() invoked on it
161+ * again even if it was used as a request target before the tearDown() call, as long as it
162+ * doesn't get used as a target of a request between the tearDown() and prepare() calls.</p>
163+ *
164+ * @param surface the output Surface for which buffers should be freed. Must be one of the
165+ * the output Surfaces used to create this session.
166+ *
167+ * @throws CameraAccessException if the camera device is no longer connected or has
168+ * encountered a fatal error.
169+ * @throws IllegalStateException if this session is no longer active, either because the session
170+ * was explicitly closed, a new session has been created
171+ * or the camera device has been closed.
172+ * @throws IllegalArgumentException if the Surface is invalid, not part of this Session, or has
173+ * already been used as a target of a CaptureRequest in this
174+ * session or immediately prior sessions.
175+ *
176+ * @hide
177+ */
178+ public abstract void tearDown (@ NonNull Surface surface ) throws CameraAccessException ;
179+
141180 /**
142181 * <p>Submit a request for an image to be captured by the camera device.</p>
143182 *
0 commit comments