libcamera: buffer: Store Request reference in Buffer

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 <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Jacopo Mondi
2019-04-18 15:37:59 +02:00
parent 0527ba92ad
commit ee027781b4
3 changed files with 33 additions and 1 deletions
+3
View File
@@ -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();
}