[pulseaudio-discuss] [RFC PATCH] alsa-mixer: Cache failure to open inputs
David Henningsson
david.henningsson at canonical.com
Fri Sep 21 01:37:41 PDT 2012
We spend most of our startup time probing soundcards, so I was hoping this
would improve bootup speed, but it doesn't seem to do so here.
Do we want this anyway? At least it reduces the logs a little.
Signed-off-by: David Henningsson <david.henningsson at canonical.com>
---
src/modules/alsa/alsa-mixer.c | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index 8072fbb..1cf502d 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -3920,6 +3920,10 @@ static void profile_set_add_auto(pa_alsa_profile_set *ps) {
pa_assert(ps);
+ /* Try input only first, for caching */
+ 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 +3931,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) {
@@ -4293,6 +4295,7 @@ void pa_alsa_profile_set_probe(
void *state;
pa_alsa_profile *p, *last = NULL;
pa_alsa_mapping *m;
+ pa_hashmap *broken_inputs;
pa_assert(ps);
pa_assert(dev_id);
@@ -4301,6 +4304,8 @@ void pa_alsa_profile_set_probe(
if (ps->probed)
return;
+ broken_inputs = 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 +4316,16 @@ void pa_alsa_profile_set_probe(
profile_finalize_probing(last, p);
p->supported = TRUE;
+ if (p->input_mappings)
+ PA_IDXSET_FOREACH(m, p->input_mappings, idx)
+ if (pa_hashmap_get(broken_inputs, m) == m) {
+ pa_log_debug("Skipping - will not be able to open input:%s", 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)
@@ -4340,6 +4353,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 %s", m->name);
+ pa_hashmap_put(broken_inputs, m, m);
+ }
break;
}
}
@@ -4370,6 +4388,7 @@ void pa_alsa_profile_set_probe(
paths_drop_unsupported(ps->input_paths);
paths_drop_unsupported(ps->output_paths);
+ pa_hashmap_free(broken_inputs, NULL, NULL);
ps->probed = TRUE;
}
--
1.7.9.5
More information about the pulseaudio-discuss
mailing list