v4l2: Use the node format when available

When the node we try to link to already has a format, return that to the
application because we can't renegotiate to a new format.
This commit is contained in:
Wim Taymans 2022-11-08 16:25:21 +01:00
parent f6d7d4372b
commit 0d24f6b35f

View file

@ -1582,19 +1582,26 @@ static int try_format(struct file *file, struct v4l2_format *fmt)
struct v4l2_format tmp;
int score;
if (p->id != SPA_PARAM_EnumFormat || p->param == NULL)
if (p->param == NULL)
continue;
if (p->id != SPA_PARAM_EnumFormat && p->id != SPA_PARAM_Format)
continue;
if (param_to_fmt(p->param, &tmp) < 0)
continue;
score = score_diff(fmt, &tmp);
pw_log_debug("check: type: %u", tmp.type);
pw_log_debug("check: format: %.4s", (char*)&tmp.fmt.pix.pixelformat);
pw_log_debug("check: width: %u", tmp.fmt.pix.width);
pw_log_debug("check: height: %u", tmp.fmt.pix.height);
pw_log_debug("check: score: %d best:%d", score, best);
pw_log_info("check: type: %u", tmp.type);
pw_log_info("check: format: %.4s", (char*)&tmp.fmt.pix.pixelformat);
pw_log_info("check: width: %u", tmp.fmt.pix.width);
pw_log_info("check: height: %u", tmp.fmt.pix.height);
pw_log_info("check: score: %d best:%d", score, best);
if (p->id == SPA_PARAM_Format) {
best_fmt = tmp;
break;
}
if (best == -1 || score < best) {
best = score;
best_fmt = tmp;