From patchwork Wed Mar 20 16:30:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 773 Return-Path: Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 04A9F611AA for ; Wed, 20 Mar 2019 17:30:45 +0100 (CET) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 8BA2B200003; Wed, 20 Mar 2019 16:30:44 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 20 Mar 2019 17:30:51 +0100 Message-Id: <20190320163055.22056-28-jacopo@jmondi.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190320163055.22056-1-jacopo@jmondi.org> References: <20190320163055.22056-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 27/31] src: cam: Create requests with multiple streams X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Mar 2019 16:30:45 -0000 Add support for multiple streams to request creation and enqueuing to the 'capture()' method of the cam test application. Signed-off-by: Jacopo Mondi --- src/cam/main.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/cam/main.cpp b/src/cam/main.cpp index 9257f391988b..201dbda765fe 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -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 map; - map[stream] = &buffer; - ret = request->setBuffers(map); + /* Provide to each request a stream to buffer association map. */ + std::map 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;