fix: sync resolution config after prepare_new_resolution (#372317) - #518
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: 修复相机分辨率配置与实际设置不同步的问题,确保配置文件记录的分辨率与实际使用的分辨率一致。
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,11 @@ int camInit(const char *devicename)
my_config->height = get_my_height();
} else {
- v4l2core_prepare_new_resolution(my_vd, my_config->width, my_config->height);
+ int prepare_ret = v4l2core_prepare_new_resolution(my_vd, my_config->width, my_config->height);
+ if (prepare_ret >= 0) {
+ my_config->width = get_my_width();
+ my_config->height = get_my_height();
+ } else {
+ // 处理分辨率准备失败的情况,记录日志或返回错误
+ return prepare_ret;
+ }
}
ret = v4l2core_update_old_format(my_vd, my_config->width, my_config->height, v4l2core_get_requested_frame_format(my_vd));
} else { |
|
[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 |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR ensures the internal camera configuration (my_config) width/height are synchronized with the actual device resolution after v4l2core_prepare_new_resolution, preventing mismatches between configuration and real capture settings. Sequence diagram for camInit resolution config synchronizationsequenceDiagram
participant camInit
participant v4l2core
participant device
participant my_config
camInit->>v4l2core: v4l2core_prepare_new_resolution(my_vd, my_config.width, my_config.height)
v4l2core->>device: apply_new_resolution()
device-->>v4l2core: actual_resolution
camInit->>device: get_my_width()
device-->>camInit: width
camInit->>my_config: width = get_my_width()
camInit->>device: get_my_height()
device-->>camInit: height
camInit->>my_config: height = get_my_height()
camInit->>v4l2core: v4l2core_update_old_format(my_vd, my_config.width, my_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
|
|
/merge |
|
This pr cannot be merged! (status: unstable) |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- If
v4l2core_prepare_new_resolutioncan fail or fall back to a different resolution, consider checking its return value before overwritingmy_config->width/heightwithget_my_width/heightso the config only reflects a successfully applied mode. - To keep behavior consistent, you might want to explicitly document or assert that
get_my_width/heightreturn the final negotiated resolution (not just the requested one), since the config is now fully driven by those accessors afterv4l2core_prepare_new_resolution.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- If `v4l2core_prepare_new_resolution` can fail or fall back to a different resolution, consider checking its return value before overwriting `my_config->width/height` with `get_my_width/height` so the config only reflects a successfully applied mode.
- To keep behavior consistent, you might want to explicitly document or assert that `get_my_width/height` return the final negotiated resolution (not just the requested one), since the config is now fully driven by those accessors after `v4l2core_prepare_new_resolution`.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
/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: