pull/696/head
Mattia Iavarone 6 years ago
parent 5d01aa5033
commit 075f6e3bfe
  1. 13
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/CameraIntegrationTest.java
  2. 15
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera1Engine.java

@ -207,20 +207,22 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
return argument.getReason() == CameraException.REASON_VIDEO_FAILED;
}
}));
int maxLoops = 20;
int loops = 0;
// First wait for onVideoRecordingEnd().
LOG.i("[WAIT VIDEO]", "Waiting for onVideoRecordingEnd()...");
Boolean wait1Result = wait1.await(DELAY);
// It seems that when running all the tests together, the device can go in some
// power saving mode which makes the CPU extremely slow. This is especially problematic
// with video snapshots where we do lots of processing. The videoEnd callback can return
// long after the actual stop() call, so if we're still processing, let's wait more.
LOG.i("[WAIT VIDEO]", "Waiting for onVideoRecordingEnd()...");
Boolean wait1Result = wait1.await(DELAY);
if (expectSuccess) {
while (wait1Result == null) {
while (wait1Result == null && loops <= maxLoops) {
LOG.w("[WAIT VIDEO]", "Waiting extra", DELAY, "milliseconds...");
wait1.listen();
wait1Result = wait1.await(DELAY);
loops++;
}
}
@ -228,10 +230,11 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
LOG.i("[WAIT VIDEO]", "Waiting for onVideoTaken()...");
VideoResult wait2Result = wait2.await(DELAY);
if (expectSuccess) {
while (wait2Result == null) {
while (wait2Result == null && loops <= maxLoops) {
LOG.w("[WAIT VIDEO]", "Waiting extra", DELAY, "milliseconds...");
wait2.listen();
wait2Result = wait2.await(DELAY);
loops++;
}
}

@ -73,20 +73,15 @@ public class Camera1Engine extends CameraEngine implements
@Override
public void onError(int error, Camera camera) {
if (error == Camera.CAMERA_ERROR_SERVER_DIED) {
// Looks like this is recoverable.
LOG.w("Recoverable error inside the onError callback.",
"CAMERA_ERROR_SERVER_DIED");
restart();
return;
}
String message = LOG.e("Internal Camera1 error.", error);
Exception runtime = new RuntimeException(message);
int reason;
switch (error) {
case Camera.CAMERA_ERROR_EVICTED: reason = CameraException.REASON_DISCONNECTED; break;
case Camera.CAMERA_ERROR_UNKNOWN: reason = CameraException.REASON_UNKNOWN; break;
case Camera.CAMERA_ERROR_SERVER_DIED:
case Camera.CAMERA_ERROR_EVICTED:
reason = CameraException.REASON_DISCONNECTED; break;
case Camera.CAMERA_ERROR_UNKNOWN: // Pass DISCONNECTED which is considered unrecoverable
reason = CameraException.REASON_DISCONNECTED; break;
default: reason = CameraException.REASON_UNKNOWN;
}
throw new CameraException(runtime, reason);

Loading…
Cancel
Save