From patchwork Wed Dec 1 07:53:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14948 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 0F94FBF415 for ; Wed, 1 Dec 2021 07:54:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C278460721; Wed, 1 Dec 2021 08:54:11 +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="XyFo/fmN"; dkim-atps=neutral Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 258A760710 for ; Wed, 1 Dec 2021 08:54:10 +0100 (CET) Received: by mail-pj1-x102d.google.com with SMTP id j5-20020a17090a318500b001a6c749e697so531340pjb.1 for ; Tue, 30 Nov 2021 23:54:10 -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=aisRSY5NBfEGCdy/9ndvSRH0p2htKgt/zk8gIFRC0cU=; b=XyFo/fmNmHhyJptbdLHThfl1YPgVWDzdxGMGiG+QiCgTR57IpCCISXLrRrdKDTZDNF ltsjKSAXKGUDYHtelx/pPOzrOwENKEAX2DFsu5jsQKYNEUTHrDnXtgfNEGOZk931hfww LVWl5LcrInL9Td0tS5c9PeepYusLfuQzoSXZM= 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=aisRSY5NBfEGCdy/9ndvSRH0p2htKgt/zk8gIFRC0cU=; b=JgWZTcpyvLNAep/YJEPCI29zznZ7/5ligmJtSS+hfji2DniaHcAXl7p8CYnveUKlfo FNC5sXuB+DI+/DmVBsOM9IXFI7jC2l9XTePfTNt5A8GK4MRkCrXvIwXUQlgjiVEaYC8l tZNCAbgTJZvJInriKuI9xh452CS8D9AUpGz1Rx4WMJnZTDpuMxcgmitpeWO3q6uNqdHj PF1LEiboifULq9jcXBIbtKJaqCbpPz0xh7qFyGFjZVcmnnMpoZMrZBMHMUBUGiWg7eP0 hqT6zX3grwXD+5RYiFgoU5ouhA5xKeJAs1Wih9x5VAnUBqeoP2vbMqILKqVdxmj7P+PO 93RA== X-Gm-Message-State: AOAM531WmivLTFoQmXqvkbLrhKe6ZtM1tdqhisfcv9rxs/2KSrVK4FhV nYPn03kZAV74K2M2GwCg5qAMXWGepnPs8w== X-Google-Smtp-Source: ABdhPJz8sqssnFAwOcugDiPCT4CKmZILqz1mRLbrqINz2rwKFzQqiBIGlELZnMN4uTHO5WRZN+HbQQ== X-Received: by 2002:a17:90a:670e:: with SMTP id n14mr5580256pjj.144.1638345248475; Tue, 30 Nov 2021 23:54:08 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:3892:a049:59ba:c772]) by smtp.gmail.com with ESMTPSA id l9sm3500848pfu.55.2021.11.30.23.54.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 23:54:08 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Dec 2021 16:53:44 +0900 Message-Id: <20211201075348.3121186-9-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211201075348.3121186-1-hiroh@chromium.org> References: <20211201075348.3121186-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 08/12] 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 Reviewed-by: Umang Jain --- 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());