Message ID | 20211130155600.2203123-11-hiroh@chromium.org |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Hiro, Thank you for the patch. On Wed, Dec 01, 2021 at 12:55:58AM +0900, Hirokazu Honda wrote: > This fixes the code accessing descriptors and > Camera3RequestDescriptor::pendingStreamsToProcess_ without holding > descriptorsMutex_ and Camera3RequestDescriptor::streamProcessMutex_ > in CameraDevice. > > Signed-off-by: Hirokazu Honda <hiroh@chromium.org> > --- > src/android/camera_device.cpp | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp > index d74307a2..e513cd84 100644 > --- a/src/android/camera_device.cpp > +++ b/src/android/camera_device.cpp > @@ -421,7 +421,11 @@ void CameraDevice::stop() > worker_.stop(); > camera_->stop(); > > - descriptors_ = {}; > + { > + MutexLocker descriptorsLock(descriptorsMutex_); > + descriptors_ = {}; > + } > + > streams_.clear(); > > state_ = State::Stopped; > @@ -918,6 +922,8 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques > */ > FrameBuffer *frameBuffer = nullptr; > int acquireFence = -1; > + > + MutexLocker lock(descriptor->streamsProcessMutex_); Blank line here ? We could lower the amount of code covered by the lock, but that wouldn't help as there can be lock contention here. I just hope locking and unlocking an std::mutex that isn't contended is a fast operation. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > switch (cameraStream->type()) { > case CameraStream::Type::Mapped: > /*
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index d74307a2..e513cd84 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -421,7 +421,11 @@ void CameraDevice::stop() worker_.stop(); camera_->stop(); - descriptors_ = {}; + { + MutexLocker descriptorsLock(descriptorsMutex_); + descriptors_ = {}; + } + streams_.clear(); state_ = State::Stopped; @@ -918,6 +922,8 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques */ FrameBuffer *frameBuffer = nullptr; int acquireFence = -1; + + MutexLocker lock(descriptor->streamsProcessMutex_); switch (cameraStream->type()) { case CameraStream::Type::Mapped: /*
This fixes the code accessing descriptors and Camera3RequestDescriptor::pendingStreamsToProcess_ without holding descriptorsMutex_ and Camera3RequestDescriptor::streamProcessMutex_ in CameraDevice. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> --- src/android/camera_device.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)