mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-03-26 07:58:03 -04:00
spa: merge Range and Step filter together
They share all of the code and the step just has an extra check for the step values.
This commit is contained in:
parent
b238c9d7a1
commit
4b3be9cc9b
1 changed files with 21 additions and 48 deletions
|
|
@ -200,7 +200,9 @@ spa_pod_filter_prop(struct spa_pod_builder *b,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_Range) ||
|
if ((p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_Range) ||
|
||||||
(p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Range)) {
|
(p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Range) ||
|
||||||
|
(p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_Step) ||
|
||||||
|
(p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Step)) {
|
||||||
int n_copied = 0;
|
int n_copied = 0;
|
||||||
/* copy all values inside the range */
|
/* copy all values inside the range */
|
||||||
for (j = 0, a1 = alt1, a2 = alt2; j < nalt1; j++, a1 = SPA_PTROFF(a1,size,void)) {
|
for (j = 0, a1 = alt1, a2 = alt2; j < nalt1; j++, a1 = SPA_PTROFF(a1,size,void)) {
|
||||||
|
|
@ -208,29 +210,14 @@ spa_pod_filter_prop(struct spa_pod_builder *b,
|
||||||
continue;
|
continue;
|
||||||
if (spa_pod_compare_value(type, a1, SPA_PTROFF(a2,size,void), size) > 0)
|
if (spa_pod_compare_value(type, a1, SPA_PTROFF(a2,size,void), size) > 0)
|
||||||
continue;
|
continue;
|
||||||
spa_pod_builder_raw(b, a1, size);
|
|
||||||
n_copied++;
|
|
||||||
}
|
|
||||||
if (n_copied == 0)
|
|
||||||
return -EINVAL;
|
|
||||||
nc->body.type = SPA_CHOICE_Enum;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((p1c == SPA_CHOICE_None && p2c == SPA_CHOICE_Step) ||
|
if (p2c == SPA_CHOICE_Step) {
|
||||||
(p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Step)) {
|
int res = spa_pod_filter_is_step_of(type, a1, SPA_PTROFF(a2,size*2,void), size);
|
||||||
int n_copied = 0;
|
if (res == 0)
|
||||||
for (j = 0, a1 = alt1, a2 = alt2; j < nalt1; j++, a1 = SPA_PTROFF(a1,size,void)) {
|
continue;
|
||||||
int res;
|
if (res == -ENOTSUP)
|
||||||
if (spa_pod_compare_value(type, a1, a2, size) < 0)
|
return -EINVAL;
|
||||||
continue;
|
}
|
||||||
if (spa_pod_compare_value(type, a1, SPA_PTROFF(a2,size,void), size) > 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
res = spa_pod_filter_is_step_of(type, a1, SPA_PTROFF(a2,size*2,void), size);
|
|
||||||
if (res == 0)
|
|
||||||
continue;
|
|
||||||
if (res == -ENOTSUP)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
spa_pod_builder_raw(b, a1, size);
|
spa_pod_builder_raw(b, a1, size);
|
||||||
n_copied++;
|
n_copied++;
|
||||||
|
|
@ -241,14 +228,23 @@ spa_pod_filter_prop(struct spa_pod_builder *b,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((p1c == SPA_CHOICE_Range && p2c == SPA_CHOICE_None) ||
|
if ((p1c == SPA_CHOICE_Range && p2c == SPA_CHOICE_None) ||
|
||||||
(p1c == SPA_CHOICE_Range && p2c == SPA_CHOICE_Enum)) {
|
(p1c == SPA_CHOICE_Range && p2c == SPA_CHOICE_Enum) ||
|
||||||
|
(p1c == SPA_CHOICE_Step && p2c == SPA_CHOICE_None) ||
|
||||||
|
(p1c == SPA_CHOICE_Step && p2c == SPA_CHOICE_Enum)) {
|
||||||
int n_copied = 0;
|
int n_copied = 0;
|
||||||
/* copy all values inside the range */
|
/* copy all values inside the range */
|
||||||
for (k = 0, a1 = alt1, a2 = alt2; k < nalt2; k++, a2 = SPA_PTROFF(a2,size,void)) {
|
for (j = 0, a1 = alt1, a2 = alt2; j < nalt2; j++, a2 = SPA_PTROFF(a2,size,void)) {
|
||||||
if (spa_pod_compare_value(type, a2, a1, size) < 0)
|
if (spa_pod_compare_value(type, a2, a1, size) < 0)
|
||||||
continue;
|
continue;
|
||||||
if (spa_pod_compare_value(type, a2, SPA_PTROFF(a1,size,void), size) > 0)
|
if (spa_pod_compare_value(type, a2, SPA_PTROFF(a1,size,void), size) > 0)
|
||||||
continue;
|
continue;
|
||||||
|
if (p1c == SPA_CHOICE_Step) {
|
||||||
|
int res = spa_pod_filter_is_step_of(type, a2, SPA_PTROFF(a1,size*2,void), size);
|
||||||
|
if (res == 0)
|
||||||
|
continue;
|
||||||
|
if (res == -ENOTSUP)
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
spa_pod_builder_raw(b, a2, size);
|
spa_pod_builder_raw(b, a2, size);
|
||||||
n_copied++;
|
n_copied++;
|
||||||
}
|
}
|
||||||
|
|
@ -291,29 +287,6 @@ spa_pod_filter_prop(struct spa_pod_builder *b,
|
||||||
if (p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Flags)
|
if (p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Flags)
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
|
|
||||||
if ((p1c == SPA_CHOICE_Step && p2c == SPA_CHOICE_None) ||
|
|
||||||
(p1c == SPA_CHOICE_Step && p2c == SPA_CHOICE_Enum)) {
|
|
||||||
int n_copied = 0;
|
|
||||||
for (j = 0, a1 = alt1, a2 = alt2; j < nalt2; j++, a2 = SPA_PTROFF(a1,size,void)) {
|
|
||||||
int res;
|
|
||||||
if (spa_pod_compare_value(type, a2, a1, size) < 0)
|
|
||||||
continue;
|
|
||||||
if (spa_pod_compare_value(type, a2, SPA_PTROFF(a1,size,void), size) > 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
res = spa_pod_filter_is_step_of(type, a2, SPA_PTROFF(a1,size*2,void), size);
|
|
||||||
if (res == 0)
|
|
||||||
continue;
|
|
||||||
if (res == -ENOTSUP)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
spa_pod_builder_raw(b, a2, size);
|
|
||||||
n_copied++;
|
|
||||||
}
|
|
||||||
if (n_copied == 0)
|
|
||||||
return -EINVAL;
|
|
||||||
nc->body.type = SPA_CHOICE_Enum;
|
|
||||||
}
|
|
||||||
if (p1c == SPA_CHOICE_Step && p2c == SPA_CHOICE_Flags)
|
if (p1c == SPA_CHOICE_Step && p2c == SPA_CHOICE_Flags)
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue