From ee027781b4c265b378ed16f91eeded7b42f5dfe4 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Tue, 9 Apr 2019 11:27:29 +0200 Subject: libcamera: buffer: Store Request reference in Buffer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add to the Buffer class methods to set and retrieve a reference to the Request instance the buffer is part of. As buffers outlive the Request they are associated with, the reference is only temporary valid during the buffer completion interval (from when the buffer gets queued to Camera for processing, until it gets marked as completed). Reviewed-by: Niklas Söderlund Reviewed-by: Laurent Pinchart Signed-off-by: Jacopo Mondi --- src/libcamera/request.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/libcamera/request.cpp') diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp index 7088a479..433c6f83 100644 --- a/src/libcamera/request.cpp +++ b/src/libcamera/request.cpp @@ -141,6 +141,7 @@ int Request::prepare() for (auto const &pair : bufferMap_) { Buffer *buffer = pair.second; + buffer->setRequest(this); pending_.insert(buffer); } @@ -177,6 +178,8 @@ bool Request::completeBuffer(Buffer *buffer) int ret = pending_.erase(buffer); ASSERT(ret == 1); + buffer->setRequest(nullptr); + return !hasPendingBuffers(); } -- cgit v1.2.1