From 6f8a814f29cb749eaf8a2ed37fdd67cc9a9b90eb 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 6a47472e4..6c8a17d4a 100644 --- a/spa/include/spa/pod/filter.h +++ b/spa/include/spa/pod/filter.h @@ -177,7 +177,7 @@ spa_pod_filter_prop(struct spa_pod_builder *b, nc = (struct spa_pod_choice*)spa_pod_builder_frame(b, &f); /* 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) || @@ -185,10 +185,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++; }