From 3abda54d80cb02cacb25b9a66ce2808dc4615b34 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 19 Mar 2025 17:04:38 +0100 Subject: [PATCH] pod: use default value of filter When using a filter, it makes more sense to use the default value of the filter as a first attempt. One case is in adapter when we try to find a passthrough format first. The audioconverter suggests a default rate of the graph rate but the follower filters this out for another unrelated default value and passthrough is not possible (altough it would be because the default value of the filter is in the supported follower range). Fixes #4619 --- spa/include/spa/pod/filter.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spa/include/spa/pod/filter.h b/spa/include/spa/pod/filter.h index 2cfc7bf08..9e265f9b7 100644 --- a/spa/include/spa/pod/filter.h +++ b/spa/include/spa/pod/filter.h @@ -181,7 +181,7 @@ spa_pod_filter_prop(struct spa_pod_builder *b, nc = &dummy; /* default value */ - spa_pod_builder_primitive(b, v1); + spa_pod_builder_primitive(b, v2); if ((p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_None) || (p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_Enum) || @@ -189,10 +189,10 @@ spa_pod_filter_prop(struct spa_pod_builder *b, (p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Enum)) { int n_copied = 0; /* copy all equal values but don't copy the default value again */ - for (j = 0, a1 = alt1; j < nalt1; j++, a1 = SPA_PTROFF(a1, size, void)) { - for (k = 0, a2 = alt2; k < nalt2; k++, a2 = SPA_PTROFF(a2,size,void)) { + for (j = 0, a2 = alt2; j < nalt2; j++, a2 = SPA_PTROFF(a2, size, void)) { + for (k = 0, a1 = alt1; k < nalt1; k++, a1 = SPA_PTROFF(a1,size,void)) { if (spa_pod_compare_value(type, a1, a2, size) == 0) { - if (p1c == SPA_CHOICE_Enum || j > 0) + if (p2c == SPA_CHOICE_Enum || j > 0) spa_pod_builder_raw(b, a1, size); n_copied++; }