From 38a3ebdca14b1e79f9e7053cb43ea464e0a92015 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 3 Jun 2025 11:31:07 +0200 Subject: [PATCH] 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. --- spa/include/spa/pod/compare.h | 4 +--- spa/plugins/audioconvert/audioadapter.c | 2 +- spa/plugins/videoconvert/videoadapter.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/spa/include/spa/pod/compare.h b/spa/include/spa/pod/compare.h index a9d0f2696..12c65fd44 100644 --- a/spa/include/spa/pod/compare.h +++ b/spa/include/spa/pod/compare.h @@ -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); case SPA_TYPE_String: return strcmp((char *)r1, (char *)r2); - case SPA_TYPE_Bytes: - return memcmp((char *)r1, (char *)r2, size); case SPA_TYPE_Rectangle: { 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); } default: - break; + return memcmp(r1, r2, size); } return 0; } diff --git a/spa/plugins/audioconvert/audioadapter.c b/spa/plugins/audioconvert/audioadapter.c index e9595aa1d..e9ff63009 100644 --- a/spa/plugins/audioconvert/audioadapter.c +++ b/spa/plugins/audioconvert/audioadapter.c @@ -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); if (p2 != NULL) { 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) spa_pod_builder_reset(b, &state); } diff --git a/spa/plugins/videoconvert/videoadapter.c b/spa/plugins/videoconvert/videoadapter.c index 9eae268e1..84a24cd2d 100644 --- a/spa/plugins/videoconvert/videoadapter.c +++ b/spa/plugins/videoconvert/videoadapter.c @@ -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); if (p2 != NULL) { 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) spa_pod_builder_reset(b, &state); }