android: camera_worker: Process all queued requests when stopping
When stopping the camera worker, queuedRequest() calls may have queued asynchronous function invocation messages to the worker thread, and some of those messages may not have been processed yet. The messages will stay in the thread's queue until the camera worker is restarted (when the camera service will start a new capture session). At that point, they will be dispatched, which will cause a crash due to the CaptureRequest passed to processRequest() having been deleted by CameraDevice::stop() calling descriptors_.clear(). Fix this by forcing dispatching of all function invocation messages when stopping the camera worker thread. Note that this is inherently racy, as more queueRequest() calls may arrive from the camera service while we're stopping. This race condition will be addressed by a subsequent patch series. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
@@ -52,18 +52,24 @@ void CaptureRequest::queue()
|
||||
*/
|
||||
CameraWorker::CameraWorker()
|
||||
{
|
||||
worker_.moveToThread(&thread_);
|
||||
worker_.moveToThread(this);
|
||||
}
|
||||
|
||||
void CameraWorker::start()
|
||||
{
|
||||
thread_.start();
|
||||
Thread::start();
|
||||
}
|
||||
|
||||
void CameraWorker::stop()
|
||||
{
|
||||
thread_.exit();
|
||||
thread_.wait();
|
||||
exit();
|
||||
wait();
|
||||
}
|
||||
|
||||
void CameraWorker::run()
|
||||
{
|
||||
exec();
|
||||
dispatchMessages(Message::Type::InvokeMessage);
|
||||
}
|
||||
|
||||
void CameraWorker::queueRequest(CaptureRequest *request)
|
||||
|
||||
Reference in New Issue
Block a user