Show a patch.

GET /api/1.1/patches/3833/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 3833,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/3833/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3833/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20200521135416.13685-4-email@uajain.com>",
    "date": "2020-05-21T13:54:25",
    "name": "[libcamera-devel,v3,3/5] libcamera: camera_manager: Introduce signals when a camera is added/removed",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "5d2096fe4f230cb37887aa4ff6fc95bf89f77634",
    "submitter": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/people/1/?format=api",
        "name": "Umang Jain",
        "email": "email@uajain.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/3833/mbox/",
    "series": [
        {
            "id": 920,
            "url": "https://patchwork.libcamera.org/api/1.1/series/920/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=920",
            "date": "2020-05-21T13:54:23",
            "name": "Introduce UVC hotplugging support",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/920/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3833/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3833/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<bounces+15657259-5c31-libcamera-devel=lists.libcamera.org@em7280.uajain.com>",
        "Received": [
            "from o1.f.az.sendgrid.net (o1.f.az.sendgrid.net [208.117.55.132])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BA68960E08\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 May 2020 15:54:26 +0200 (CEST)",
            "by filterdrecv-p3iad2-8ddf98858-xm5rk with SMTP id\n\tfilterdrecv-p3iad2-8ddf98858-xm5rk-18-5EC68811-11\n\t2020-05-21 13:54:25.414650661 +0000 UTC m=+4807854.394384064",
            "from mail.uajain.com (unknown)\n\tby ismtpd0008p1maa1.sendgrid.net (SG) with ESMTP id\n\tNWP7hY6pRuS3tH6hTbiaGQ for <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 May 2020 13:54:24.614 +0000 (UTC)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=uajain.com\n\theader.i=@uajain.com header.b=\"oMHhjdfs\"; \n\tdkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=uajain.com;\n\th=from:subject:in-reply-to:references:mime-version:to:cc:\n\tcontent-transfer-encoding:content-type;\n\ts=s1; bh=Df4ZvtW1VJ32k7ot9799b04IQDgezPZJIKxu8lNrNt0=;\n\tb=oMHhjdfszSDQJOBJ+v6OOqo2Onn0nupvBm3g2EO2eZads9pKnZRC60JhYm5SirM9MiAZ\n\thWenV9Mm+QOo1eNByvng+rYXBjsdPXC+x90WqxVvFjIqxInCaqYQwpILGNtboCGTuh+Ti7\n\t84mQub6dELx9qcVooHkW6PZ9vFvorskZQ=",
        "From": "Umang Jain <email@uajain.com>",
        "Date": "Thu, 21 May 2020 13:54:25 +0000 (UTC)",
        "Message-Id": "<20200521135416.13685-4-email@uajain.com>",
        "In-Reply-To": "<20200521135416.13685-1-email@uajain.com>",
        "References": "<20200521135416.13685-1-email@uajain.com>",
        "Mime-Version": "1.0",
        "X-SG-EID": "1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPcHIuSzkf5/M5SksOT1pntG7QXTTZK2cE1S7jwIaCKrb/mbbypVgSEEUHuO3QBMfxxVazHlquUhRPeV6ihAIwFbVMpYvTr2j+FAYbzl8NFIA3BUZ+j7RkJRsq7H8GO6fLsCVipybfAfgfgqpzG3Kiwlzd7FWFVmconZFxj/RWrP6G9NNqfy9lwXwqj7bAUj65Mp4aYuCEUz96n6qk5xb/nHA==",
        "To": "libcamera-devel@lists.libcamera.org",
        "Content-Transfer-Encoding": "7bit",
        "Content-Type": "text/plain; charset=us-ascii",
        "Subject": "[libcamera-devel] [PATCH v3 3/5] libcamera: camera_manager:\n\tIntroduce signals when a camera is added/removed",
        "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, 21 May 2020 13:54:27 -0000"
    },
    "content": "Emit 'newCameraAdded' and 'cameraRemoved' from CameraManager to enable\nhotplug and hot-unplug support in appplication like QCam.\n\nTo avoid use-after-free race between the CameraManager and the\napplication, emit the 'cameraRemoved' with the shared_ptr version\nof <Camera *>. This requires to change the function signature of\nCameraManager::removeCamera() API.\n\nSigned-off-by: Umang Jain <email@uajain.com>\n---\n include/libcamera/camera_manager.h |  6 ++++-\n src/libcamera/camera_manager.cpp   | 36 +++++++++++++++++++++++++++---\n src/libcamera/pipeline_handler.cpp |  2 +-\n 3 files changed, 39 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h\nindex 079f848..365e286 100644\n--- a/include/libcamera/camera_manager.h\n+++ b/include/libcamera/camera_manager.h\n@@ -13,6 +13,7 @@\n #include <vector>\n \n #include <libcamera/object.h>\n+#include <libcamera/signal.h>\n \n namespace libcamera {\n \n@@ -35,13 +36,16 @@ public:\n \tstd::shared_ptr<Camera> get(dev_t devnum);\n \n \tvoid addCamera(std::shared_ptr<Camera> camera, dev_t devnum);\n-\tvoid removeCamera(Camera *camera);\n+\tvoid removeCamera(std::shared_ptr<Camera> camera);\n \n \tstatic const std::string &version() { return version_; }\n \n \tvoid setEventDispatcher(std::unique_ptr<EventDispatcher> dispatcher);\n \tEventDispatcher *eventDispatcher();\n \n+\tSignal<std::shared_ptr<Camera>> newCameraAdded;\n+\tSignal<std::shared_ptr<Camera>> cameraRemoved;\n+\n private:\n \tstatic const std::string version_;\n \tstatic CameraManager *self_;\ndiff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\nindex 27064d2..bdd78f5 100644\n--- a/src/libcamera/camera_manager.cpp\n+++ b/src/libcamera/camera_manager.cpp\n@@ -185,7 +185,7 @@ void CameraManager::Private::addCamera(std::shared_ptr<Camera> &camera,\n \t\t}\n \t}\n \n-\tcameras_.push_back(std::move(camera));\n+\tcameras_.push_back(camera);\n \n \tif (devnum) {\n \t\tunsigned int index = cameras_.size() - 1;\n@@ -375,6 +375,34 @@ std::shared_ptr<Camera> CameraManager::get(dev_t devnum)\n \treturn iter->second.lock();\n }\n \n+/**\n+ * \\var CameraManager::newCameraAdded\n+ * \\brief Notify of a new camera added to the system\n+ *\n+ * This signal is emitted when a new camera is detected and successfully handled\n+ * by the camera manager. The notification occurs alike for cameras detected\n+ * when the manager is started with start() or when new cameras are later\n+ * connected to the system. When the signal is emitted the new camera is already\n+ * available from the list of cameras().\n+ *\n+ * The signal is emitted from the CameraManager thread. Applications shall\n+ * minimize the time spent in the signal handler and shall in particular not\n+ * perform any blocking operation.\n+ */\n+\n+/**\n+ * \\var CameraManager::cameraRemoved\n+ * \\brief Notify of a new camera removed from the system\n+ *\n+ * This signal is emitted when a camera is removed from the system. When the\n+ * signal is emitted the camera is not available from the list of cameras()\n+ * anymore.\n+ *\n+ * The signal is emitted from the CameraManager thread. Applications shall\n+ * minimize the time spent in the signal handler and shall in particular not\n+ * perform any blocking operation.\n+ */\n+\n /**\n  * \\brief Add a camera to the camera manager\n  * \\param[in] camera The camera to be added\n@@ -394,6 +422,7 @@ void CameraManager::addCamera(std::shared_ptr<Camera> camera, dev_t devnum)\n \tASSERT(Thread::current() == p_.get());\n \n \tp_->addCamera(camera, devnum);\n+\tnewCameraAdded.emit(camera);\n }\n \n /**\n@@ -406,11 +435,12 @@ void CameraManager::addCamera(std::shared_ptr<Camera> camera, dev_t devnum)\n  *\n  * \\context This function shall be called from the CameraManager thread.\n  */\n-void CameraManager::removeCamera(Camera *camera)\n+void CameraManager::removeCamera(std::shared_ptr<Camera> camera)\n {\n \tASSERT(Thread::current() == p_.get());\n \n-\tp_->removeCamera(camera);\n+\tp_->removeCamera(camera.get());\n+\tcameraRemoved.emit(camera);\n }\n \n /**\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex 53aeebd..9a1e6ff 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -555,7 +555,7 @@ void PipelineHandler::disconnect()\n \t\t\tcontinue;\n \n \t\tcamera->disconnect();\n-\t\tmanager_->removeCamera(camera.get());\n+\t\tmanager_->removeCamera(camera);\n \t}\n \n \tcameras_.clear();\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "3/5"
    ]
}