summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund@ragnatech.se>2020-08-11 01:07:37 +0200
committerNiklas Söderlund <niklas.soderlund@ragnatech.se>2020-08-14 13:19:15 +0200
commit27869c5f649c4b524e142014be073b40230ecbc4 (patch)
treece805806bd6c9166e6892887b292109616073b06 /src
parentdac8e9552ccdff137e717270468e584c2a9895b9 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/cam/capture.cpp4
-rw-r--r--src/cam/capture.h2
-rw-r--r--src/libcamera/camera.cpp4
-rw-r--r--src/libcamera/pipeline/ipu3/ipu3.cpp2
-rw-r--r--src/libcamera/request.cpp6
-rw-r--r--src/qcam/main_window.h2
6 files changed, 10 insertions, 10 deletions
diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp
index 07203769..af9029b7 100644
--- a/src/cam/capture.cpp
+++ b/src/cam/capture.cpp
@@ -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);
diff --git a/src/cam/capture.h b/src/cam/capture.h
index 32940a2a..b4e39d51 100644
--- a/src/cam/capture.h
+++ b/src/cam/capture.h
@@ -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_;
diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index 820fa1e3..afdd4775 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -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";
diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index d931ed33..019e50b8 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -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;
diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp
index d5f11e8c..60b30692 100644
--- a/src/libcamera/request.cpp
+++ b/src/libcamera/request.cpp
@@ -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;
diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h
index 6e1bcd76..3d21779e 100644
--- a/src/qcam/main_window.h
+++ b/src/qcam/main_window.h
@@ -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_ */