@@ -750,6 +750,15 @@ void CameraDevice::close()
camera_->release();
}
+int CameraDevice::flush()
+{
+ std::scoped_lock<std::mutex> halLock(halMutex_);
+
+ stop();
+
+ return 0;
+}
+
void CameraDevice::stop()
{
if (!running_)
@@ -760,6 +769,25 @@ void CameraDevice::stop()
{
std::scoped_lock<std::mutex> lock(mutex_);
+
+ for (auto &[cookie, descriptor] : descriptors_) {
+ LOG(HAL, Debug) << "request is canceled: " << cookie;
+
+ camera3_capture_result_t captureResult = {};
+ captureResult.frame_number = descriptor.frameNumber_;
+ captureResult.num_output_buffers = descriptor.buffers_.size();
+ for (camera3_stream_buffer_t &buffer : descriptor.buffers_) {
+ buffer.acquire_fence = -1;
+ buffer.release_fence = -1;
+ buffer.status = CAMERA3_BUFFER_STATUS_ERROR;
+ }
+ captureResult.output_buffers = descriptor.buffers_.data();
+
+ notifyError(descriptor.frameNumber_,
+ descriptor.buffers_[0].stream);
+ callbacks_->process_capture_result(callbacks_, &captureResult);
+ }
+
descriptors_.clear();
}
@@ -41,6 +41,7 @@ public:
int open(const hw_module_t *hardwareModule);
void close();
+ int flush();
unsigned int id() const { return id_; }
camera3_device_t *camera3Device() { return &camera3Device_; }
@@ -66,9 +66,13 @@ static void hal_dev_dump([[maybe_unused]] const struct camera3_device *dev,
{
}
-static int hal_dev_flush([[maybe_unused]] const struct camera3_device *dev)
+static int hal_dev_flush(const struct camera3_device *dev)
{
- return 0;
+ if (!dev)
+ return -EINVAL;
+
+ CameraDevice *camera = reinterpret_cast<CameraDevice *>(dev->priv);
+ return camera->flush();
}
int hal_dev_close(hw_device_t *hw_device)
This implements flush(). It is mostly the same as close() though the canceled events are reported with error messages. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> --- src/android/camera_device.cpp | 28 ++++++++++++++++++++++++++++ src/android/camera_device.h | 1 + src/android/camera_ops.cpp | 8 ++++++-- 3 files changed, 35 insertions(+), 2 deletions(-)