File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
core/src/main/java/edu/wpi/grip/core/sources Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -350,7 +350,23 @@ public void onSourceRemovedEvent(SourceRemovedEvent event) throws InterruptedExc
350350 // a new camera source is added. For webcam sources, this means that the video stream
351351 // won't be freed and new sources won't be able to connect to the webcam until the
352352 // application is closed.
353- this .stopAndAwait ();
353+ if (StandardSystemProperty .OS_NAME .value ().toLowerCase ().contains ("mac" )) {
354+ // Workaround for #716. This affects webcams as well as IP camera sources.
355+ // Use only stopAsync() to avoid blocking. Since we have no way of knowing when
356+ // the capture has actually been freed, we use a dumb delay to try to make sure it's
357+ // freed before returning. THIS IS NOT A GOOD SOLUTION. But it's the best one we have
358+ // until the bug is fixed.
359+ stopAsync ();
360+ try {
361+ // Wait a bit to try to make sure the capture is actually freed before returning
362+ Thread .sleep (100 );
363+ } catch (InterruptedException ignore ) {
364+ // We did our best. Hopefully, the webcam has been freed at this point.
365+ Thread .currentThread ().interrupt ();
366+ }
367+ } else {
368+ this .stopAndAwait ();
369+ }
354370 } finally {
355371 this .eventBus .unregister (this );
356372 }
You can’t perform that action at this time.
0 commit comments