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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
| void pa_alsa_profile_set_probe( pa_alsa_profile_set *ps, const char *dev_id, const pa_sample_spec *ss, unsigned default_n_fragments, unsigned default_fragment_size_msec) {
bool found_output = false, found_input = false;
pa_alsa_profile *p, *last = NULL; pa_alsa_profile **pp, **probe_order; pa_alsa_mapping *m; pa_hashmap *broken_inputs, *broken_outputs, *used_paths; pa_alsa_mapping *selected_fallback_input = NULL, *selected_fallback_output = NULL;
pa_assert(ps); pa_assert(dev_id); pa_assert(ss);
broken_inputs = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func); broken_outputs = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func); used_paths = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
pp = probe_order = pa_xnew0(pa_alsa_profile *, pa_hashmap_size(ps->profiles) + 1);
pp += add_profiles_to_probe(pp, ps->profiles, false, false); pp += add_profiles_to_probe(pp, ps->profiles, false, true); pp += add_profiles_to_probe(pp, ps->profiles, true, false); pp += add_profiles_to_probe(pp, ps->profiles, true, true);
for (pp = probe_order; *pp; pp++) { uint32_t idx; p = *pp;
if (found_input && p->fallback_input) if (selected_fallback_input == NULL || pa_idxset_get_by_index(p->input_mappings, 0) != selected_fallback_input) continue; if (found_output && p->fallback_output) if (selected_fallback_output == NULL || pa_idxset_get_by_index(p->output_mappings, 0) != selected_fallback_output) continue;
if (!p->supported) { profile_finalize_probing(last, p); p->supported = true;
if (p->output_mappings) { PA_IDXSET_FOREACH(m, p->output_mappings, idx) { if (pa_hashmap_get(broken_outputs, m) == m) { pa_log_debug("Skipping profile %s - will not be able to open output:%s", p->name, m->name); p->supported = false; break; } } }
if (p->input_mappings && p->supported) { PA_IDXSET_FOREACH(m, p->input_mappings, idx) { if (pa_hashmap_get(broken_inputs, m) == m) { pa_log_debug("Skipping profile %s - will not be able to open input:%s", p->name, m->name); p->supported = false; break; } } }
if (p->supported) pa_log_debug("Looking at profile %s", p->name);
if (p->output_mappings && p->supported) PA_IDXSET_FOREACH(m, p->output_mappings, idx) { if (m->output_pcm) continue;
pa_log_debug("Checking for playback on %s (%s)", m->description, m->name); if (!(m->output_pcm = mapping_open_pcm(m, ss, dev_id, m->exact_channels, SND_PCM_STREAM_PLAYBACK, default_n_fragments, default_fragment_size_msec))) { p->supported = false; if (pa_idxset_size(p->output_mappings) == 1 && ((!p->input_mappings) || pa_idxset_size(p->input_mappings) == 0)) { pa_log_debug("Caching failure to open output:%s", m->name); pa_hashmap_put(broken_outputs, m, m); } break; }
if (m->hw_device_index < 0) mapping_query_hw_device(m, m->output_pcm); }
if (p->input_mappings && p->supported) PA_IDXSET_FOREACH(m, p->input_mappings, idx) { if (m->input_pcm) continue;
pa_log_debug("Checking for recording on %s (%s)", m->description, m->name); if (!(m->input_pcm = mapping_open_pcm(m, ss, dev_id, m->exact_channels, SND_PCM_STREAM_CAPTURE, default_n_fragments, default_fragment_size_msec))) { p->supported = false; if (pa_idxset_size(p->input_mappings) == 1 && ((!p->output_mappings) || pa_idxset_size(p->output_mappings) == 0)) { pa_log_debug("Caching failure to open input:%s", m->name); pa_hashmap_put(broken_inputs, m, m); } break; }
if (m->hw_device_index < 0) mapping_query_hw_device(m, m->input_pcm); }
last = p;
if (!p->supported) continue; }
pa_log_debug("Profile %s supported.", p->name);
if (p->output_mappings) PA_IDXSET_FOREACH(m, p->output_mappings, idx) if (m->output_pcm) { found_output = true; if (p->fallback_output && selected_fallback_output == NULL) { selected_fallback_output = m; } mapping_paths_probe(m, p, PA_ALSA_DIRECTION_OUTPUT, used_paths); }
if (p->input_mappings) PA_IDXSET_FOREACH(m, p->input_mappings, idx) if (m->input_pcm) { found_input = true; if (p->fallback_input && selected_fallback_input == NULL) { selected_fallback_input = m; } mapping_paths_probe(m, p, PA_ALSA_DIRECTION_INPUT, used_paths); } }
profile_finalize_probing(last, NULL);
pa_alsa_profile_set_drop_unsupported(ps);
paths_drop_unused(ps->input_paths, used_paths); paths_drop_unused(ps->output_paths, used_paths);
pa_hashmap_free(broken_inputs); pa_hashmap_free(broken_outputs); pa_hashmap_free(used_paths); pa_xfree(probe_order);
ps->probed = true; }
|