From patchwork Mon Nov 29 11:44:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14843 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 A8B44BF415 for ; Mon, 29 Nov 2021 11:45:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 40537605B6; Mon, 29 Nov 2021 12:45:16 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="WdMBIyoI"; dkim-atps=neutral Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9C6A360592 for ; Mon, 29 Nov 2021 12:45:13 +0100 (CET) Received: by mail-pj1-x1032.google.com with SMTP id o6-20020a17090a0a0600b001a64b9a11aeso13934218pjo.3 for ; Mon, 29 Nov 2021 03:45:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sp5Sw3uSiY5RflgCnmeAXEew7x/3MvLj60NFCnZsN6c=; b=WdMBIyoIVKUvVKq+ck48MAcl6/4QVFBZ+EpqA3c0gyz0tx61Ev9HUcakY0l3kIFPiZ WBnW9j9eaxJNzYxPi7prmKAwRj28GPD3jkTqqExNZnN1qhfq8dsbBFosOfDpBKOv4zIt knJVSLvIegRK8wJpYURiZy5cCi1FhZOn3XalQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sp5Sw3uSiY5RflgCnmeAXEew7x/3MvLj60NFCnZsN6c=; b=7HaecssufRu6L/eZOjN/f8fErRiJjSZKYhy9CCwg9TijOfkpOeJpcMCBtea2QaoOwU qcwLXUqTVUMvpVHiHe/K2VCaE7pbYee8mFul5N+pP4w/8MBvbKuYaRXAIXGWs2/NgHBU mwl56hYZuBSsy3UlDdpAA3JW2rYBlEpEzEbxMwi4BGJZPR+AM7QIKt5rH9p1saZQ6jQM 0AB8/iEqDKUxQpljpKyvQ82Otx+qTnvkelPLsekTAFBeJHBAw2+Xj0RPCwxI7M5cA0m2 zrxBd1UFIqVyKSMgkDD46rcE4+gExPNJ1XVtW+68Cmk++zgopOZMB3Cq6ISt60N/ttQ4 YOfQ== X-Gm-Message-State: AOAM532Gp241j4T2+IVcIZhwrsQPpwtA9YXQmbcYjjm+YDvUliEyZ2u7 vLLNbu8WzWPyO7E2SWQsrVCLc7ZTsjxpzA== X-Google-Smtp-Source: ABdhPJyrP1QpNkkgQx/GsNKndopbMOb+vK0r1dQ6MI/9XeTzlVaEp/OEVHRffpOa09zPAFko71/3sQ== X-Received: by 2002:a17:90a:bf8a:: with SMTP id d10mr37111102pjs.67.1638186311933; Mon, 29 Nov 2021 03:45:11 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:f254:cda9:46e8:17b7]) by smtp.gmail.com with ESMTPSA id hg4sm17951966pjb.1.2021.11.29.03.45.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 03:45:11 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Nov 2021 20:44:49 +0900 Message-Id: <20211129114453.3186042-8-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211129114453.3186042-1-hiroh@chromium.org> References: <20211129114453.3186042-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 07/11] android: camera_stream: Protect buffers initialization by mutex_ 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" The initialization on buffers_ in CameraStrean::configure() is not protected by mutex_. It is no problem because configure() is not invoked simultaneously while other functions are called. This protects it to keep the thread safety consistency for buffers access. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart --- src/android/camera_stream.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp index 5a62b7cd..2181d094 100644 --- a/src/android/camera_stream.cpp +++ b/src/android/camera_stream.cpp @@ -125,6 +125,7 @@ int CameraStream::configure() if (ret < 0) return ret; + MutexLocker lock(*mutex_); /* Save a pointer to the reserved frame buffers */ for (const auto &frameBuffer : allocator_->buffers(stream())) buffers_.push_back(frameBuffer.get());