Skip to content

fix: sync resolution config after prepare_new_resolution (#372317) - #519

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:release/eaglefrom
add-uos:release/eagle
Aug 18, 2026
Merged

fix: sync resolution config after prepare_new_resolution (#372317)#519
deepin-bot[bot] merged 1 commit into
linuxdeepin:release/eaglefrom
add-uos:release/eagle

Conversation

@add-uos

@add-uos add-uos commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Sync my_config width/height with actual values after v4l2core_prepare_new_resolution to avoid config mismatch.

在 v4l2core_prepare_new_resolution 调用后同步 my_config 的 宽高配置,避免配置值与实际分辨率不一致。

Log: 同步分辨率配置
PMS: BUG-372317
Influence: 修复相机分辨率配置与实际设置不同步的问题,确保配置文件记录的分辨率与实际使用的分辨率一致。

Summary by Sourcery

Bug Fixes:

  • Synchronize the stored camera width and height with the actual resolution after preparing a new resolution, preventing configuration mismatches.

Sync my_config width/height with actual values after
v4l2core_prepare_new_resolution to avoid config mismatch.

在 v4l2core_prepare_new_resolution 调用后同步 my_config 的
宽高配置,避免配置值与实际分辨率不一致。

Log: 同步分辨率配置
PMS: BUG-372317
Influence: 修复相机分辨率配置与实际设置不同步的问题,确保配置文件记录的分辨率与实际使用的分辨率一致。
@sourcery-ai

sourcery-ai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR ensures the in-memory camera resolution configuration (my_config) is updated to reflect the actual resolution after v4l2core_prepare_new_resolution is called, preventing mismatches between configured and active resolution values.

Sequence diagram for updated resolution sync in camInit

sequenceDiagram
    participant camInit
    participant v4l2core
    participant config as my_config

    camInit->>v4l2core: v4l2core_prepare_new_resolution(my_vd, config.width, config.height)
    camInit->>camInit: get_my_width()
    camInit->>camInit: get_my_height()
    camInit->>config: update width, height
    camInit->>v4l2core: v4l2core_update_old_format(my_vd, config.width, config.height, v4l2core_get_requested_frame_format(my_vd))
Loading

File-Level Changes

Change Details Files
Ensure camera configuration width/height are resynced from the actual device values after preparing a new resolution so subsequent logic uses consistent resolution data.
  • After calling v4l2core_prepare_new_resolution, fetch the current width from the device via get_my_width and store it in my_config->width.
  • After calling v4l2core_prepare_new_resolution, fetch the current height from the device via get_my_height and store it in my_config->height.
  • Preserve existing logic for initializing resolution when my_width/my_height are not yet set, only modifying the branch where a new resolution is prepared.
src/src/LPF_V4L2.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:95分

■ 【总体评价】

代码修复了分辨率配置未同步的逻辑缺陷,确保后续函数使用正确的参数。
逻辑完全正确且无安全风险,属于高质量的BUG修复补丁。

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓

camInit 函数的 else 分支中,调用 v4l2core_prepare_new_resolution 之后,通过 get_my_width()get_my_height() 重新获取并更新 my_config->widthmy_config->height,确保后续调用 v4l2core_update_old_format 时使用的是最新同步的分辨率参数。
潜在问题:无
建议:无需修改,逻辑严谨。

  • 2.代码质量(良好)✓

代码风格与上下文保持一致,修改简洁明了,直接针对问题点进行修复,未引入冗余代码。
潜在问题:无
建议:可考虑在代码处添加简短注释,说明为何在 prepare_new_resolution 后需要重新获取宽高,以便后续维护。

  • 3.代码性能(无性能问题)✓

新增的仅为两个简单的取值赋值操作,时间复杂度为 O(1),对系统性能无任何负面影响。
潜在问题:
建议:无需优化。

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次代码修改仅涉及配置参数的同步更新,不涉及外部输入处理、内存越界或权限操作,不存在安全风险。

  • 建议:无需安全修复。

■ 【改进建议代码示例】

diff --git a/src/src/LPF_V4L2.c b/src/src/LPF_V4L2.c
index 7a79ecdf..a6a180b4 100644
--- a/src/src/LPF_V4L2.c
+++ b/src/src/LPF_V4L2.c
@@ -220,6 +220,8 @@ int camInit(const char *devicename)
                 my_config->height = get_my_height();
             } else {
                 v4l2core_prepare_new_resolution(my_vd, my_config->width, my_config->height);
+                // 同步最新的分辨率配置,防止后续更新使用过期参数
+                my_config->width  = get_my_width();
+                my_config->height = get_my_height();
             }
             ret = v4l2core_update_old_format(my_vd, my_config->width, my_config->height, v4l2core_get_requested_frame_format(my_vd));
         } else {

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Consider updating my_config->width/height only after checking the return value of v4l2core_prepare_new_resolution so that the configuration is not updated when the resolution change fails.
  • If get_my_width() / get_my_height() are reading from shared global state, double-check that calling them here cannot race with other threads changing resolution, otherwise you may want to centralize the resolution source or add appropriate synchronization.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider updating `my_config->width`/`height` only after checking the return value of `v4l2core_prepare_new_resolution` so that the configuration is not updated when the resolution change fails.
- If `get_my_width()` / `get_my_height()` are reading from shared global state, double-check that calling them here cannot race with other threads changing resolution, otherwise you may want to centralize the resolution source or add appropriate synchronization.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, lzwind

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@add-uos

add-uos commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: unstable)

@deepin-bot
deepin-bot Bot merged commit c9d987f into linuxdeepin:release/eagle Aug 18, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants