alsa: rework the channel params

Avoid adding a None choice, just add one single value without a choice
when the min == max. In that case we can also add a channel position.
This commit is contained in:
Wim Taymans 2025-05-08 18:17:45 +02:00
parent 2d8080cbde
commit f068e4ba85

View file

@ -1617,23 +1617,18 @@ skip_channels:
snd_pcm_free_chmaps(maps); snd_pcm_free_chmaps(maps);
} }
else { else {
const struct channel_map *map = NULL;
struct spa_pod_choice *choice;
if (index > 0) if (index > 0)
return 0; return 0;
spa_pod_builder_push_choice(b, &f[0], SPA_CHOICE_None, 0);
choice = (struct spa_pod_choice*)spa_pod_builder_frame(b, &f[0]);
spa_pod_builder_int(b, max);
if (min != max) { if (min != max) {
spa_pod_builder_push_choice(b, &f[0], SPA_CHOICE_Range, 0);
spa_pod_builder_int(b, max);
spa_pod_builder_int(b, min); spa_pod_builder_int(b, min);
spa_pod_builder_int(b, max); spa_pod_builder_int(b, max);
choice->body.type = SPA_CHOICE_Range;
}
spa_pod_builder_pop(b, &f[0]); spa_pod_builder_pop(b, &f[0]);
} else {
if (min == max) { const struct channel_map *map = NULL;
spa_pod_builder_int(b, min);
if (state->default_pos.channels == min) { if (state->default_pos.channels == min) {
map = &state->default_pos; map = &state->default_pos;
spa_log_debug(state->log, "%p: using provided default", state); spa_log_debug(state->log, "%p: using provided default", state);
@ -1641,7 +1636,6 @@ skip_channels:
map = &default_map[min]; map = &default_map[min];
spa_log_debug(state->log, "%p: using default %d channel map", state, min); spa_log_debug(state->log, "%p: using default %d channel map", state, min);
} }
}
if (map) { if (map) {
spa_pod_builder_prop(b, SPA_FORMAT_AUDIO_position, 0); spa_pod_builder_prop(b, SPA_FORMAT_AUDIO_position, 0);
spa_pod_builder_push_array(b, &f[0]); spa_pod_builder_push_array(b, &f[0]);
@ -1652,6 +1646,7 @@ skip_channels:
spa_pod_builder_pop(b, &f[0]); spa_pod_builder_pop(b, &f[0]);
} }
} }
}
return 1; return 1;
} }