libcamera: request: Make Stream pointer const
The Stream pointer just acts as a key in the Request object. There is no good use-case to modify a stream from a pointer retrieved from the Request, make it const. This allows pipeline handlers to better express that the Stream pointer is retrieved in a Request should just be treated as a key. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
+2
-2
@@ -169,7 +169,7 @@ void Capture::requestComplete(Request *request)
|
||||
info << "fps: " << std::fixed << std::setprecision(2) << fps;
|
||||
|
||||
for (auto it = buffers.begin(); it != buffers.end(); ++it) {
|
||||
Stream *stream = it->first;
|
||||
const Stream *stream = it->first;
|
||||
FrameBuffer *buffer = it->second;
|
||||
const std::string &name = streamName_[stream];
|
||||
|
||||
@@ -209,7 +209,7 @@ void Capture::requestComplete(Request *request)
|
||||
}
|
||||
|
||||
for (auto it = buffers.begin(); it != buffers.end(); ++it) {
|
||||
Stream *stream = it->first;
|
||||
const Stream *stream = it->first;
|
||||
FrameBuffer *buffer = it->second;
|
||||
|
||||
request->addBuffer(stream, buffer);
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ private:
|
||||
std::shared_ptr<libcamera::Camera> camera_;
|
||||
libcamera::CameraConfiguration *config_;
|
||||
|
||||
std::map<libcamera::Stream *, std::string> streamName_;
|
||||
std::map<const libcamera::Stream *, std::string> streamName_;
|
||||
BufferWriter *writer_;
|
||||
std::chrono::steady_clock::time_point last_;
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ public:
|
||||
std::shared_ptr<PipelineHandler> pipe_;
|
||||
std::string id_;
|
||||
std::set<Stream *> streams_;
|
||||
std::set<Stream *> activeStreams_;
|
||||
std::set<const Stream *> activeStreams_;
|
||||
|
||||
private:
|
||||
bool disconnected_;
|
||||
@@ -889,7 +889,7 @@ int Camera::queueRequest(Request *request)
|
||||
}
|
||||
|
||||
for (auto const &it : request->buffers()) {
|
||||
Stream *stream = it.first;
|
||||
const Stream *stream = it.first;
|
||||
|
||||
if (p_->activeStreams_.find(stream) == p_->activeStreams_.end()) {
|
||||
LOG(Camera, Error) << "Invalid request";
|
||||
|
||||
@@ -663,7 +663,7 @@ int PipelineHandlerIPU3::queueRequestDevice(Camera *camera, Request *request)
|
||||
|
||||
/* Queue all buffers from the request aimed for the ImgU. */
|
||||
for (auto it : request->buffers()) {
|
||||
Stream *stream = static_cast<Stream *>(it.first);
|
||||
const Stream *stream = it.first;
|
||||
FrameBuffer *buffer = it.second;
|
||||
int ret;
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ Request::~Request()
|
||||
* \retval -EEXIST The request already contains a buffer for the stream
|
||||
* \retval -EINVAL The buffer does not reference a valid Stream
|
||||
*/
|
||||
int Request::addBuffer(Stream *stream, FrameBuffer *buffer)
|
||||
int Request::addBuffer(const Stream *stream, FrameBuffer *buffer)
|
||||
{
|
||||
if (!stream) {
|
||||
LOG(Request, Error) << "Invalid stream reference";
|
||||
@@ -162,9 +162,9 @@ int Request::addBuffer(Stream *stream, FrameBuffer *buffer)
|
||||
* \return The buffer associated with the stream, or nullptr if the stream is
|
||||
* not part of this request
|
||||
*/
|
||||
FrameBuffer *Request::findBuffer(Stream *stream) const
|
||||
FrameBuffer *Request::findBuffer(const Stream *stream) const
|
||||
{
|
||||
auto it = bufferMap_.find(stream);
|
||||
const auto it = bufferMap_.find(stream);
|
||||
if (it == bufferMap_.end())
|
||||
return nullptr;
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ private:
|
||||
bool captureRaw_;
|
||||
Stream *vfStream_;
|
||||
Stream *rawStream_;
|
||||
std::map<Stream *, QQueue<FrameBuffer *>> freeBuffers_;
|
||||
std::map<const Stream *, QQueue<FrameBuffer *>> freeBuffers_;
|
||||
QQueue<CaptureRequest> doneQueue_;
|
||||
QMutex mutex_; /* Protects freeBuffers_ and doneQueue_ */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user