[{"id":609,"web_url":"https://patchwork.libcamera.org/comment/609/","msgid":"<20190125171315.GB4515@pendragon.ideasonboard.com>","date":"2019-01-25T17:13:15","subject":"Re: [libcamera-devel] [PATCH 5/5] libcamera: pipeline: Refuse to\n\tsubstitute camera data","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Fri, Jan 25, 2019 at 06:04:00PM +0100, Jacopo Mondi wrote:\n> Once a pipeline-specific data has been associated with a camera, refuse\n> to update it in order to avoid invalidating the previously set\n> reference, which might still be owned by the caller.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/include/pipeline_handler.h |  2 +-\n>  src/libcamera/pipeline_handler.cpp       | 23 ++++++++++++++---------\n>  2 files changed, 15 insertions(+), 10 deletions(-)\n> \n> diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h\n> index ca77a40..01a0f0b 100644\n> --- a/src/libcamera/include/pipeline_handler.h\n> +++ b/src/libcamera/include/pipeline_handler.h\n> @@ -47,7 +47,7 @@ protected:\n>  \tvoid hotplugMediaDevice(MediaDevice *media);\n>  \n>  \tCameraData *cameraData(const Camera *camera);\n> -\tvoid setCameraData(const Camera *camera, std::unique_ptr<CameraData> data);\n> +\tint setCameraData(const Camera *camera, std::unique_ptr<CameraData> data);\n>  \n>  private:\n>  \tvirtual void disconnect();\n> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> index dc55f8f..7e927a7 100644\n> --- a/src/libcamera/pipeline_handler.cpp\n> +++ b/src/libcamera/pipeline_handler.cpp\n> @@ -212,21 +212,26 @@ CameraData *PipelineHandler::cameraData(const Camera *camera)\n>   * information with \\a camera. Ownership of \\a data is transferred to\n>   * the PipelineHandler.\n>   *\n> - * If pipeline-specific data has already been associated with the camera by a\n> - * previous call to this method, is it replaced by \\a data and the previous data\n> - * are deleted, rendering all references to them invalid.\n> + * Once pipeline-specific data has already been associated with the camera\n> + * by a previous call to this method it cannot be changed later on.\n\nMaybe \"Pipeline-specific data can only be set once. Any attempt to call\nthis method after the first one with the same camera will return an\nerror and won't affect the pipeline-specific data.\" ? Up to you.\n\n>   *\n>   * The data can be retrieved by pipeline handlers using the cameraData() method.\n> + *\n> + * \\return 0 on success, or a negative error code if camera specific data have\n> + * already been set\n>   */\n> -void PipelineHandler::setCameraData(const Camera *camera,\n> -\t\t\t\t    std::unique_ptr<CameraData> data)\n> +int PipelineHandler::setCameraData(const Camera *camera,\n> +\t\t\t\t   std::unique_ptr<CameraData> data)\n>  {\n> -\tif (cameraData_.count(camera))\n> -\t\tLOG(Pipeline, Debug)\n> -\t\t\t<< \"Replacing data associated with \"\n> -\t\t\t<< camera->name();\n> +\tif (cameraData_.find(camera) != cameraData_.end()) {\n> +\t\tLOG(Pipeline, Error)\n> +\t\t\t<< \"Replacing data associated with a camera is forbidden \";\n\ns/ \";/\";/\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t\treturn -EINVAL;\n> +\t}\n>  \n>  \tcameraData_[camera] = std::move(data);\n> +\n> +\treturn 0;\n>  }\n>  \n>  /**","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0188760C6A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Jan 2019 18:13:16 +0100 (CET)","from pendragon.ideasonboard.com\n\t(250-166-145-178.mobileinternet.proximus.be [178.145.166.250])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 71641325;\n\tFri, 25 Jan 2019 18:13:16 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1548436396;\n\tbh=iL0owBCveTQfLiHwD6VB0RwUQHvuSaVLFpk41hwvtx4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=DzJPk+LJN8iIZvgVSn/uRjZhBNi8io+GiTWq+KGPeV1MkkkSwRavLDb67Ai7/oV9h\n\tNSmC4PHV4LrMmxIgGbnL1ghQoC4AuWHmSGoWbUmpdVBU8SReDn/EdWHg16lDEVtwwZ\n\tb/Ykc40NUo52sa/wFTgeChx37L71pt43QOvP14po=","Date":"Fri, 25 Jan 2019 19:13:15 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190125171315.GB4515@pendragon.ideasonboard.com>","References":"<20190125170400.24821-1-jacopo@jmondi.org>\n\t<20190125170400.24821-6-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190125170400.24821-6-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 5/5] libcamera: pipeline: Refuse to\n\tsubstitute camera data","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Fri, 25 Jan 2019 17:13:17 -0000"}}]