Merge "Camera: fix NPE in buffer error callback" into qt-qpr1-dev

This commit is contained in:
TreeHugger Robot
2019-09-14 07:46:58 +00:00
committed by Android (Google) Code Review

View File

@@ -1026,34 +1026,35 @@ public class CameraDeviceImpl extends CameraDevice
// callback is valid // callback is valid
executor = checkExecutor(executor, callback); executor = checkExecutor(executor, callback);
// Make sure that there all requests have at least 1 surface; all surfaces are non-null; synchronized(mInterfaceLock) {
// the surface isn't a physical stream surface for reprocessing request checkIfCameraClosedOrInError();
for (CaptureRequest request : requestList) {
if (request.getTargets().isEmpty()) {
throw new IllegalArgumentException(
"Each request must have at least one Surface target");
}
for (Surface surface : request.getTargets()) { // Make sure that there all requests have at least 1 surface; all surfaces are non-null;
if (surface == null) { // the surface isn't a physical stream surface for reprocessing request
throw new IllegalArgumentException("Null Surface targets are not allowed"); for (CaptureRequest request : requestList) {
if (request.getTargets().isEmpty()) {
throw new IllegalArgumentException(
"Each request must have at least one Surface target");
} }
for (int i = 0; i < mConfiguredOutputs.size(); i++) { for (Surface surface : request.getTargets()) {
OutputConfiguration configuration = mConfiguredOutputs.valueAt(i); if (surface == null) {
if (configuration.isForPhysicalCamera() throw new IllegalArgumentException("Null Surface targets are not allowed");
&& configuration.getSurfaces().contains(surface)) { }
if (request.isReprocess()) {
throw new IllegalArgumentException( for (int i = 0; i < mConfiguredOutputs.size(); i++) {
"Reprocess request on physical stream is not allowed"); OutputConfiguration configuration = mConfiguredOutputs.valueAt(i);
if (configuration.isForPhysicalCamera()
&& configuration.getSurfaces().contains(surface)) {
if (request.isReprocess()) {
throw new IllegalArgumentException(
"Reprocess request on physical stream is not allowed");
}
} }
} }
} }
} }
}
synchronized(mInterfaceLock) {
checkIfCameraClosedOrInError();
if (repeating) { if (repeating) {
stopRepeating(); stopRepeating();
} }
@@ -2343,14 +2344,21 @@ public class CameraDeviceImpl extends CameraDevice
if (errorCode == ERROR_CAMERA_BUFFER) { if (errorCode == ERROR_CAMERA_BUFFER) {
// Because 1 stream id could map to multiple surfaces, we need to specify both // Because 1 stream id could map to multiple surfaces, we need to specify both
// streamId and surfaceId. // streamId and surfaceId.
List<Surface> surfaces = OutputConfiguration config = mConfiguredOutputs.get(
mConfiguredOutputs.get(resultExtras.getErrorStreamId()).getSurfaces(); resultExtras.getErrorStreamId());
for (Surface surface : surfaces) { if (config == null) {
Log.v(TAG, String.format(
"Stream %d has been removed. Skipping buffer lost callback",
resultExtras.getErrorStreamId()));
return;
}
for (Surface surface : config.getSurfaces()) {
if (!request.containsTarget(surface)) { if (!request.containsTarget(surface)) {
continue; continue;
} }
if (DEBUG) { if (DEBUG) {
Log.v(TAG, String.format("Lost output buffer reported for frame %d, target %s", Log.v(TAG, String.format(
"Lost output buffer reported for frame %d, target %s",
frameNumber, surface)); frameNumber, surface));
} }
failureDispatch = new Runnable() { failureDispatch = new Runnable() {