Skip to content

Commit

Permalink
Fix videomode is null (#1513)
Browse files Browse the repository at this point in the history
There is a weird edge case at least with arducam/broken arducams/used
arducams where cscore will see it when pv starts but not be able to
connect to it. If we always read out the "current" video mode instead of
null when it is disconnected things will work. If the camera is
disconnected while we try to change the video mode when we get the
current video mode it will tell us what we wanted to set it to. Then
when the camera reconnects it will be in that video mode.
  • Loading branch information
Juniormunk authored Nov 1, 2024
1 parent 37aaa49 commit d7a7610
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ public void setGain(int gain) {

@Override
public VideoMode getCurrentVideoMode() {
return camera.isConnected() ? camera.getVideoMode() : null;
return camera
.getVideoMode(); // This returns the current video mode even if the camera is disconnected
}

@Override
Expand All @@ -250,7 +251,7 @@ public void setVideoModeInternal(VideoMode videoMode) {
logger.error("Got a null video mode! Doing nothing...");
return;
}
camera.setVideoMode(videoMode);
if (camera.setVideoMode(videoMode)) logger.debug("Failed to set video mode!");
} catch (Exception e) {
logger.error("Failed to set video mode!", e);
}
Expand Down

0 comments on commit d7a7610

Please sign in to comment.