android: CameraDevice: Add stop()

This adds CameraDevice::stop(), which cleans up the member
variables of CameraDevice. It is called in CameraDevice::close()
and CameraDevice::configureStreams().

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Hirokazu Honda 2021-04-02 11:12:37 +09:00 committed by Laurent Pinchart
parent 796109c8dc
commit 0b661d70ec
2 changed files with 14 additions and 7 deletions

View file

@ -754,9 +754,18 @@ void CameraDevice::close()
{
streams_.clear();
stop();
camera_->release();
}
void CameraDevice::stop()
{
if (!running_)
return;
worker_.stop();
camera_->stop();
camera_->release();
running_ = false;
}
@ -1642,12 +1651,8 @@ PixelFormat CameraDevice::toPixelFormat(int format) const
*/
int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
{
/* Before any configuration attempt, stop the camera if it's running. */
if (running_) {
worker_.stop();
camera_->stop();
running_ = false;
}
/* Before any configuration attempt, stop the camera. */
stop();
if (stream_list->num_streams == 0) {
LOG(HAL, Error) << "No streams in configuration";