summaryrefslogtreecommitdiff
path: root/src/android/camera_device.cpp
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2021-05-06 18:10:42 +0200
committerJacopo Mondi <jacopo@jmondi.org>2021-06-14 12:26:27 +0200
commit1f38e4c73f5d39b366f75b774e76490850031532 (patch)
tree84e1d455472d29b80ad5179822c79f2f26f166e5 /src/android/camera_device.cpp
parentf461ffb69a85b6df6a8413cb7716e2b89414d64e (diff)
android: camera_device: Replace running_ with CameraState
The CameraDevice class maintains the camera state in the 'running_' boolean flag to check if the camera has to be started at the first received process_capture_request() call which happens after the camera had been stopped. So far this was correct, as the operations that change the camera could only start or stop the camera, so a simple boolean flag was enough. To prepare to handle the flush() operation that will introduce a new 'flushing' state, replace the simple plain boolean flag with an enumeration of values that define the CameraState. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/android/camera_device.cpp')
-rw-r--r--src/android/camera_device.cpp10
1 files changed, 5 insertions, 5 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;
}
/*