media-session: ignore empty channelMap/channelVolume

This commit is contained in:
Wim Taymans 2020-11-23 20:18:32 +01:00
parent 95e2ec9f72
commit b86acec625
2 changed files with 20 additions and 0 deletions

View file

@ -165,6 +165,8 @@ static char *serialize_props(struct device *dev, const struct spa_pod *param)
n_vals = spa_pod_copy_array(&prop->value, SPA_TYPE_Float,
vals, SPA_AUDIO_MAX_CHANNELS);
if (n_vals == 0)
continue;
fprintf(f, "%s\"volumes\": [", (comma ? ", " : ""));
for (i = 0; i < n_vals; i++)
@ -179,6 +181,8 @@ static char *serialize_props(struct device *dev, const struct spa_pod *param)
n_vals = spa_pod_copy_array(&prop->value, SPA_TYPE_Id,
map, SPA_AUDIO_MAX_CHANNELS);
if (n_vals == 0)
continue;
fprintf(f, "%s\"channels\": [", (comma ? ", " : ""));
for (i = 0; i < n_vals; i++)
@ -247,6 +251,9 @@ static int restore_route(struct device *dev, const char *val, uint32_t index, ui
if (spa_json_get_float(&it[2], &vols[n_vols]) <= 0)
break;
}
if (n_vols == 0)
continue;
spa_pod_builder_prop(&b, SPA_PROP_channelVolumes, 0);
spa_pod_builder_array(&b, sizeof(float), SPA_TYPE_Float,
n_vols, vols);
@ -264,6 +271,9 @@ static int restore_route(struct device *dev, const char *val, uint32_t index, ui
break;
map[n_ch] = channel_from_name(chname);
}
if (n_ch == 0)
continue;
spa_pod_builder_prop(&b, SPA_PROP_channelMap, 0);
spa_pod_builder_array(&b, sizeof(uint32_t), SPA_TYPE_Id,
n_ch, map);