@@ -144,8 +144,6 @@ static int capture()
return ret;
}
- Stream *stream = *streams.begin();
-
ret = camera->allocateBuffers();
if (ret) {
std::cerr << "Failed to allocate buffers"
@@ -153,11 +151,14 @@ static int capture()
return ret;
}
- camera->requestCompleted.connect(requestComplete);
-
- BufferPool &pool = stream->bufferPool();
-
- for (Buffer &buffer : pool.buffers()) {
+ /*
+ * Create the requests to be later enqueued.
+ *
+ * FIXME: Assume all streams have the same number of buffers: use
+ * the first stream's buffer pool and create on request per buffer.
+ */
+ unsigned int bufferCount = (*streams.begin())->bufferPool().count();
+ for (unsigned int i = 0; i < bufferCount; ++i) {
Request *request = camera->createRequest();
if (!request) {
std::cerr << "Can't create request" << std::endl;
@@ -165,9 +166,14 @@ static int capture()
goto out;
}
- std::map<Stream *, Buffer *> map;
- map[stream] = &buffer;
- ret = request->setBuffers(map);
+ /* Provide to each request a stream to buffer association map. */
+ std::map<Stream *, Buffer *> requestMap;
+ for (Stream *stream : streams) {
+ Buffer *buffer = &stream->bufferPool().buffers()[i];
+ requestMap[stream] = buffer;
+ }
+
+ ret = request->setBuffers(requestMap);
if (ret < 0) {
std::cerr << "Can't set buffers for request" << std::endl;
goto out;
@@ -176,6 +182,8 @@ static int capture()
requests.push_back(request);
}
+ camera->requestCompleted.connect(requestComplete);
+
ret = camera->start();
if (ret) {
std::cout << "Failed to start capture" << std::endl;
Add support for multiple streams to request creation and enqueuing to the 'capture()' method of the cam test application. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> --- src/cam/main.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)