diff options
| author | 2015-11-26 12:34:29 +0100 | |
|---|---|---|
| committer | 2015-12-10 16:02:05 +0800 | |
| commit | f49f8b0bad0c6cd5db1b603233ad008c5bac4a60 (patch) | |
| tree | 173819b517dad6d43598f0bd297e2bc173259adf | |
| parent | cb299b858f4f073e2abd4ad45aa944dc0dfd0aa2 (diff) | |
Camera2: create new streams if surface size has changed
When a new capture session is created, the old streams
are re-used if same surface and rotation. However, if the
surface has changed size, we must re-create the stream
to ensure HAL is configured properly, which includes
setting up proper sensor resolution.
This is an issue in e.g. CTS testNoiseReductionModes
and testEdgeModeControl, where a new preview with different
size can be setup without first stopping the previous one.
The same preview surface is used here, but with changed size.
Change-Id: I3b88a95209e83cf1cef0f4d1f791c87b0feb093f
Signed-off-by: Mikael Persson <mikael.persson@intel.com>
Signed-off-by: Zhiquan Liu <zhiquan.liu@intel.com>
| -rw-r--r-- | core/java/android/hardware/camera2/impl/CameraDeviceImpl.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java index 6e02df1f7131..8bfcc708f834 100644 --- a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java +++ b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java @@ -95,6 +95,8 @@ public class CameraDeviceImpl extends CameraDevice { new SimpleEntry<>(REQUEST_ID_NONE, null); private final SparseArray<OutputConfiguration> mConfiguredOutputs = new SparseArray<>(); + private final SparseArray<Size> mConfiguredOutputSizes = + new SparseArray<>(); private final String mCameraId; private final CameraCharacteristics mCharacteristics; @@ -388,7 +390,14 @@ public class CameraDeviceImpl extends CameraDevice { if (!outputs.contains(outConfig)) { deleteList.add(streamId); } else { - addSet.remove(outConfig); // Don't create a stream previously created + // Even if same surface and rotation, the surface can have re-sized. + // If so, we must create a new stream to ensure HAL is configured correctly. + Size outSize = SurfaceUtils.getSurfaceSize(outConfig.getSurface()); + if (!outSize.equals(mConfiguredOutputSizes.valueAt(i))) { + deleteList.add(streamId); + } else { + addSet.remove(outConfig); // Don't create a stream previously created + } } } @@ -421,13 +430,16 @@ public class CameraDeviceImpl extends CameraDevice { for (Integer streamId : deleteList) { mRemoteDevice.deleteStream(streamId); mConfiguredOutputs.delete(streamId); + mConfiguredOutputSizes.delete(streamId); } // Add all new streams for (OutputConfiguration outConfig : outputs) { if (addSet.contains(outConfig)) { int streamId = mRemoteDevice.createStream(outConfig); + Size outSize = SurfaceUtils.getSurfaceSize(outConfig.getSurface()); mConfiguredOutputs.put(streamId, outConfig); + mConfiguredOutputSizes.put(streamId, outSize); } } |