From patchwork Mon Apr 15 23:18:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 995 Return-Path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BFB5160B2E for ; Tue, 16 Apr 2019 01:18:19 +0200 (CEST) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 4F3811BF203; Mon, 15 Apr 2019 23:18:19 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 16 Apr 2019 01:18:54 +0200 Message-Id: <20190415231859.9747-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415231859.9747-1-jacopo@jmondi.org> References: <20190415231859.9747-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 2/7] libcamera: camera: Propagate freeBuffers() error 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: Mon, 15 Apr 2019 23:18:19 -0000 The error return code of PipelineHandler::freeBuffers() was not propagate up to applications by the Camera class. Fix this by returning the incremental error accumulated by multiple calls (one per Stream) to freeBuffers(). Do not return the error code of the call to freeBuffers() in the allocateBuffers() method error path not to overwrite the original error code returned from the allocation method. Signed-off-by: Jacopo Mondi --- src/libcamera/camera.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index bdf14b31d8ee..7f2dc904df16 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -671,6 +671,8 @@ int Camera::allocateBuffers() */ int Camera::freeBuffers() { + int ret = 0; + if (!stateIs(CameraPrepared)) return -EACCES; @@ -683,12 +685,12 @@ int Camera::freeBuffers() * by the V4L2 device that has allocated them. */ stream->bufferPool().destroyBuffers(); - pipe_->freeBuffers(this, stream); + ret |= pipe_->freeBuffers(this, stream); } state_ = CameraConfigured; - return 0; + return ret; } /**