VideoCapturerAndroid: Remove isDisposed()

Also remove the unnecessary code in VideoCapturerAndroid.dispose() and
only log instead.

BUG=webrtc:5519

Review-Url: https://codereview.webrtc.org/2007863005
Cr-Commit-Position: refs/heads/master@{#12913}
This commit is contained in:
magjed
2016-05-26 04:00:50 -07:00
committed by Commit bot
parent 2e15593803
commit cd8e2ba29b
2 changed files with 1 additions and 24 deletions

View File

@ -223,7 +223,6 @@ public class VideoCapturerAndroidTestFixtures {
static public void release(VideoCapturerAndroid capturer) { static public void release(VideoCapturerAndroid capturer) {
assertNotNull(capturer); assertNotNull(capturer);
capturer.dispose(); capturer.dispose();
assertTrue(capturer.isDisposed());
} }
static public void startCapturerAndRender(VideoCapturerAndroid capturer) static public void startCapturerAndRender(VideoCapturerAndroid capturer)
@ -238,7 +237,6 @@ public class VideoCapturerAndroidTestFixtures {
track.dispose(); track.dispose();
source.dispose(); source.dispose();
factory.dispose(); factory.dispose();
assertTrue(capturer.isDisposed());
} }
static public void switchCamera(VideoCapturerAndroid capturer) throws InterruptedException { static public void switchCamera(VideoCapturerAndroid capturer) throws InterruptedException {
@ -278,7 +276,6 @@ public class VideoCapturerAndroidTestFixtures {
track.dispose(); track.dispose();
source.dispose(); source.dispose();
factory.dispose(); factory.dispose();
assertTrue(capturer.isDisposed());
} }
static public void cameraEventsInvoked(VideoCapturerAndroid capturer, CameraEvents events, static public void cameraEventsInvoked(VideoCapturerAndroid capturer, CameraEvents events,
@ -351,7 +348,6 @@ public class VideoCapturerAndroidTestFixtures {
track.dispose(); track.dispose();
source.dispose(); source.dispose();
factory.dispose(); factory.dispose();
assertTrue(capturer.isDisposed());
} }
static public void startStopWithDifferentResolutions(VideoCapturerAndroid capturer, static public void startStopWithDifferentResolutions(VideoCapturerAndroid capturer,
@ -526,7 +522,6 @@ public class VideoCapturerAndroidTestFixtures {
track.dispose(); track.dispose();
source.dispose(); source.dispose();
factory.dispose(); factory.dispose();
assertTrue(capturer.isDisposed());
// Return the frame(s), on a different thread out of spite. // Return the frame(s), on a different thread out of spite.
final List<I420Frame> pendingFrames = renderer.waitForPendingFrames(); final List<I420Frame> pendingFrames = renderer.waitForPendingFrames();
@ -604,7 +599,6 @@ public class VideoCapturerAndroidTestFixtures {
track.dispose(); track.dispose();
source.dispose(); source.dispose();
factory.dispose(); factory.dispose();
assertTrue(capturer.isDisposed());
assertTrue(gotExpectedResolution); assertTrue(gotExpectedResolution);
} }

View File

@ -47,7 +47,6 @@ public class VideoCapturerAndroid implements
private final static String TAG = "VideoCapturerAndroid"; private final static String TAG = "VideoCapturerAndroid";
private static final int CAMERA_STOP_TIMEOUT_MS = 7000; private static final int CAMERA_STOP_TIMEOUT_MS = 7000;
private boolean isDisposed = false;
private android.hardware.Camera camera; // Only non-null while capturing. private android.hardware.Camera camera; // Only non-null while capturing.
private final Object handlerLock = new Object(); private final Object handlerLock = new Object();
// |cameraThreadHandler| must be synchronized on |handlerLock| when not on the camera thread, // |cameraThreadHandler| must be synchronized on |handlerLock| when not on the camera thread,
@ -257,25 +256,9 @@ public class VideoCapturerAndroid implements
} }
} }
// Dispose the SurfaceTextureHelper. This needs to be done manually, otherwise the
// SurfaceTextureHelper thread and resources will not be garbage collected.
@Override @Override
public void dispose() { public void dispose() {
Logging.d(TAG, "release"); Logging.d(TAG, "dispose");
if (isDisposed()) {
throw new IllegalStateException("Already released");
}
synchronized (handlerLock) {
if (cameraThreadHandler != null) {
throw new IllegalStateException("dispose() called while camera is running");
}
}
isDisposed = true;
}
// Used for testing purposes to check if dispose() has been called.
public boolean isDisposed() {
return isDisposed;
} }
// Note that this actually opens the camera, and Camera callbacks run on the // Note that this actually opens the camera, and Camera callbacks run on the