From patchwork Tue Nov 30 15:55:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14905 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 E7BC3C324F for ; Tue, 30 Nov 2021 15:56:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6BE1560727; Tue, 30 Nov 2021 16:56:26 +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="nu5eTPmP"; dkim-atps=neutral Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3468F605C4 for ; Tue, 30 Nov 2021 16:56:23 +0100 (CET) Received: by mail-pj1-x1035.google.com with SMTP id h24so15695057pjq.2 for ; Tue, 30 Nov 2021 07:56:23 -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=nu5eTPmP+cc4a6g2SsJKzg55jkuH8Kn4pITBi/BlD0LS3FN59j4VBGUpK7kus1j4Ks JeVfZE6FuBYUWjynExev/tbkPLl43I3MtPfznSQFHVtiXLifQrkYQhhjQkjEPSCksBe/ ULYHeOik5AoOIxmbXOZ+Gg2Niz3uTBFxdSR6M= 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=ybvb37FJZtROlLEzc9+vcLA/NPBwoNxay75T930Csbb0LJBo7ccHJq99bm3YuuNjuT fUwg8nk/tA50FLHTB0HM97K+oa+G18A8m+CZdZJviDuC7k7L/N4WH+DltFkV701hOTV6 1mkRVNwf4mgPhwSEdMkNihc0kq73cjhQBRNCwehCPuJjV89497a5sz3KP5PJB35240q0 jp440IkmEtsfJandmMpV84qG5SNKPMUs07gSMVJrmPCG09Lvr2RJEybAqFVapjsOqJOh dMmO9xwtxt2TvZRo5u9VhlQKX/rr+mumTA0ST5kyk8q6gEr27GUCuE3IxYdaZDNh/Dle 2mzA== X-Gm-Message-State: AOAM530lRAZQyYHBmDvOt1ZVaAbQU7JSgrSr0s/SEYtTISnWfst9EVeM EbUBHO7b5Th10T+eyIszbB2QUtFH25FCTg== X-Google-Smtp-Source: ABdhPJyZeZBkttFlNHi8w1Ic7qIZjqNSEdPbXf7J8WbaK9xi5zlqBtkX64gdncQUWgwTCjj1J35Q6A== X-Received: by 2002:a17:902:b78b:b0:143:baac:2ebc with SMTP id e11-20020a170902b78b00b00143baac2ebcmr187265pls.77.1638287781579; Tue, 30 Nov 2021 07:56:21 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:c90a:5a53:b139:1336]) by smtp.gmail.com with ESMTPSA id pc10sm3510283pjb.9.2021.11.30.07.56.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 07:56:21 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Dec 2021 00:55:56 +0900 Message-Id: <20211130155600.2203123-9-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211130155600.2203123-1-hiroh@chromium.org> References: <20211130155600.2203123-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 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());