Lines Matching refs:profile
39 /* We need to cache the active profile, because we want to compare the old
41 * have access to the new profile. */
65 static bool profile_good_for_output(pa_card_profile *profile, pa_device_port *port) {
70 pa_assert(profile);
72 card = profile->card;
77 if (!pa_safe_streq(card->active_profile->input_name, profile->input_name))
80 if (card->active_profile->n_sources != profile->n_sources)
83 if (card->active_profile->max_source_channels != profile->max_source_channels)
100 static bool profile_good_for_input(pa_card_profile *profile, pa_device_port *port) {
105 pa_assert(profile);
107 card = profile->card;
112 if (!pa_safe_streq(card->active_profile->output_name, profile->output_name))
115 if (card->active_profile->n_sinks != profile->n_sinks)
118 if (card->active_profile->max_sink_channels != profile->max_sink_channels)
136 pa_card_profile *best_profile = NULL, *profile;
141 pa_log_info("Keeping sticky card profile '%s'", port->card->active_profile->name);
145 pa_log_debug("Finding best profile for port %s, preferred = %s",
148 PA_HASHMAP_FOREACH(profile, port->profiles, state) {
151 unsigned prio = profile->priority;
156 name = profile->output_name;
157 good = profile_good_for_output(profile, port);
161 name = profile->input_name;
162 good = profile_good_for_input(profile, port);
169 /* Give a high bonus in case this is the preferred profile */
170 if (pa_safe_streq(name ? name : profile->name, port->preferred_profile))
176 best_profile = profile;
181 pa_log_debug("No suitable profile found");
186 pa_log_debug("Could not set profile %s", best_profile->name);
253 /* Now that profile has changed, our sink and source pointers must be updated */
289 * profile is still available in the
291 * the profile availability hasn't been updated yet. */
307 /* Our profile switching logic caused trouble with bluetooth headsets (see
309 * module-bluetooth-policy takes care of automatic profile switching
370 pa_card_profile *profile, *best_profile;
376 PA_HASHMAP_FOREACH(profile, card->profiles, state) {
377 if (profile->available == PA_AVAILABLE_NO)
380 if (profile->priority > best_profile->priority)
381 best_profile = profile;
387 static pa_hook_result_t card_profile_available_hook_callback(pa_core *c, pa_card_profile *profile, struct userdata *u) {
390 pa_assert(profile);
391 pa_assert_se(card = profile->card);
393 if (profile->available != PA_AVAILABLE_NO)
396 if (!pa_streq(profile->name, card->active_profile->name))
400 pa_log_info("Keeping sticky card profile '%s'", profile->name);
404 pa_log_debug("Active profile %s on card %s became unavailable, switching to another profile", profile->name, card->name);
485 /* If the profile change didn't affect input, it doesn't indicate change in
498 /* If the profile change modified the set of sinks, then it's unclear
501 * profile contains no sinks, though, then we know the user only cares
521 /* If the profile change didn't affect output, it doesn't indicate change in
534 /* If the profile change modified the set of sources, then it's unclear
537 * new profile contains no sources, though, then we know the user only
564 /* This profile change wasn't initiated by the user, so it doesn't signal