1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
| int pa_alsa_path_probe(pa_alsa_path *p, pa_alsa_mapping *mapping, snd_mixer_t *m, bool ignore_dB) { pa_alsa_element *e; pa_alsa_jack *j; 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;
pa_assert(p); pa_assert(m);
if (p->probed) return p->supported ? 0 : -1; p->probed = true;
pa_zero(min_dB); pa_zero(max_dB);
pa_log_debug("Probing path '%s'", p->name);
PA_LLIST_FOREACH(j, p->jacks) { if (jack_probe(j, mapping, m) < 0) { p->supported = false; pa_log_debug("Probe of jack '%s' failed.", j->alsa_name); return -1; } pa_log_debug("Probe of jack '%s' succeeded (%s)", j->alsa_name, j->has_control ? "found!" : "not found"); }
PA_LLIST_FOREACH(e, p->elements) { if (element_probe(e, m) < 0) { p->supported = false; pa_log_debug("Probe of element '%s' failed.", e->alsa_name); return -1; } pa_log_debug("Probe of element '%s' succeeded (volume=%d, switch=%d, enumeration=%d).", e->alsa_name, e->volume_use, e->switch_use, e->enumeration_use);
if (ignore_dB) e->has_dB = false;
if (e->volume_use == PA_ALSA_VOLUME_MERGE) {
if (!p->has_volume) { p->min_volume = e->min_volume; p->max_volume = e->max_volume; }
if (e->has_dB) {
if (!p->has_volume) { for (t = 0; t < PA_CHANNEL_POSITION_MAX; t++) if (PA_CHANNEL_POSITION_MASK(t) & e->merged_mask) { min_dB[t] = e->min_dB; max_dB[t] = e->max_dB; path_volume_channels |= PA_CHANNEL_POSITION_MASK(t); }
p->has_dB = true; } else { if (p->has_dB) { for (t = 0; t < PA_CHANNEL_POSITION_MAX; t++) if (PA_CHANNEL_POSITION_MASK(t) & e->merged_mask) { min_dB[t] += e->min_dB; max_dB[t] += e->max_dB; path_volume_channels |= PA_CHANNEL_POSITION_MASK(t); } } else { e->volume_use = PA_ALSA_VOLUME_ZERO; pa_log_info("Zeroing volume of '%s' on path '%s'", e->alsa_name, p->name); } } } else if (p->has_volume) { e->volume_use = PA_ALSA_VOLUME_IGNORE; pa_log_info("Ignoring volume of '%s' on path '%s' (missing dB info)", e->alsa_name, p->name); } p->has_volume = true; }
if (e->switch_use == PA_ALSA_SWITCH_MUTE) p->has_mute = true; }
if (p->has_req_any && !p->req_any_present) { p->supported = false; pa_log_debug("Skipping path '%s', none of required-any elements preset.", p->name); return -1; }
path_drop_unsupported(p); path_make_options_unique(p);
p->supported = true;
p->min_dB = INFINITY; p->max_dB = -INFINITY;
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]) p->min_dB = min_dB[t];
if (p->max_dB < max_dB[t]) p->max_dB = max_dB[t]; } }
return 0; }
|