Skip to content

Commit d67df1f

Browse files
add-uosdeepin-bot[bot]
authored andcommitted
fix(camera): prefer DConfig resolution over local config (BUG-366203)
When preferredResolution is set via DConfig, use it directly instead of the locally cached resolution from config file on first launch. DConfig的preferredResolution配置优先于本地配置文件中的分辨率, 修复首次打开应用时仍使用本地旧配置的问题。 Log: 修复preferredResolution首次启动不生效的问题 PMS: BUG-366203 Influence: 设置preferredResolution后首次启动即可生效,无需重启两次。
1 parent e6dc8fc commit d67df1f

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/src/LPF_V4L2.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd.
2-
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
1+
// Copyright (C) 2020 - 2026 Uniontech Software Technology Co.,Ltd.
2+
// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.
33
//
44
// SPDX-License-Identifier: GPL-3.0-or-later
55

@@ -18,6 +18,7 @@ extern "C" {
1818
#include "audio.h"
1919
#include "core_io.h"
2020
#include "colorspaces.h"
21+
#include "v4l2_formats.h"
2122

2223
int camInit(const char *devicename)
2324
{
@@ -210,12 +211,15 @@ int camInit(const char *devicename)
210211
v4l2core_prepare_new_format(my_vd, (int)my_config->format);
211212

212213
if ((strcmp(my_config->device_name, devlist->list_devices[my_vd->this_device].name) == 0) && (strcmp(my_config->device_location, my_vd->videodevice) == 0)) {
213-
v4l2core_prepare_new_resolution(my_vd, my_config->width, my_config->height);
214-
// 分辨率可能已经被校正
215-
if (my_config->width != get_my_width() || my_config->height != get_my_height()) {
216-
printf("%s: adjust resolution(%dx%d => %dx%d)\n", __func__, my_config->width, my_config->height, get_my_width(), get_my_height());
214+
// DConfig preferredResolution 优先于本地配置文件中的分辨率
215+
if (get_preferred_resolution_width() > 0 && get_preferred_resolution_height() > 0) {
216+
v4l2core_prepare_new_resolution(my_vd,
217+
get_preferred_resolution_width(),
218+
get_preferred_resolution_height());
217219
my_config->width = get_my_width();
218220
my_config->height = get_my_height();
221+
} else {
222+
v4l2core_prepare_new_resolution(my_vd, my_config->width, my_config->height);
219223
}
220224
ret = v4l2core_update_old_format(my_vd, my_config->width, my_config->height, v4l2core_get_requested_frame_format(my_vd));
221225
} else {

0 commit comments

Comments
 (0)