[libcamera-devel,26/30] libcamera: camera: Start streams before pipeline

Message ID 20191126233620.1695316-27-niklas.soderlund@ragnatech.se
State Superseded
Headers show
Series
  • libcamera: Rework buffer API
Related show

Commit Message

Niklas Söderlund Nov. 26, 2019, 11:36 p.m. UTC
The FrameBuffer interface require individual streams to be started
explicitly. This is needed so that the streams may perform any
preparations before the pipeline and this the camera is started.

The only supported stream at the moment is V4L2 streams and they need to
be started so they can prepare for the use of external buffers in the
case they are used.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/libcamera/camera.cpp | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Patch

diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index e810fb725d81350d..6b1b3fb64f8b2c0b 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -856,15 +856,23 @@  int Camera::queueRequest(Request *request)
  */
 int Camera::start()
 {
+	int ret;
+
 	if (disconnected_)
 		return -ENODEV;
 
 	if (!stateIs(CameraPrepared))
 		return -EACCES;
 
+	for (Stream *stream : activeStreams_) {
+		ret = stream->start();
+		if (ret < 0)
+			return ret;
+	}
+
 	LOG(Camera, Debug) << "Starting capture";
 
-	int ret = pipe_->start(this);
+	ret = pipe_->start(this);
 	if (ret)
 		return ret;
 
@@ -899,6 +907,9 @@  int Camera::stop()
 
 	pipe_->stop(this);
 
+	for (Stream *stream : activeStreams_)
+		stream->stop();
+
 	return 0;
 }