adapter: use the right default when filtering default

We should prefer the value of the follower when fixating to the
PortConfig format.

To make this actually work we need to be able to check if the value is
within the configured ranges. Implement the check for all types by
simply comparing the memory. This should then work also for checking
arrays, such as channel positions.
This commit is contained in:
Wim Taymans 2025-06-03 11:31:07 +02:00
parent a5e63102d9
commit 38a3ebdca1
3 changed files with 3 additions and 5 deletions

View file

@ -52,8 +52,6 @@ SPA_API_POD_COMPARE int spa_pod_compare_value(uint32_t type, const void *r1, con
return SPA_CMP(*(double *)r1, *(double *)r2); return SPA_CMP(*(double *)r1, *(double *)r2);
case SPA_TYPE_String: case SPA_TYPE_String:
return strcmp((char *)r1, (char *)r2); return strcmp((char *)r1, (char *)r2);
case SPA_TYPE_Bytes:
return memcmp((char *)r1, (char *)r2, size);
case SPA_TYPE_Rectangle: case SPA_TYPE_Rectangle:
{ {
const struct spa_rectangle *rec1 = (struct spa_rectangle *) r1, const struct spa_rectangle *rec1 = (struct spa_rectangle *) r1,
@ -75,7 +73,7 @@ SPA_API_POD_COMPARE int spa_pod_compare_value(uint32_t type, const void *r1, con
return SPA_CMP(n1, n2); return SPA_CMP(n1, n2);
} }
default: default:
break; return memcmp(r1, r2, size);
} }
return 0; return 0;
} }

View file

@ -927,7 +927,7 @@ static struct spa_pod *merge_objects(struct impl *this, struct spa_pod_builder *
p2 = spa_pod_object_find_prop(o2, p2, p1->key); p2 = spa_pod_object_find_prop(o2, p2, p1->key);
if (p2 != NULL) { if (p2 != NULL) {
spa_pod_builder_get_state(b, &state); spa_pod_builder_get_state(b, &state);
res = spa_pod_filter_prop(b, p1, p2); res = spa_pod_filter_prop(b, p2, p1);
if (res < 0) if (res < 0)
spa_pod_builder_reset(b, &state); spa_pod_builder_reset(b, &state);
} }

View file

@ -978,7 +978,7 @@ static struct spa_pod *merge_objects(struct impl *this, struct spa_pod_builder *
p2 = spa_pod_object_find_prop(o2, p2, p1->key); p2 = spa_pod_object_find_prop(o2, p2, p1->key);
if (p2 != NULL) { if (p2 != NULL) {
spa_pod_builder_get_state(b, &state); spa_pod_builder_get_state(b, &state);
res = spa_pod_filter_prop(b, p1, p2); res = spa_pod_filter_prop(b, p2, p1);
if (res < 0) if (res < 0)
spa_pod_builder_reset(b, &state); spa_pod_builder_reset(b, &state);
} }