mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
acp: fix > 2 channel maps
This commit is contained in:
parent
925cc9b487
commit
df912a9059
2 changed files with 29 additions and 13 deletions
|
|
@ -1768,7 +1768,7 @@ static bool element_probe_volume(pa_alsa_element *e, snd_mixer_elem_t *me) {
|
|||
if (is_mono) {
|
||||
e->n_channels = 1;
|
||||
|
||||
if (!e->override_map) {
|
||||
if (e->override_map & (1 << (e->n_channels-1))) {
|
||||
for (p = PA_CHANNEL_POSITION_FRONT_LEFT; p < PA_CHANNEL_POSITION_MAX; p++) {
|
||||
if (alsa_channel_ids[p] == SND_MIXER_SCHN_UNKNOWN)
|
||||
continue;
|
||||
|
|
@ -1805,14 +1805,14 @@ static bool element_probe_volume(pa_alsa_element *e, snd_mixer_elem_t *me) {
|
|||
* pa_channel_position_mask_t masks[SND_MIXER_SCHN_LAST + 1][8];
|
||||
*
|
||||
* Since the array size is fixed at 8, we obviously
|
||||
* don't support elements with more than two
|
||||
* don't support elements with more than eight
|
||||
* channels... */
|
||||
alsa_id_str(buf, sizeof(buf), &e->alsa_id);
|
||||
pa_log_warn("Volume element %s has %u channels. That's too much! I can't handle that!", buf, e->n_channels);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!e->override_map) {
|
||||
if (!(e->override_map & (1 << (e->n_channels-1)))) {
|
||||
for (p = PA_CHANNEL_POSITION_FRONT_LEFT; p < PA_CHANNEL_POSITION_MAX; p++) {
|
||||
bool has_channel;
|
||||
|
||||
|
|
@ -2495,6 +2495,7 @@ static int element_parse_override_map(pa_config_parser_state *state) {
|
|||
int idx;
|
||||
pa_atoi(s + 1, &idx);
|
||||
if (idx >= 1 && idx <= 8) {
|
||||
e->override_map |= (1 << i);
|
||||
e->masks[i++][idx-1] = m;
|
||||
} else {
|
||||
pa_log("[%s:%u] Override map index '%s' invalid in '%s'", state->filename, state->lineno, state->lvalue, state->section);
|
||||
|
|
@ -2506,8 +2507,6 @@ static int element_parse_override_map(pa_config_parser_state *state) {
|
|||
pa_xfree(n);
|
||||
}
|
||||
|
||||
e->override_map = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2812,6 +2811,12 @@ pa_alsa_path* pa_alsa_path_new(const char *paths_dir, const char *fname, pa_alsa
|
|||
{ "enumeration", element_parse_enumeration, NULL, NULL },
|
||||
{ "override-map.1", element_parse_override_map, NULL, NULL },
|
||||
{ "override-map.2", element_parse_override_map, NULL, NULL },
|
||||
{ "override-map.3", element_parse_override_map, NULL, NULL },
|
||||
{ "override-map.4", element_parse_override_map, NULL, NULL },
|
||||
{ "override-map.5", element_parse_override_map, NULL, NULL },
|
||||
{ "override-map.6", element_parse_override_map, NULL, NULL },
|
||||
{ "override-map.7", element_parse_override_map, NULL, NULL },
|
||||
{ "override-map.8", element_parse_override_map, NULL, NULL },
|
||||
/* ... later on we might add override-map.3 and so on here ... */
|
||||
{ "required", element_parse_required, NULL, NULL },
|
||||
{ "required-any", element_parse_required, NULL, NULL },
|
||||
|
|
@ -3029,6 +3034,7 @@ int pa_alsa_path_probe(pa_alsa_path *p, pa_alsa_mapping *mapping, snd_mixer_t *m
|
|||
double min_dB[PA_CHANNEL_POSITION_MAX], max_dB[PA_CHANNEL_POSITION_MAX];
|
||||
pa_channel_position_t t;
|
||||
pa_channel_position_mask_t path_volume_channels = 0;
|
||||
bool min_dB_set, max_dB_set;
|
||||
char buf[64];
|
||||
|
||||
pa_assert(p);
|
||||
|
|
@ -3059,7 +3065,7 @@ int pa_alsa_path_probe(pa_alsa_path *p, pa_alsa_mapping *mapping, snd_mixer_t *m
|
|||
pa_log_debug("Probe of element %s failed.", buf);
|
||||
return -1;
|
||||
}
|
||||
pa_log_debug("Probe of element %s succeeded (volume=%d, switch=%d, enumeration=%d).", buf, e->volume_use, e->switch_use, e->enumeration_use);
|
||||
pa_log_debug("Probe of element %s succeeded (volume=%d, switch=%d, enumeration=%d, has_dB=%d).", buf, e->volume_use, e->switch_use, e->enumeration_use, e->has_dB);
|
||||
|
||||
if (ignore_dB)
|
||||
e->has_dB = false;
|
||||
|
|
@ -3071,6 +3077,8 @@ int pa_alsa_path_probe(pa_alsa_path *p, pa_alsa_mapping *mapping, snd_mixer_t *m
|
|||
p->max_volume = e->max_volume;
|
||||
}
|
||||
|
||||
pa_log_debug("merge ok, has_volume = %d", p->has_volume);
|
||||
|
||||
if (e->has_dB) {
|
||||
if (!p->has_volume) {
|
||||
for (t = 0; t < PA_CHANNEL_POSITION_MAX; t++)
|
||||
|
|
@ -3123,20 +3131,28 @@ int pa_alsa_path_probe(pa_alsa_path *p, pa_alsa_mapping *mapping, snd_mixer_t *m
|
|||
p->supported = true;
|
||||
|
||||
p->min_dB = INFINITY;
|
||||
min_dB_set = false;
|
||||
p->max_dB = -INFINITY;
|
||||
max_dB_set = false;
|
||||
|
||||
for (t = 0; t < PA_CHANNEL_POSITION_MAX; t++) {
|
||||
if (path_volume_channels & PA_CHANNEL_POSITION_MASK(t)) {
|
||||
if (p->min_dB > min_dB[t])
|
||||
if (p->min_dB > min_dB[t]) {
|
||||
p->min_dB = min_dB[t];
|
||||
min_dB_set = true;
|
||||
}
|
||||
|
||||
if (p->max_dB < max_dB[t])
|
||||
if (p->max_dB < max_dB[t]) {
|
||||
p->max_dB = max_dB[t];
|
||||
max_dB_set = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (p->min_dB == INFINITY)
|
||||
|
||||
/* this is probably a wrong prediction, but it should be safe */
|
||||
if (!min_dB_set)
|
||||
p->min_dB = -INFINITY;
|
||||
if (p->max_dB == -INFINITY)
|
||||
if (!max_dB_set)
|
||||
p->max_dB = 0;
|
||||
|
||||
return 0;
|
||||
|
|
@ -3175,7 +3191,7 @@ void pa_alsa_element_dump(pa_alsa_element *e) {
|
|||
pa_assert(e);
|
||||
|
||||
alsa_id_str(buf, sizeof(buf), &e->alsa_id);
|
||||
pa_log_debug("Element %s, direction=%i, switch=%i, volume=%i, volume_limit=%li, enumeration=%i, required=%i, required_any=%i, required_absent=%i, mask=0x%llx, n_channels=%u, override_map=%s",
|
||||
pa_log_debug("Element %s, direction=%i, switch=%i, volume=%i, volume_limit=%li, enumeration=%i, required=%i, required_any=%i, required_absent=%i, mask=0x%llx, n_channels=%u, override_map=%02x",
|
||||
buf,
|
||||
e->direction,
|
||||
e->switch_use,
|
||||
|
|
@ -3187,7 +3203,7 @@ void pa_alsa_element_dump(pa_alsa_element *e) {
|
|||
e->required_absent,
|
||||
(long long unsigned) e->merged_mask,
|
||||
e->n_channels,
|
||||
pa_yes_no(e->override_map));
|
||||
e->override_map);
|
||||
|
||||
PA_LLIST_FOREACH(o, e->options)
|
||||
pa_alsa_option_dump(o);
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ struct pa_alsa_element {
|
|||
|
||||
long constant_volume;
|
||||
|
||||
bool override_map:1;
|
||||
unsigned int override_map;
|
||||
bool direction_try_other:1;
|
||||
|
||||
bool has_dB:1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue