mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-15 00:19:44 +03:00
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>
This commit is contained in:
parent
f461ffb69a
commit
1f38e4c73f
2 changed files with 12 additions and 6 deletions
|
@ -404,7 +404,7 @@ CameraDevice::Camera3RequestDescriptor::Camera3RequestDescriptor(
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CameraDevice::CameraDevice(unsigned int id, std::shared_ptr<Camera> camera)
|
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)
|
facing_(CAMERA_FACING_FRONT), orientation_(0)
|
||||||
{
|
{
|
||||||
camera_->requestCompleted.connect(this, &CameraDevice::requestComplete);
|
camera_->requestCompleted.connect(this, &CameraDevice::requestComplete);
|
||||||
|
@ -799,14 +799,14 @@ void CameraDevice::close()
|
||||||
|
|
||||||
void CameraDevice::stop()
|
void CameraDevice::stop()
|
||||||
{
|
{
|
||||||
if (!running_)
|
if (state_ == State::Stopped)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
worker_.stop();
|
worker_.stop();
|
||||||
camera_->stop();
|
camera_->stop();
|
||||||
|
|
||||||
descriptors_.clear();
|
descriptors_.clear();
|
||||||
running_ = false;
|
state_ = State::Stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraDevice::setCallbacks(const camera3_callback_ops_t *callbacks)
|
void CameraDevice::setCallbacks(const camera3_callback_ops_t *callbacks)
|
||||||
|
@ -1900,7 +1900,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* Start the camera if that's the first request we handle. */
|
/* Start the camera if that's the first request we handle. */
|
||||||
if (!running_) {
|
if (state_ == State::Stopped) {
|
||||||
worker_.start();
|
worker_.start();
|
||||||
|
|
||||||
int ret = camera_->start();
|
int ret = camera_->start();
|
||||||
|
@ -1909,7 +1909,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
running_ = true;
|
state_ = State::Running;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -89,6 +89,11 @@ private:
|
||||||
int androidFormat;
|
int androidFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class State {
|
||||||
|
Stopped,
|
||||||
|
Running,
|
||||||
|
};
|
||||||
|
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
int initializeStreamConfigurations();
|
int initializeStreamConfigurations();
|
||||||
|
@ -115,7 +120,8 @@ private:
|
||||||
|
|
||||||
CameraWorker worker_;
|
CameraWorker worker_;
|
||||||
|
|
||||||
bool running_;
|
State state_;
|
||||||
|
|
||||||
std::shared_ptr<libcamera::Camera> camera_;
|
std::shared_ptr<libcamera::Camera> camera_;
|
||||||
std::unique_ptr<libcamera::CameraConfiguration> config_;
|
std::unique_ptr<libcamera::CameraConfiguration> config_;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue