Show a patch.

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

{
    "id": 23069,
    "url": "https://patchwork.libcamera.org/api/patches/23069/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/23069/",
    "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": "<20250328160736.94529-1-barnabas.pocze@ideasonboard.com>",
    "date": "2025-03-28T16:07:36",
    "name": "[v1] gstreamer: Use `Control<>` objects when setting controls",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "5344edf8a6dd0f7ff57ca8abef018b799c50e7f9",
    "submitter": {
        "id": 216,
        "url": "https://patchwork.libcamera.org/api/people/216/?format=api",
        "name": "Barnabás Pőcze",
        "email": "barnabas.pocze@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/23069/mbox/",
    "series": [
        {
            "id": 5092,
            "url": "https://patchwork.libcamera.org/api/series/5092/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5092",
            "date": "2025-03-28T16:07:36",
            "name": "[v1] gstreamer: Use `Control<>` objects when setting controls",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/5092/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/23069/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/23069/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 78B96C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 28 Mar 2025 16:07:43 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7327F6897D;\n\tFri, 28 Mar 2025 17:07:42 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 104DF614E9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 28 Mar 2025 17:07:41 +0100 (CET)",
            "from pb-laptop.local (185.221.143.221.nat.pool.zt.hu\n\t[185.221.143.221])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6714E9FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 28 Mar 2025 17:05:51 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"aFWXDYfT\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1743177951;\n\tbh=jLa1jqP8RpuJU/h79ARBMTUXxxCO9yHpv6aRS7vshVc=;\n\th=From:To:Subject:Date:From;\n\tb=aFWXDYfT4zucbtqwi2CX+m/+oLUqCNL8kI6k5/pADsuC3rG8trvrZbrbHN+A1gsR4\n\t8cnH5MfmN6B4tHb5wnxiwQh4aVT0nqYnG4BWlDT5cC0nOdyH6YpOFPOmVEFWFZzvxE\n\tutvTLeVZjmJOsTk+EdCt+PNxzHr4xXy1YhHcf1+A=",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[PATCH v1] gstreamer: Use `Control<>` objects when setting controls",
        "Date": "Fri, 28 Mar 2025 17:07:36 +0100",
        "Message-ID": "<20250328160736.94529-1-barnabas.pocze@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.49.0",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "`g_value_get_boolean()` returns `gboolean`, which is actually `int`. Thus\n\n  // ControlValue x;\n  auto val = g_value_get_boolean(...);\n  x.set(val);\n\nwill cause `ControlValue::set<int, ...>(const int&)` to be called, which\nwill save the value as `ControlTypeInteger32`, not `ControlTypeBoolean`.\n\nThen, if something tries to retrieve the boolean value, it will run into an\nassertion failure:\n\n  Assertion `type_ == details::control_type<std::remove_cv_t<T>>::value' failed.\n\nin `ControlValue::set()`.\n\nFix this by using the appropriately typed `Control<>` object when setting\nthe value in the `ControlList` as this ensures that the value will be\nconverted to the actual type of the control.\n\nBug: https://bugs.libcamera.org/show_bug.cgi?id=261\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\nThere is a simpler fix to this issue as well:\n\n\tdiff --git a/src/gstreamer/gstlibcamera-controls.cpp.in b/src/gstreamer/gstlibcamera-controls.cpp.in\n\tindex d937b19e6..8378b5fd0 100644\n\t--- a/src/gstreamer/gstlibcamera-controls.cpp.in\n\t+++ b/src/gstreamer/gstlibcamera-controls.cpp.in\n\t@@ -271,7 +271,7 @@ bool GstCameraControls::setProperty(guint propId, const GValue *value,\n\t\t\t}\n\t\t\tRectangle val = value_get_rectangle(value);\n\t{%- else %}\n\t-               auto val = g_value_get_{{ ctrl.gtype }}(value);\n\t+               {{ ctrl.element_type }} val = g_value_get_{{ ctrl.gtype }}(value);\n\t{%- endif %}\n\t\t\tcontrol.set(val);\n\t{%- endif %}\n\n---\n src/gstreamer/gstlibcamera-controls.cpp.in | 13 ++++---------\n 1 file changed, 4 insertions(+), 9 deletions(-)\n\n--\n2.49.0",
    "diff": "diff --git a/src/gstreamer/gstlibcamera-controls.cpp.in b/src/gstreamer/gstlibcamera-controls.cpp.in\nindex d937b19e6..89c530da0 100644\n--- a/src/gstreamer/gstlibcamera-controls.cpp.in\n+++ b/src/gstreamer/gstlibcamera-controls.cpp.in\n@@ -223,7 +223,6 @@ bool GstCameraControls::setProperty(guint propId, const GValue *value,\n {%- for ctrl in ctrls %}\n\n \tcase controls::{{ ctrl.namespace }}{{ ctrl.name|snake_case|upper }}: {\n-\t\tControlValue control;\n {%- if ctrl.is_array %}\n \t\tsize_t size = gst_value_array_get_size(value);\n {%- if ctrl.size != 0 %}\n@@ -254,12 +253,9 @@ bool GstCameraControls::setProperty(guint propId, const GValue *value,\n \t\t}\n\n {%- if ctrl.size == 0 %}\n-\t\tcontrol.set(Span<const {{ ctrl.element_type }}>(values.data(),\n-\t\t\t\t\t\t\t\tsize));\n+\t\tSpan<const {{ ctrl.element_type }}> val(values.data(), size);\n {%- else %}\n-\t\tcontrol.set(Span<const {{ ctrl.element_type }},\n-\t\t\t         {{ ctrl.size }}>(values.data(),\n-\t\t\t\t\t\t  {{ ctrl.size }}));\n+\t\tSpan<const {{ ctrl.element_type }}, {{ ctrl.size }}> val(values.data(), size);\n {%- endif %}\n {%- else %}\n {%- if ctrl.is_rectangle %}\n@@ -273,10 +269,9 @@ bool GstCameraControls::setProperty(guint propId, const GValue *value,\n {%- else %}\n \t\tauto val = g_value_get_{{ ctrl.gtype }}(value);\n {%- endif %}\n-\t\tcontrol.set(val);\n {%- endif %}\n-\t\tcontrols_.set(propId, control);\n-\t\tcontrols_acc_.set(propId, control);\n+\t\tcontrols_.set(controls::{{ ctrl.namespace }}{{ ctrl.name }}, val);\n+\t\tcontrols_acc_.set(controls::{{ ctrl.namespace }}{{ ctrl.name }}, val);\n \t\treturn true;\n \t}\n {%- endfor %}\n",
    "prefixes": [
        "v1"
    ]
}