From patchwork Fri May 28 21:00:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vedant Paranjape X-Patchwork-Id: 12472 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id DACCCC3206 for ; Fri, 28 May 2021 21:00:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0E26068921; Fri, 28 May 2021 23:00:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="V80d7L5o"; dkim-atps=neutral Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D90CB602AA for ; Fri, 28 May 2021 23:00:40 +0200 (CEST) Received: by mail-pg1-x52e.google.com with SMTP id j12so3432754pgh.7 for ; Fri, 28 May 2021 14:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+/HsCWEjqMck/2/ZH4LoxrLozttKr+zwFrdc1Sr+2YA=; b=V80d7L5oQCiy2mxFBgBsnhG7CsFm6bfocMGQ8vzL/UGAWawvhr1eAqgEwYXLWI+bBj SnMYAiWsYgYhuuBn1ykY6RT5th0ACapujipL7VYhh/m+sMkSgItx2BFDBHjXdIg7uH9s XhcJDdwb0TLP6b+Ed2G7fZlNH1vjBd7c0DgBtDLYpx8rZaR4dGBKFaufD9y+Or2cOmhg BW7TyplBz1zGprDLj6ZtDDDQTMsEWD/xAF5jBET/TeRJpmVjRx/Y4Rzm1oJywKE++HFT UsBOQ+kNB0+/jLZmH7XGh2nvz+8QICOzvKeQxUyDSQCOvW+jj215OxwwhT+nsU9b8jVj An4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+/HsCWEjqMck/2/ZH4LoxrLozttKr+zwFrdc1Sr+2YA=; b=C7+T6pWsFfwYEGteayNiGNgQBq7IY7DKbGNmx5nLoxxr+B7PsAChuSxH54/JF0usPj TL1iRhKqx0goguNKo6W1ZVcte4p36veuxbT28mW1hl8wyHAr86C6TKOUKdxjOHCW/TZV py71m4kA3Wh2L8exbN63JKvSSs7n8M/kal0utkh0VquJ2fqK10zv0SF73mfcWdXT3yz9 duOlnUB2/g7bqUeAJwWX53Up2Ym10piljApRFcA6lM5k5dmzrjHDdPIYlciLWcoUhRuB riOzURfOSablUnmXL2zD1rKXdWlpBDWNTAfoynVA2sCsDJeQwQ9yZQJS393ZicCVranm RmTw== X-Gm-Message-State: AOAM533CTxBAWjmjTO/AJcwH1aCBtrXWxTs0xjDwSW5uOsXsohXqERj2 KA6DuJR6vpPrejFlEz/nYS1wpwl7CPX76lQe X-Google-Smtp-Source: ABdhPJyLS4+ze3K4Xf6jP7TOMLIwmgH4mpEIdN2Y92eutpTn9Cv9Vk8UZgEF5jg8hKacNR8pIyx0Aw== X-Received: by 2002:a63:58f:: with SMTP id 137mr10823569pgf.241.1622235638758; Fri, 28 May 2021 14:00:38 -0700 (PDT) Received: from localhost.localdomain ([1.186.78.76]) by smtp.googlemail.com with ESMTPSA id e6sm5234832pjt.1.2021.05.28.14.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 14:00:38 -0700 (PDT) From: Vedant Paranjape To: libcamera-devel@lists.libcamera.org Date: Sat, 29 May 2021 02:30:11 +0530 Message-Id: <20210528210011.154346-1-vedantparanjape160201@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1] Fix todo in gst_libcamera_src_task_enter() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vedant Paranjape Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Error checking the output from generateConfiguration() was missing in the code. Only assert was added as a guard which checked if the generated camera config are equal to the roles passed to it. But since, if generateConfiguration() is passed a invalid role, it returns a nullptr. Added error checking so that it checks the return value, and sends an error message on GstBus. Signed-off-by: Vedant Paranjape --- src/gstreamer/gstlibcamerasrc.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index 87246b40..8b6057df 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -375,11 +375,13 @@ gst_libcamera_src_task_enter(GstTask *task, [[maybe_unused]] GThread *thread, /* Generate the stream configurations, there should be one per pad. */ state->config_ = state->cam_->generateConfiguration(roles); - /* - * \todo Check if camera may increase or decrease the number of streams - * regardless of the number of roles. - */ - g_assert(state->config_->size() == state->srcpads_.size()); + if (state->config_ == nullptr) { + GST_ELEMENT_ERROR(self, RESOURCE, SETTINGS, + ("Failed to generate camera configuration from roles"), + ("Camera::generateConfiguration() returned nullptr")); + gst_task_stop(task); + return; + } for (gsize i = 0; i < state->srcpads_.size(); i++) { GstPad *srcpad = state->srcpads_[i];