diff options
Diffstat (limited to 'src/android')
-rw-r--r-- | src/android/camera_device.cpp | 10 | ||||
-rw-r--r-- | src/android/camera_device.h | 8 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index d7f24101..2c23366c 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -404,7 +404,7 @@ CameraDevice::Camera3RequestDescriptor::Camera3RequestDescriptor( */ CameraDevice::CameraDevice(unsigned int id, std::shared_ptr<Camera> camera) - : id_(id), running_(false), camera_(std::move(camera)), + : id_(id), state_(State::Stopped), camera_(std::move(camera)), facing_(CAMERA_FACING_FRONT), orientation_(0) { camera_->requestCompleted.connect(this, &CameraDevice::requestComplete); @@ -799,14 +799,14 @@ void CameraDevice::close() void CameraDevice::stop() { - if (!running_) + if (state_ == State::Stopped) return; worker_.stop(); camera_->stop(); descriptors_.clear(); - running_ = false; + state_ = State::Stopped; } void CameraDevice::setCallbacks(const camera3_callback_ops_t *callbacks) @@ -1900,7 +1900,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques return -EINVAL; /* Start the camera if that's the first request we handle. */ - if (!running_) { + if (state_ == State::Stopped) { worker_.start(); int ret = camera_->start(); @@ -1909,7 +1909,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques return ret; } - running_ = true; + state_ = State::Running; } /* diff --git a/src/android/camera_device.h b/src/android/camera_device.h index decf1754..70c29755 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -89,6 +89,11 @@ private: int androidFormat; }; + enum class State { + Stopped, + Running, + }; + void stop(); int initializeStreamConfigurations(); @@ -115,7 +120,8 @@ private: CameraWorker worker_; - bool running_; + State state_; + std::shared_ptr<libcamera::Camera> camera_; std::unique_ptr<libcamera::CameraConfiguration> config_; |