From patchwork Wed Dec 1 07:07:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14934 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 2C931BF415 for ; Wed, 1 Dec 2021 07:07:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C439D60733; Wed, 1 Dec 2021 08:07:51 +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="Eq5l+sKk"; dkim-atps=neutral Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 255DB60723 for ; Wed, 1 Dec 2021 08:07:50 +0100 (CET) Received: by mail-pl1-x634.google.com with SMTP id o14so16957664plg.5 for ; Tue, 30 Nov 2021 23:07:50 -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=Eq5l+sKk1W0jOMRADeIbtVPK009O9SFWnT+blrulAn6fP85hL6y8TYVyb+Z5rugRKL lm1YGDihPRoFG/Lov1guQf+ZugqWBAZfFioa3Q3m9AL5Dmy0flmBAaPJfyXCohLf+9+E EjesJhdYRegHbrbcJeDEbLXE8ZVqabUEwgITc= 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=LrrB1B6Cl06M3+Hadr25YLOI2E/vHm5SRm/XEgsN7DIh8JA2ygwlXHP5GtWu7QO02x UkwZ9GT4NeuMrGOGwwFk9uNh/W94r/4bqp5/hUDKhli4kBBTm1HwsrybMmSR+A3vDyVI m05hL8SwaLE1NCILFxS/9DihTmksxLUeF5XJ/lFhf6K6gl2qKf2B9+q3IfiqkCl8gNEX SIkBlwoRj+wwJl9PNvCdqPRQ1eY79NMWJkJ18+BBYdk8h05wqnbYtaTWj28es0LseipT V4gmdNvk5UUf4T3we6t1iMHMAqQgoI12168+DCPmmgCudBPEoSAwnz3YV+/Om2RbwkvS wOvQ== X-Gm-Message-State: AOAM533Jark84wav+lO/RncNJums/bwwNS8dmnFGAeEnlLj1tNAaRx83 LF0BB/mfsl90wsqu6lZML56eWI1L2bB0OQ== X-Google-Smtp-Source: ABdhPJwWxyuqUyyMTkedNmDfpFhBTdg0cWyg2mEJv8v1PRP7rm3AAAp3koWdcem7D9mOpfNEZ5HQNw== X-Received: by 2002:a17:90b:94:: with SMTP id bb20mr5251057pjb.210.1638342468486; Tue, 30 Nov 2021 23:07:48 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:3892:a049:59ba:c772]) by smtp.gmail.com with ESMTPSA id m10sm16598962pgv.75.2021.11.30.23.07.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 23:07:48 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Dec 2021 16:07:24 +0900 Message-Id: <20211201070728.3114247-9-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211201070728.3114247-1-hiroh@chromium.org> References: <20211201070728.3114247-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 --- 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());