Skip to content

Commit 103b8a8

Browse files
authored
Fix webcam sources failing to stop when opening saved projects (#686)
1 parent 7f1498c commit 103b8a8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/src/main/java/edu/wpi/grip/core/sources/CameraSource.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,12 @@ public void onSourceRemovedEvent(SourceRemovedEvent event) throws InterruptedExc
333333
TimeoutException, IOException {
334334
if (event.getSource() == this) {
335335
try {
336-
this.stopAsync();
336+
// Stop the camera service and wait for it to terminate.
337+
// If we just use stopAsync(), the camera service won't always have terminated by the time
338+
// a new camera source is added. For webcam sources, this means that the video stream
339+
// won't be freed and new sources won't be able to connect to the webcam until the
340+
// application is closed.
341+
this.stopAndAwait();
337342
} finally {
338343
this.eventBus.unregister(this);
339344
}

0 commit comments

Comments
 (0)