diff options
author | Barnabás Pőcze <pobrn@protonmail.com> | 2025-01-20 14:16:59 +0000 |
---|---|---|
committer | Barnabás Pőcze <pobrn@protonmail.com> | 2025-02-17 18:16:41 +0100 |
commit | 32cc6717d26820f55d2e8315ac2300d3a630417c (patch) | |
tree | 63c4187da4d1518038278e434a0c671e3e310117 | |
parent | 892e85e4e35a29dd6dc492117404ffb300dd9767 (diff) |
libcamera: request: addBuffer(): Do fence check earlier
Check if the buffer has a fence before making any modifications because
otherwise it is possible for `Request::addBuffer()` to return an error code
while at the same time the buffer - for all intents and purposes - is added
to the request.
Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
-rw-r--r-- | src/libcamera/request.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp index 8c56ed30..b206ac13 100644 --- a/src/libcamera/request.cpp +++ b/src/libcamera/request.cpp @@ -475,6 +475,15 @@ int Request::addBuffer(const Stream *stream, FrameBuffer *buffer, return -EINVAL; } + /* + * Make sure the fence has been extracted from the buffer + * to avoid waiting on a stale fence. + */ + if (buffer->_d()->fence()) { + LOG(Request, Error) << "Can't add buffer that still references a fence"; + return -EEXIST; + } + auto it = bufferMap_.find(stream); if (it != bufferMap_.end()) { LOG(Request, Error) << "FrameBuffer already set for stream"; @@ -485,15 +494,6 @@ int Request::addBuffer(const Stream *stream, FrameBuffer *buffer, _d()->pending_.insert(buffer); bufferMap_[stream] = buffer; - /* - * Make sure the fence has been extracted from the buffer - * to avoid waiting on a stale fence. - */ - if (buffer->_d()->fence()) { - LOG(Request, Error) << "Can't add buffer that still references a fence"; - return -EEXIST; - } - if (fence && fence->isValid()) buffer->_d()->setFence(std::move(fence)); |