Skip to content

Commit

Permalink
Merge pull request #97589 from pkowal1982/fix_97454
Browse files Browse the repository at this point in the history
Fix error message on startup when camera is busy
  • Loading branch information
akien-mga committed Sep 28, 2024
2 parents 0e2a76d + 0178bb8 commit 1fc8208
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions modules/camera/camera_feed_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ String CameraFeedLinux::get_device_name() const {
}

bool CameraFeedLinux::activate_feed() {
ERR_FAIL_COND_V_MSG(selected_format == -1, false, "CameraFeed format needs to be set before activating.");
file_descriptor = open(device_name.ascii(), O_RDWR | O_NONBLOCK, 0);
if (_request_buffers() && _start_capturing()) {
buffer_decoder = _create_buffer_decoder();
Expand Down Expand Up @@ -302,16 +303,14 @@ Array CameraFeedLinux::get_formats() const {
}

CameraFeed::FeedFormat CameraFeedLinux::get_format() const {
return formats[selected_format];
FeedFormat feed_format = {};
return selected_format == -1 ? feed_format : formats[selected_format];
}

bool CameraFeedLinux::set_format(int p_index, const Dictionary &p_parameters) {
ERR_FAIL_COND_V_MSG(active, false, "Feed is active.");
ERR_FAIL_INDEX_V_MSG(p_index, formats.size(), false, "Invalid format index.");

parameters = p_parameters.duplicate();
selected_format = p_index;

FeedFormat feed_format = formats[p_index];

file_descriptor = open(device_name.ascii(), O_RDWR | O_NONBLOCK, 0);
Expand Down Expand Up @@ -344,6 +343,8 @@ bool CameraFeedLinux::set_format(int p_index, const Dictionary &p_parameters) {
}
close(file_descriptor);

parameters = p_parameters.duplicate();
selected_format = p_index;
emit_signal(SNAME("format_changed"));

return true;
Expand All @@ -353,7 +354,6 @@ CameraFeedLinux::CameraFeedLinux(const String &p_device_name) :
CameraFeed() {
device_name = p_device_name;
_query_device(device_name);
set_format(0, Dictionary());
}

CameraFeedLinux::~CameraFeedLinux() {
Expand Down

0 comments on commit 1fc8208

Please sign in to comment.