summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund@ragnatech.se>2019-11-22 17:31:08 +0100
committerNiklas Söderlund <niklas.soderlund@ragnatech.se>2020-01-12 16:10:37 +0100
commitdea689e1f260b904697a9c2f3d05b7b5068d85e1 (patch)
tree3f4af3e375e64a7e54c4a044e0620679f7fe1032 /src
parent13724144f9bfd22f79d56431061bc55a887c1d10 (diff)
libcamera: request: In addBuffer() do not fetch stream from Buffer
In the FrameBuffer interface the stream will not be available from the buffer object as the buffer might be allocated externally. The application needs to explicitly state which stream the buffer is being added for to the request. Extend the addBuffer() function to get this information explicitly from the caller. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/android/camera_device.cpp2
-rw-r--r--src/cam/capture.cpp4
-rw-r--r--src/libcamera/request.cpp4
-rw-r--r--src/qcam/main_window.cpp4
-rw-r--r--src/v4l2/v4l2_camera.cpp2
5 files changed, 8 insertions, 8 deletions
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 065e0292..09588c16 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -754,7 +754,7 @@ void CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reque
Request *request =
camera_->createRequest(reinterpret_cast<uint64_t>(descriptor));
- request->addBuffer(std::move(buffer));
+ request->addBuffer(stream, std::move(buffer));
int ret = camera_->queueRequest(request);
if (ret) {
diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp
index 4b65b1d0..1a4dbe7c 100644
--- a/src/cam/capture.cpp
+++ b/src/cam/capture.cpp
@@ -95,7 +95,7 @@ int Capture::capture(EventLoop *loop)
Stream *stream = cfg.stream();
std::unique_ptr<Buffer> buffer = stream->createBuffer(i);
- ret = request->addBuffer(std::move(buffer));
+ ret = request->addBuffer(stream, std::move(buffer));
if (ret < 0) {
std::cerr << "Can't set buffer for request"
<< std::endl;
@@ -185,7 +185,7 @@ void Capture::requestComplete(Request *request)
return;
}
- request->addBuffer(std::move(newBuffer));
+ request->addBuffer(stream, std::move(newBuffer));
}
camera_->queueRequest(request);
diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp
index 92330c1a..54dfb461 100644
--- a/src/libcamera/request.cpp
+++ b/src/libcamera/request.cpp
@@ -113,6 +113,7 @@ Request::~Request()
/**
* \brief Store a Buffer with its associated Stream in the Request
+ * \param[in] stream The stream the buffer belongs to
* \param[in] buffer The Buffer to store in the request
*
* Ownership of the buffer is passed to the request. It will be deleted when
@@ -125,9 +126,8 @@ 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(std::unique_ptr<Buffer> buffer)
+int Request::addBuffer(Stream *stream, std::unique_ptr<Buffer> buffer)
{
- Stream *stream = buffer->stream();
if (!stream) {
LOG(Request, Error) << "Invalid stream reference";
return -EINVAL;
diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index 0a353e8b..8b3d9923 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -191,7 +191,7 @@ int MainWindow::startCapture()
goto error;
}
- ret = request->addBuffer(std::move(buffer));
+ ret = request->addBuffer(stream, std::move(buffer));
if (ret < 0) {
std::cerr << "Can't set buffer for request" << std::endl;
goto error;
@@ -289,7 +289,7 @@ void MainWindow::requestComplete(Request *request)
return;
}
- request->addBuffer(std::move(newBuffer));
+ request->addBuffer(stream, std::move(newBuffer));
}
camera_->queueRequest(request);
diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp
index 7221755d..b6e0bb76 100644
--- a/src/v4l2/v4l2_camera.cpp
+++ b/src/v4l2/v4l2_camera.cpp
@@ -192,7 +192,7 @@ int V4L2Camera::qbuf(unsigned int index)
return -ENOMEM;
}
- int ret = request->addBuffer(std::move(buffer));
+ int ret = request->addBuffer(stream, std::move(buffer));
if (ret < 0) {
LOG(V4L2Compat, Error) << "Can't set buffer for request";
return -ENOMEM;