diff --git a/src/examples/media-session/default-routes.c b/src/examples/media-session/default-routes.c index 4900d474a..2716dab4f 100644 --- a/src/examples/media-session/default-routes.c +++ b/src/examples/media-session/default-routes.c @@ -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); diff --git a/src/examples/media-session/restore-stream.c b/src/examples/media-session/restore-stream.c index 5590e1196..11c2986d5 100644 --- a/src/examples/media-session/restore-stream.c +++ b/src/examples/media-session/restore-stream.c @@ -172,6 +172,8 @@ static char *serialize_props(struct stream *str, 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++) @@ -186,6 +188,8 @@ static char *serialize_props(struct stream *str, const struct spa_pod *param) n_ch = spa_pod_copy_array(&prop->value, SPA_TYPE_Id, map, SPA_AUDIO_MAX_CHANNELS); + if (n_ch == 0) + continue; fprintf(f, "%s\"channels\": [", (comma ? ", " : "")); for (i = 0; i < n_ch; i++) @@ -310,6 +314,9 @@ static int restore_stream(struct stream *str, const char *val) 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); @@ -327,6 +334,9 @@ static int restore_stream(struct stream *str, const char *val) 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);