From patchwork Tue Aug 4 10:19:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 27609 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 D84D3C3333 for ; Tue, 4 Aug 2026 10:20:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 463F8680B9; Tue, 4 Aug 2026 12:20:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BvKE62LW"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C21E368087 for ; Tue, 4 Aug 2026 12:19:53 +0200 (CEST) Received: from pb-laptop.local (185.221.141.208.nat.pool.zt.hu [185.221.141.208]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4254FDA8 for ; Tue, 4 Aug 2026 12:18:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1785838724; bh=g4jt54kXxvnWrcff0ensF6BIPmkQQbdUZ7xO/oY1Wb8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BvKE62LWFuSVsZFwF0tnFlxQXiSbzFSn6Ps7/cD9W9rya7Zff9IOSxbnK7yGQ4lrz x+Fdmo5ezf7LPe6LBE0s4aAXu4LERfIUdLLXIrrNtYPMEvGNoX/HC3tIyJXPRYWYEF UqhvFeZzqW1uVpICsqoZ6o7VV6BmI96PMvbBHPEk= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 07/10] libcamera: egl: initEGLContext(): Avoid double init Date: Tue, 4 Aug 2026 12:19:46 +0200 Message-ID: <20260804101949.353266-8-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260804101949.353266-1-barnabas.pocze@ideasonboard.com> References: <20260804101949.353266-1-barnabas.pocze@ideasonboard.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" If the initialization is already done, reject further attempts, otherwise resources would be leaked. Signed-off-by: Barnabás Pőcze --- src/libcamera/egl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 6b50e7bb77..5e75c3a6d2 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -359,7 +359,7 @@ void eGL::createOutputTexture2D(eGLImage &eglImage) * - eglCreateImageKHR / eglDestroyImageKHR * - glEGLImageTargetTexture2DOES * - * \return 0 on success, or -ENODEV on failure + * \return 0 on success, or negative error code on failure */ int eGL::initEGLContext() { @@ -382,6 +382,9 @@ int eGL::initEGLContext() EGLint numConfigs; EGLConfig config; + if (context_ != EGL_NO_CONTEXT) + return -EEXIST; + if (!eglBindAPI(EGL_OPENGL_ES_API)) { LOG(eGL, Error) << "API bind fail"; goto fail;