fix: sync resolution config after prepare_new_resolution (#372317) - #519
Conversation
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: 修复相机分辨率配置与实际设置不同步的问题,确保配置文件记录的分辨率与实际使用的分辨率一致。
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis 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 camInitsequenceDiagram
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))
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 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 { |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider updating
my_config->width/heightonly after checking the return value ofv4l2core_prepare_new_resolutionso 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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
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: