Patch Detail
Show a patch.
GET /api/patches/9274/?format=api
{ "id": 9274, "url": "https://patchwork.libcamera.org/api/patches/9274/?format=api", "web_url": "https://patchwork.libcamera.org/patch/9274/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20200810120406.52654-5-email@uajain.com>", "date": "2020-08-10T12:04:14", "name": "[libcamera-devel,v2,4/4] android: camera_hal_manager: Handle hot-unplug of currently open camera", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "ede59c88a9a74b07226df4b870bdc81b24a374eb", "submitter": { "id": 1, "url": "https://patchwork.libcamera.org/api/people/1/?format=api", "name": "Umang Jain", "email": "email@uajain.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/9274/mbox/", "series": [ { "id": 1210, "url": "https://patchwork.libcamera.org/api/series/1210/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1210", "date": "2020-08-10T12:04:11", "name": "android: Camera hotplug support", "version": 2, "mbox": "https://patchwork.libcamera.org/series/1210/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/9274/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/9274/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D481FBD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 10 Aug 2020 12:04:18 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A0BD460DCA;\n\tMon, 10 Aug 2020 14:04:18 +0200 (CEST)", "from o1.f.az.sendgrid.net (o1.f.az.sendgrid.net [208.117.55.132])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0657460E89\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 10 Aug 2020 14:04:15 +0200 (CEST)", "by filterdrecv-p3mdw1-7ff865655c-8dgl4 with SMTP id\n\tfilterdrecv-p3mdw1-7ff865655c-8dgl4-17-5F3137BE-AA\n\t2020-08-10 12:04:14.852928121 +0000 UTC m=+1014484.473196805", "from mail.uajain.com (unknown)\n\tby ismtpd0006p1maa1.sendgrid.net (SG) with ESMTP id\n\tdv0XAPOxRNKcg96xkeHjSQ for <libcamera-devel@lists.libcamera.org>;\n\tMon, 10 Aug 2020 12:04:14.467 +0000 (UTC)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=uajain.com header.i=@uajain.com\n\theader.b=\"vrY0woxL\"; dkim-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=hRI3QrkrdUUb2GfoxLz6TSSt2ZtkOZOlo3hKcH4mQIo=;\n\tb=vrY0woxLq8rOya3FVh71M+t4LJFEB/c1S23IRDyOuNnQAIgLu09dfzRDjV5PB4YMSL6D\n\tuTCoBZWh9GMeXZhKMCxHpeOsx18aK2O8qsLevxricFT9EdwV07MoEiFFj3ftBwtMybGRH+\n\t/4kjo7h6j49g7sjc7yeq29ykSS0AgIkXQ=", "From": "Umang Jain <email@uajain.com>", "Date": "Mon, 10 Aug 2020 12:04:14 +0000 (UTC)", "Message-Id": "<20200810120406.52654-5-email@uajain.com>", "In-Reply-To": "<20200810120406.52654-1-email@uajain.com>", "References": "<20200810120406.52654-1-email@uajain.com>", "Mime-Version": "1.0", "X-SG-EID": "1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPcO0wIVNwfic3Culi7Uik3lzUh+gFX7nrLTXMz/5XSKoetSIgIsTB3YntnH97XAgGKc06ApYMZ7L0zlgppraeFgCulJ7sEjSlSD7S3r2YOMpV4kFprWoqsp56uD99TvWz035kuC/3/dIyAS5ASQnyKsZASegiFQN14XlruLT24FFlpD865ejz/e9CE1I3NzTRKoKPc93QVM1gNcRwzia7i5w==", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[libcamera-devel] [PATCH v2 4/4] android: camera_hal_manager:\n\tHandle hot-unplug of currently open camera", "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>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Maintain an extra ref for the currently open camera in CameraHalManager.\nThis will ensure we have an graceful handling if the currently open\ncamera is hot-unplugged.\n\nSigned-off-by: Umang Jain <email@uajain.com>\n---\n src/android/camera_device.h | 1 +\n src/android/camera_hal_manager.cpp | 18 +++++++++++++++---\n src/android/camera_hal_manager.h | 2 ++\n 3 files changed, 18 insertions(+), 3 deletions(-)", "diff": "diff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex 7f9e010..2dc0a20 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -61,6 +61,7 @@ public:\n \n \tint facing() const { return facing_; }\n \tint orientation() const { return orientation_; }\n+\tbool running() { return running_; }\n \n \tvoid setCallbacks(const camera3_callback_ops_t *callbacks);\n \tconst camera_metadata_t *getStaticMetadata();\ndiff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp\nindex fdde2c0..9db5954 100644\n--- a/src/android/camera_hal_manager.cpp\n+++ b/src/android/camera_hal_manager.cpp\n@@ -38,6 +38,8 @@ CameraHalManager::~CameraHalManager()\n \tcameras_.clear();\n \tcamerasMap_.clear();\n \n+\tcameraInUse_.reset();\n+\n \tif (cameraManager_) {\n \t\tcameraManager_->stop();\n \t\tdelete cameraManager_;\n@@ -55,6 +57,7 @@ int CameraHalManager::init()\n \n \tcameraCounter_ = 0;\n \texternalCameraCounter_ = 1000;\n+\tcameraInUse_ = nullptr;\n \n \tint ret = cameraManager_->start();\n \tif (ret) {\n@@ -82,14 +85,17 @@ CameraDevice *CameraHalManager::open(unsigned int id,\n \t\treturn nullptr;\n \t}\n \n-\tCameraDevice *camera = iter->get();\n+\tif (cameraInUse_)\n+\t\tcameraInUse_.reset();\n+\n+\tcameraInUse_ = std::move(*iter);\n \n-\tif (camera->open(hardwareModule))\n+\tif (cameraInUse_->open(hardwareModule))\n \t\treturn nullptr;\n \n \tLOG(HAL, Info) << \"Open camera '\" << id << \"'\";\n \n-\treturn camera;\n+\treturn cameraInUse_.get();\n }\n \n void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n@@ -169,6 +175,12 @@ void CameraHalManager::cameraRemoved(std::shared_ptr<Camera> cam)\n \tunsigned int id = (*iter)->id();\n \tcallbacks_->camera_device_status_change(callbacks_, id,\n \t\t\t\t\t\tCAMERA_DEVICE_STATUS_NOT_PRESENT);\n+\n+\tif (*iter == cameraInUse_ && cameraInUse_->running()) {\n+\t\tcameraInUse_->close();\n+\t\tcameraInUse_.reset();\n+\t}\n+\n \tcameras_.erase(iter);\n \n \tLOG(HAL, Debug) << \"Camera ID: \" << id << \" removed successfully.\";\ndiff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h\nindex 7c481d4..974d53d 100644\n--- a/src/android/camera_hal_manager.h\n+++ b/src/android/camera_hal_manager.h\n@@ -48,6 +48,8 @@ private:\n \tstd::map<std::string, unsigned int> camerasMap_;\n \tMutex mutex_;\n \n+\tstd::shared_ptr<CameraDevice> cameraInUse_;\n+\n \tunsigned int externalCameraCounter_;\n \tunsigned int cameraCounter_;\n };\n", "prefixes": [ "libcamera-devel", "v2", "4/4" ] }