Skip to content

Commit

Permalink
Add checks for CameraDevice
Browse files Browse the repository at this point in the history
  • Loading branch information
Chi-EEE committed Apr 16, 2024
1 parent 702cb07 commit 7ce2772
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/rpi/common/src/car/system/device/CameraDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace car::system::device

void CameraDevice::update() {
std::lock_guard<std::mutex> lock(this->camera_mutex_);
if (!this->connected_ || !this->camera_->isOpened()) {
if (!this->connected_ || this->camera_ == nullptr || !this->camera_->isOpened()) {
this->frame_buffer_ = "";
return;
}
Expand All @@ -42,6 +42,7 @@ namespace car::system::device
void CameraDevice::stop() {
std::lock_guard<std::mutex> lock(this->camera_mutex_);
this->camera_->release();
this->connected_ = false;
}

void CameraDevice::disconnect() {
Expand Down

0 comments on commit 7ce2772

Please sign in to comment.