diff options
author | Eino-Ville Talvala <etalvala@google.com> | 2013-08-27 16:49:04 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-08-27 16:49:04 +0000 |
commit | fb3d78118b59cf7e44d780c6a0a050f3b3a7076e (patch) | |
tree | be4847dba3053cdc101377f54749e6300b9be9de /core/java/android | |
parent | 4a9c7fec662315d9da48f0f5f99313f270424b48 (diff) | |
parent | 8ebd52bf4166a5ef8b7e91c9e3ecce2ce27cff12 (diff) | |
download | frameworks_base-fb3d78118b59cf7e44d780c6a0a050f3b3a7076e.zip frameworks_base-fb3d78118b59cf7e44d780c6a0a050f3b3a7076e.tar.gz frameworks_base-fb3d78118b59cf7e44d780c6a0a050f3b3a7076e.tar.bz2 |
Merge "Camera2: Add CameraDevice#flush()" into klp-dev
Diffstat (limited to 'core/java/android')
3 files changed, 56 insertions, 2 deletions
diff --git a/core/java/android/hardware/camera2/CameraDevice.java b/core/java/android/hardware/camera2/CameraDevice.java index 848d7bc..a4a56d7 100644 --- a/core/java/android/hardware/camera2/CameraDevice.java +++ b/core/java/android/hardware/camera2/CameraDevice.java @@ -303,7 +303,8 @@ public interface CameraDevice extends AutoCloseable { * preview or other continuous stream of frames, without having to submit * requests through {@link #capture} at video rates.</p> * - * <p>To stop the repeating capture, call {@link #stopRepeating}</p> + * <p>To stop the repeating capture, call {@link #stopRepeating}. Calling + * {@link #flush} will also clear the request.</p> * * <p>Calling repeat will replace a burst set up by {@link * #setRepeatingBurst}, although any in-progress burst will be @@ -323,6 +324,8 @@ public interface CameraDevice extends AutoCloseable { * @see #capture * @see #captureBurst * @see #setRepeatingBurst + * @see #stopRepeating + * @see #flush */ public void setRepeatingRequest(CaptureRequest request, CaptureListener listener) throws CameraAccessException; @@ -348,7 +351,8 @@ public interface CameraDevice extends AutoCloseable { * requests through {@link #capture} at video rates.</p> * * <p>To stop the repeating capture, call {@link #stopRepeating}. Any - * ongoing burst will still be completed, however.</p> + * ongoing burst will still be completed, however. Calling + * {@link #flush} will also clear the request.</p> * * <p>Calling repeatBurst will replace a repeating request set up by * {@link #setRepeatingRequest}, although any in-progress capture will be completed @@ -367,6 +371,8 @@ public interface CameraDevice extends AutoCloseable { * @see #capture * @see #captureBurst * @see #setRepeatingRequest + * @see #stopRepeating + * @see #flush */ public void setRepeatingBurst(List<CaptureRequest> requests, CaptureListener listener) throws CameraAccessException; @@ -435,6 +441,38 @@ public interface CameraDevice extends AutoCloseable { public void setErrorListener(ErrorListener listener); /** + * Flush all captures currently pending and in-progress as fast as + * possible. + * + * <p>The camera device will discard all of its current work as fast as + * possible. Some in-flight captures may complete successfully and call + * {@link CaptureListener#onCaptureComplete}, while others will trigger + * their {@link CaptureListener#onCaptureFailed} callbacks. If a repeating + * request or a repeating burst is set, it will be cleared by the flush.</p> + * + * <p>This method is the fastest way to idle the camera device for + * reconfiguration with {@link #configureOutputs}, at the cost of discarding + * in-progress work. Once the flush is complete, the idle callback will be + * called.</p> + * + * <p>Flushing will introduce at least a brief pause in the stream of data + * from the camera device, since once the flush is complete, the first new + * request has to make it through the entire camera pipeline before new + * output buffers are produced.</p> + * + * <p>This means that using {@code flush()} to simply remove pending + * requests is not recommended; it's best used for quickly switching output + * configurations, or for cancelling long in-progress requests (such as a + * multi-second capture).</p> + * + * @throws CameraAccessException if the camera device is no longer connected + * @see #setRepeatingRequest + * @see #setRepeatingBurst + * @see #configureOutputs + */ + public void flush() throws CameraAccessException; + + /** * Close the connection to this camera device. After this call, all calls to * the camera device interface will throw a {@link IllegalStateException}, * except for calls to close(). diff --git a/core/java/android/hardware/camera2/ICameraDeviceUser.aidl b/core/java/android/hardware/camera2/ICameraDeviceUser.aidl index 5a9b72f..b1724de 100644 --- a/core/java/android/hardware/camera2/ICameraDeviceUser.aidl +++ b/core/java/android/hardware/camera2/ICameraDeviceUser.aidl @@ -45,4 +45,6 @@ interface ICameraDeviceUser int getCameraInfo(out CameraMetadata info); int waitUntilIdle(); + + int flush(); } diff --git a/core/java/android/hardware/camera2/impl/CameraDevice.java b/core/java/android/hardware/camera2/impl/CameraDevice.java index ac9f591..64e4dc9 100644 --- a/core/java/android/hardware/camera2/impl/CameraDevice.java +++ b/core/java/android/hardware/camera2/impl/CameraDevice.java @@ -280,6 +280,20 @@ public class CameraDevice implements android.hardware.camera2.CameraDevice { } @Override + public void flush() throws CameraAccessException { + synchronized (mLock) { + try { + mRemoteDevice.flush(); + } catch (CameraRuntimeException e) { + throw e.asChecked(); + } catch (RemoteException e) { + // impossible + return; + } + } + } + + @Override public void close() throws Exception { // TODO: every method should throw IllegalStateException after close has been called |