[{"id":3626,"web_url":"https://patchwork.libcamera.org/comment/3626/","msgid":"<20200206220438.GG7611@pendragon.ideasonboard.com>","date":"2020-02-06T22:04:38","subject":"Re: [libcamera-devel] [PATCH 1/6] qcam: Tie FrameBufferAllocator to\n\tstream life","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the patch.\n\nOn Thu, Feb 06, 2020 at 03:04:59PM +0000, Kieran Bingham wrote:\n> The FrameBufferAllocator must be deleted and reconstructed before performing\n> any reconfiguration of the stream.\n> \n> Construct the allocator at startCapture, and destroy it during stopCapture so\n> that we can successfully stop and restart the stream.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  src/qcam/main_window.cpp | 5 +++--\n>  1 file changed, 3 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> index df51fa888342..38bc04a23b86 100644\n> --- a/src/qcam/main_window.cpp\n> +++ b/src/qcam/main_window.cpp\n> @@ -37,7 +37,6 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)\n>  \n>  \tret = openCamera(cm);\n>  \tif (!ret) {\n> -\t\tallocator_ = FrameBufferAllocator::create(camera_);\n>  \t\tret = startCapture();\n>  \t}\n\nYou can remove the braces.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>  \n> @@ -50,7 +49,6 @@ MainWindow::~MainWindow()\n>  {\n>  \tif (camera_) {\n>  \t\tstopCapture();\n> -\t\tdelete allocator_;\n>  \t\tcamera_->release();\n>  \t\tcamera_.reset();\n>  \t}\n> @@ -171,6 +169,7 @@ int MainWindow::startCapture()\n>  \n>  \tadjustSize();\n>  \n> +\tallocator_ = FrameBufferAllocator::create(camera_);\n>  \tret = allocator_->allocate(stream);\n>  \tif (ret < 0) {\n>  \t\tstd::cerr << \"Failed to allocate capture buffers\" << std::endl;\n> @@ -255,6 +254,8 @@ void MainWindow::stopCapture()\n>  \t}\n>  \tmappedBuffers_.clear();\n>  \n> +\tdelete allocator_;\n> +\n>  \tisCapturing_ = false;\n>  \n>  \tconfig_.reset();","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 CC36560864\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  6 Feb 2020 23:04:54 +0100 (CET)","from pendragon.ideasonboard.com\n\t(117.145-247-81.adsl-dyn.isp.belgacom.be [81.247.145.117])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 29BBEB7D;\n\tThu,  6 Feb 2020 23:04:54 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1581026694;\n\tbh=MuMO2iyibXDR112fE+gszYcEoqOhhEGm2JYz36QOUts=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=IN9n03JzatUB//tAgClJ+t4XQEbgcKhJs1D7Ni5hrw/Ia7xAxo55Ac/5lZXw4HvB1\n\txGVM+wLSua5dBEmCzwiKTkDGGC+1XYev0QAtSZvAZYYaipK8LYMQ29OoYr/fOoBjlb\n\tQPvrRmJf2E5hsymfnTHEMPlV51FkCakc+wxWjSis=","Date":"Fri, 7 Feb 2020 00:04:38 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Message-ID":"<20200206220438.GG7611@pendragon.ideasonboard.com>","References":"<20200206150504.24204-1-kieran.bingham@ideasonboard.com>\n\t<20200206150504.24204-2-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200206150504.24204-2-kieran.bingham@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 1/6] qcam: Tie FrameBufferAllocator to\n\tstream life","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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":"Thu, 06 Feb 2020 22:04:55 -0000"}},{"id":3643,"web_url":"https://patchwork.libcamera.org/comment/3643/","msgid":"<CAKQmDh83uX7NiwaY8UUgNvObNQissP74-7O26Qiq6MQg7Tot+Q@mail.gmail.com>","date":"2020-02-08T20:29:01","subject":"Re: [libcamera-devel] [PATCH 1/6] qcam: Tie FrameBufferAllocator to\n\tstream life","submitter":{"id":30,"url":"https://patchwork.libcamera.org/api/people/30/","name":"Nicolas Dufresne","email":"nicolas@ndufresne.ca"},"content":"Le jeu. 6 févr. 2020 10 h 05, Kieran Bingham <\nkieran.bingham@ideasonboard.com> a écrit :\n\n> The FrameBufferAllocator must be deleted and reconstructed before\n> performing\n> any reconfiguration of the stream.\n>\n> Construct the allocator at startCapture, and destroy it during stopCapture\n> so\n> that we can successfully stop and restart the stream.\n>\n\nCan you explain why adding this limitation. We have fixed this issue in v4l\nwith buffer orphaning, so I don't understand why introducing it again in\nsoftware.\n\nNot being able to orphan the buffer pool actually prevents zero-copy\nrenegotiation. Consider the case where the framebuffer is being used as\nyour display scan out. You need to reconfigure and produce a new buffer\nbefore this framebuffer can be returned.\n\n\n\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  src/qcam/main_window.cpp | 5 +++--\n>  1 file changed, 3 insertions(+), 2 deletions(-)\n>\n> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> index df51fa888342..38bc04a23b86 100644\n> --- a/src/qcam/main_window.cpp\n> +++ b/src/qcam/main_window.cpp\n> @@ -37,7 +37,6 @@ MainWindow::MainWindow(CameraManager *cm, const\n> OptionsParser::Options &options)\n>\n>         ret = openCamera(cm);\n>         if (!ret) {\n> -               allocator_ = FrameBufferAllocator::create(camera_);\n>                 ret = startCapture();\n>         }\n>\n> @@ -50,7 +49,6 @@ MainWindow::~MainWindow()\n>  {\n>         if (camera_) {\n>                 stopCapture();\n> -               delete allocator_;\n>                 camera_->release();\n>                 camera_.reset();\n>         }\n> @@ -171,6 +169,7 @@ int MainWindow::startCapture()\n>\n>         adjustSize();\n>\n> +       allocator_ = FrameBufferAllocator::create(camera_);\n>         ret = allocator_->allocate(stream);\n>         if (ret < 0) {\n>                 std::cerr << \"Failed to allocate capture buffers\" <<\n> std::endl;\n> @@ -255,6 +254,8 @@ void MainWindow::stopCapture()\n>         }\n>         mappedBuffers_.clear();\n>\n> +       delete allocator_;\n> +\n>         isCapturing_ = false;\n>\n>         config_.reset();\n> --\n> 2.20.1\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel\n>","headers":{"Return-Path":"<nicolas@ndufresne.ca>","Received":["from mail-pl1-x641.google.com (mail-pl1-x641.google.com\n\t[IPv6:2607:f8b0:4864:20::641])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2A5ED607EC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  8 Feb 2020 21:29:15 +0100 (CET)","by mail-pl1-x641.google.com with SMTP id g6so1175408plp.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 08 Feb 2020 12:29:14 -0800 (PST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ndufresne-ca.20150623.gappssmtp.com; s=20150623;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=Dqme9ZwbApS03Xvj0mFwaE0jRH1W2EroBz0WoJCYwRQ=;\n\tb=Yt73nPwilWkafSbqfvoph6gY5v6+C2v4bCiyPGPWu4HKRPkG5eQfUBfjDA3A6TS0NN\n\tqyXTiPHkPE5fA4SDWVxTcTmv6yHKwglPjpXnXS/Yi4wl+o3koLGPueul7m2bq0ALL1hu\n\toVF7+OG1oM171SmyAquUeavKfIeam0t1Q12kt+F9lJ0cpwHe/o1zUwU2KUvPPHawhSfH\n\tSzHq3YcoxoXg1jjac71sz8zG2PdEU1t2KfPK3DQwJ7BXZn3CFs4ulEe8BbdjEmVwGJw2\n\t1ZoZEM/hMuHtNYSpI7lsRsl+9cgDhqrHfnFGaENeva/VYPt25fosdOZ+hsJ8CbDTM5z7\n\tSpjg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=Dqme9ZwbApS03Xvj0mFwaE0jRH1W2EroBz0WoJCYwRQ=;\n\tb=kTzp9L0Bg90Ja0IpV9CNpvQvfbxedx70Bs5z0mfgJLRXTLgkEO8Il1OpUEFqjt0Sy+\n\ttVJI1uxHxFH1Zp6MqBLRGDQleE+02uA9lXwoWQjB7u77jSAsLUb6eP7Al1I4b6PkTj8o\n\tLLBoUKt8sC6wTihQGY4Ed2qlwvKTD3uV8Sh2Xt99q2TN0H1ZalVtVX2o0mzmC8Kvzqba\n\tMqjHGznVegNKJDTKqD3rdI7vGFU8VlzKclNGpabrNz1F4Iog6b5Vt89C71xumjWKTzcP\n\tAU06d7AoIijw5FucZ1ejFC4ik9wZBsJpIh4o07HiGb1CG1UlNzG7Z5Rj5iYY3vit9HDy\n\t70rA==","X-Gm-Message-State":"APjAAAXkitQWm5zxkgG9roEUk/KyBpqlSfyRyPQlS6m8bKBWZUag/1+j\n\taxOUHT7m2V1qoQRJj52Un3ZSLjy9X1NSVMhuDb/t2w==","X-Google-Smtp-Source":"APXvYqwPZmhQbkGWZcpK7XhBxSrtAOB1kiQy9N1j8oqf9oo0XEv47HlVon91KeGmG+315QFs+cNnYDauIebA2StKFnk=","X-Received":"by 2002:a17:90a:fb45:: with SMTP id\n\tiq5mr11804645pjb.93.1581193752852; \n\tSat, 08 Feb 2020 12:29:12 -0800 (PST)","MIME-Version":"1.0","References":"<20200206150504.24204-1-kieran.bingham@ideasonboard.com>\n\t<20200206150504.24204-2-kieran.bingham@ideasonboard.com>","In-Reply-To":"<20200206150504.24204-2-kieran.bingham@ideasonboard.com>","From":"Nicolas Dufresne <nicolas@ndufresne.ca>","Date":"Sat, 8 Feb 2020 15:29:01 -0500","Message-ID":"<CAKQmDh83uX7NiwaY8UUgNvObNQissP74-7O26Qiq6MQg7Tot+Q@mail.gmail.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Content-Type":"multipart/alternative; boundary=\"000000000000f5c9a9059e165b0d\"","Subject":"Re: [libcamera-devel] [PATCH 1/6] qcam: Tie FrameBufferAllocator to\n\tstream life","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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":"Sat, 08 Feb 2020 20:29:15 -0000"}}]