media-session: make sample-rate optional in policy-node

When deciding on the number of channels to use for the node,
ignore parsing the sample rate. This makes it possible to activate the
node with a missing rate property, like when the node can do all
possible rates.
This commit is contained in:
Wim Taymans 2021-04-22 13:04:05 +02:00
parent 3fd8f62e21
commit 0e8e1de17d

View file

@ -139,6 +139,8 @@ static bool find_format(struct node *node)
spa_list_for_each(p, &node->obj->param_list, link) {
struct spa_audio_info info = { 0, };
struct spa_pod *position = NULL;
uint32_t n_position = 0;
if (p->id != SPA_PARAM_EnumFormat)
continue;
@ -161,7 +163,18 @@ static bool find_format(struct node *node)
info.info.raw.position[0] = SPA_AUDIO_CHANNEL_FL;
info.info.raw.position[1] = SPA_AUDIO_CHANNEL_FR;
spa_format_audio_raw_parse(p->param, &info.info.raw);
spa_pod_parse_object(p->param,
SPA_TYPE_OBJECT_Format, NULL,
SPA_FORMAT_AUDIO_format, SPA_POD_Id(&info.info.raw.format),
SPA_FORMAT_AUDIO_rate, SPA_POD_OPT_Int(&info.info.raw.rate),
SPA_FORMAT_AUDIO_channels, SPA_POD_Int(&info.info.raw.channels),
SPA_FORMAT_AUDIO_position, SPA_POD_OPT_Pod(&position));
if (position != NULL)
n_position = spa_pod_copy_array(position, SPA_TYPE_Id,
info.info.raw.position, SPA_AUDIO_MAX_CHANNELS);
if (n_position == 0 || n_position != info.info.raw.channels)
SPA_FLAG_SET(info.info.raw.flags, SPA_AUDIO_FLAG_UNPOSITIONED);
if (node->format.info.raw.channels < info.info.raw.channels)
node->format = info;