@@ -991,8 +991,6 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
FrameBuffer *frameBuffer = nullptr;
UniqueFD acquireFence;
- MutexLocker lock(descriptor->streamsProcessMutex_);
-
switch (cameraStream->type()) {
case CameraStream::Type::Mapped:
/* Mapped streams will be handled in the next loop. */
@@ -1068,7 +1066,6 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
<< cameraStream->configuration().pixelFormat << "]"
<< " (mapped)";
- MutexLocker lock(descriptor->streamsProcessMutex_);
descriptor->pendingStreamsToProcess_.insert({ cameraStream, &buffer });
/*
@@ -1242,9 +1239,6 @@ void CameraDevice::requestComplete(Request *request)
descriptor->resultMetadata_ = std::make_unique<CameraMetadata>(0, 0);
}
- /* Handle post-processing. */
- MutexLocker locker(descriptor->streamsProcessMutex_);
-
/*
* Queue all the post-processing streams request at once. The completion
* slot streamProcessingComplete() can only execute when we are out
@@ -1272,10 +1266,8 @@ void CameraDevice::requestComplete(Request *request)
}
}
- if (descriptor->pendingStreamsToProcess_.empty()) {
- locker.unlock();
+ if (descriptor->pendingStreamsToProcess_.empty())
completeDescriptor(descriptor);
- }
}
/**
@@ -1382,6 +1374,19 @@ void CameraDevice::setBufferStatus(StreamBuffer &streamBuffer,
}
}
+void CameraDevice::streamProcessingCompleteDelegate(StreamBuffer *streamBuffer,
+ StreamBuffer::Status status)
+{
+ /*
+ * Delegate the callback to the camera manager thread to simplify race condition.
+ */
+ auto *method = new BoundMethodMember{
+ this, camera_.get(), &CameraDevice::streamProcessingComplete, ConnectionTypeQueued
+ };
+
+ method->activate(streamBuffer, status);
+}
+
/**
* \brief Handle post-processing completion of a stream in a capture request
* \param[in] streamBuffer The StreamBuffer for which processing is complete
@@ -1402,13 +1407,9 @@ void CameraDevice::streamProcessingComplete(StreamBuffer *streamBuffer,
Camera3RequestDescriptor *request = streamBuffer->request;
- {
- MutexLocker locker(request->streamsProcessMutex_);
-
- request->pendingStreamsToProcess_.erase(streamBuffer->stream);
- if (!request->pendingStreamsToProcess_.empty())
- return;
- }
+ request->pendingStreamsToProcess_.erase(streamBuffer->stream);
+ if (!request->pendingStreamsToProcess_.empty())
+ return;
completeDescriptor(streamBuffer->request);
}
@@ -65,6 +65,8 @@ public:
int configureStreams(camera3_stream_configuration_t *stream_list);
int processCaptureRequest(camera3_capture_request_t *request);
void requestComplete(libcamera::Request *request);
+ void streamProcessingCompleteDelegate(StreamBuffer *bufferStream,
+ StreamBuffer::Status status);
void streamProcessingComplete(StreamBuffer *bufferStream,
StreamBuffer::Status status);
@@ -66,9 +66,7 @@ public:
};
/* Keeps track of streams requiring post-processing. */
- std::map<CameraStream *, StreamBuffer *> pendingStreamsToProcess_
- LIBCAMERA_TSA_GUARDED_BY(streamsProcessMutex_);
- libcamera::Mutex streamsProcessMutex_;
+ std::map<CameraStream *, StreamBuffer *> pendingStreamsToProcess_;
Camera3RequestDescriptor(libcamera::Camera *camera,
const camera3_capture_request_t *camera3Request);