spa: audioadapter: check if follower supports enum params before requesting them

Some follower nodes don't support all audioadapter params (For example, param
SPA_PARAM_Props is not supported by 'support.null-sink'). This change adds a
check to avoid unsuported errors when requesting a param that is not supported
by the follower.
This commit is contained in:
Julian Bouzas 2021-11-29 14:21:11 -05:00 committed by Wim Taymans
parent 84e210ded9
commit 921a9038e1

View file

@ -108,6 +108,30 @@ struct impl {
/** \endcond */ /** \endcond */
static void follower_enum_params(struct impl *this,
uint32_t id,
uint32_t idx,
struct spa_result_node_params *result,
const struct spa_pod *filter,
struct spa_pod_builder *builder,
int *res)
{
if (result->next < 0x10000) {
if ((*res = spa_node_enum_params_sync(this->convert,
id, &result->next, filter, &result->param, builder)) == 1)
return;
result->next = 0x10000;
}
if (result->next >= 0x10000 && this->follower_params_flags[idx] & SPA_PARAM_INFO_READ) {
result->next &= 0xffff;
if ((*res = spa_node_enum_params_sync(this->follower,
id, &result->next, filter, &result->param, builder)) == 1) {
result->next |= 0x10000;
return;
}
}
}
static int impl_node_enum_params(void *object, int seq, static int impl_node_enum_params(void *object, int seq,
uint32_t id, uint32_t start, uint32_t num, uint32_t id, uint32_t start, uint32_t num,
const struct spa_pod *filter) const struct spa_pod *filter)
@ -137,25 +161,20 @@ next:
res = spa_node_enum_params(this->convert, seq, id, start, num, filter); res = spa_node_enum_params(this->convert, seq, id, start, num, filter);
return res; return res;
case SPA_PARAM_PropInfo: case SPA_PARAM_PropInfo:
case SPA_PARAM_Props: follower_enum_params(this, id, IDX_PropInfo, &result, filter, &b, &res);
case SPA_PARAM_ProcessLatency: if (res == 1)
{ break;
if (result.next < 0x10000) { return res;
if ((res = spa_node_enum_params_sync(this->convert, case SPA_PARAM_Props:
id, &result.next, filter, &result.param, &b)) == 1) follower_enum_params(this, id, IDX_Props, &result, filter, &b, &res);
break; if (res == 1)
result.next = 0x10000; break;
} return res;
if (result.next >= 0x10000) { case SPA_PARAM_ProcessLatency:
result.next &= 0xffff; follower_enum_params(this, id, IDX_ProcessLatency, &result, filter, &b, &res);
if ((res = spa_node_enum_params_sync(this->follower, if (res == 1)
id, &result.next, filter, &result.param, &b)) == 1) { break;
result.next |= 0x10000;
break;
}
}
return res; return res;
}
case SPA_PARAM_EnumFormat: case SPA_PARAM_EnumFormat:
case SPA_PARAM_Format: case SPA_PARAM_Format:
case SPA_PARAM_Latency: case SPA_PARAM_Latency: