I was hoping this would improve bootup speed, but it doesn't seem to do so here, at least not much. But at least it reduces the logs a little. Signed-off-by: David Henningsson <david.henningsson at canonical.com> --- src/modules/alsa/alsa-mixer.c | 43 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c index 8072fbb..b6ee1a4 100644 --- a/src/modules/alsa/alsa-mixer.c +++ b/src/modules/alsa/alsa-mixer.c @@ -3920,6 +3920,16 @@ static void profile_set_add_auto(pa_alsa_profile_set *ps) { pa_assert(ps); + /* The order is important here: + 1) try single inputs and outputs before trying their + combination, because if the half-duplex test failed, we don't have + to try full duplex. + 2) try the output right before the input combinations with + that output, because then the output_pcm is not closed between tests. + */ + PA_HASHMAP_FOREACH(n, ps->mappings, n_state) + profile_set_add_auto_pair(ps, NULL, n); + PA_HASHMAP_FOREACH(m, ps->mappings, m_state) { profile_set_add_auto_pair(ps, m, NULL); @@ -3927,8 +3937,6 @@ static void profile_set_add_auto(pa_alsa_profile_set *ps) { profile_set_add_auto_pair(ps, m, n); } - PA_HASHMAP_FOREACH(n, ps->mappings, n_state) - profile_set_add_auto_pair(ps, NULL, n); } static int profile_verify(pa_alsa_profile *p) { @@ -4290,9 +4298,10 @@ void pa_alsa_profile_set_probe( unsigned default_n_fragments, unsigned default_fragment_size_msec) { - void *state; + void *state, *state2; pa_alsa_profile *p, *last = NULL; pa_alsa_mapping *m; + pa_hashmap *broken_mappings; pa_assert(ps); pa_assert(dev_id); @@ -4301,6 +4310,8 @@ void pa_alsa_profile_set_probe( if (ps->probed) return; + broken_mappings = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func); + PA_HASHMAP_FOREACH(p, ps->profiles, state) { uint32_t idx; @@ -4311,8 +4322,21 @@ void pa_alsa_profile_set_probe( profile_finalize_probing(last, p); p->supported = TRUE; + PA_HASHMAP_FOREACH(m, broken_mappings, state2) { + const char* inout = NULL; + if (p->output_mappings && pa_idxset_get_by_data(p->output_mappings, m, NULL) == m) + inout = "output"; + else if (p->input_mappings && pa_idxset_get_by_data(p->input_mappings, m, NULL) == m) + inout = "input"; + if (inout) { + pa_log_debug("Skipping - will not be able to open %s:%s", inout, m->name); + p->supported = FALSE; + break; + } + } + /* Check if we can open all new ones */ - if (p->output_mappings) + if (p->supported && p->output_mappings) PA_IDXSET_FOREACH(m, p->output_mappings, idx) { if (m->output_pcm) @@ -4324,6 +4348,11 @@ void pa_alsa_profile_set_probe( 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_mappings, m, m); + } break; } } @@ -4340,6 +4369,11 @@ void pa_alsa_profile_set_probe( 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_mappings, m, m); + } break; } } @@ -4370,6 +4404,7 @@ void pa_alsa_profile_set_probe( paths_drop_unsupported(ps->input_paths); paths_drop_unsupported(ps->output_paths); + pa_hashmap_free(broken_mappings, NULL, NULL); ps->probed = TRUE; } -- 1.7.9.5