Lines Matching refs:card
37 pa_card *card;
49 static void card_info_new(struct userdata *u, pa_card *card) {
54 info->card = card;
55 info->active_profile = card->active_profile;
57 pa_hashmap_put(u->card_infos, card, info);
61 pa_hashmap_remove(info->userdata->card_infos, info->card);
66 pa_card *card;
72 card = profile->card;
74 if (pa_safe_streq(card->active_profile->name, "off"))
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)
86 if (port == card->preferred_output_port)
89 PA_IDXSET_FOREACH(sink, card->sinks, idx) {
101 pa_card *card;
107 card = profile->card;
109 if (pa_safe_streq(card->active_profile->name, "off"))
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)
121 if (port == card->preferred_input_port)
124 PA_IDXSET_FOREACH(source, card->sources, idx) {
140 if (port->card->profile_is_sticky) {
141 pa_log_info("Keeping sticky card profile '%s'", port->card->active_profile->name);
185 if (pa_card_set_profile(port->card, best_profile, false) != 0) {
213 pa_card *card;
216 pa_assert_se(card = port->card);
220 PA_IDXSET_FOREACH(pp.sink, card->sinks, state)
226 PA_IDXSET_FOREACH(pp.source, card->sources, state)
233 card->active_profile == pa_hashmap_get(port->profiles, card->active_profile->name);
235 pa_safe_streq(port->preferred_profile, profile_name_for_dir(card->active_profile, port->direction)));
272 PA_HASHMAP_FOREACH(p, port->card->ports, state) {
302 if (!port->card) {
303 pa_log_warn("Port %s does not have a card", port->name);
312 if (pa_safe_streq(pa_proplist_gets(port->card->proplist, PA_PROP_DEVICE_BUS), "bluetooth"))
369 static pa_card_profile *find_best_profile(pa_card *card) {
373 pa_assert(card);
374 best_profile = pa_hashmap_get(card->profiles, "off");
376 PA_HASHMAP_FOREACH(profile, card->profiles, state) {
388 pa_card *card;
391 pa_assert_se(card = profile->card);
396 if (!pa_streq(profile->name, card->active_profile->name))
399 if (card->profile_is_sticky) {
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);
405 pa_card_set_profile(card, find_best_profile(card), false);
412 pa_card *card;
415 PA_IDXSET_FOREACH(card, core->cards, state) {
419 PA_HASHMAP_FOREACH(port, card->ports, state2) {
470 static pa_hook_result_t card_put_hook_callback(pa_core *core, pa_card *card, struct userdata *u) {
471 card_info_new(u, card);
476 static pa_hook_result_t card_unlink_hook_callback(pa_core *core, pa_card *card, struct userdata *u) {
477 card_info_free(pa_hashmap_get(u->card_infos, card));
482 static void update_preferred_input_port(pa_card *card, pa_card_profile *old_profile, pa_card_profile *new_profile) {
493 if (pa_idxset_size(card->sources) != 1) {
494 pa_card_set_preferred_port(card, PA_DIRECTION_INPUT, NULL);
503 if (pa_idxset_size(card->sinks) > 0 && !pa_safe_streq(old_profile->output_name, new_profile->output_name)) {
504 pa_card_set_preferred_port(card, PA_DIRECTION_INPUT, NULL);
508 source = pa_idxset_first(card->sources, NULL);
515 pa_card_set_preferred_port(card, PA_DIRECTION_INPUT, source->active_port);
518 static void update_preferred_output_port(pa_card *card, pa_card_profile *old_profile, pa_card_profile *new_profile) {
529 if (pa_idxset_size(card->sinks) != 1) {
530 pa_card_set_preferred_port(card, PA_DIRECTION_OUTPUT, NULL);
539 if (pa_idxset_size(card->sources) > 0 && !pa_safe_streq(old_profile->input_name, new_profile->input_name)) {
540 pa_card_set_preferred_port(card, PA_DIRECTION_OUTPUT, NULL);
544 sink = pa_idxset_first(card->sinks, NULL);
551 pa_card_set_preferred_port(card, PA_DIRECTION_OUTPUT, sink->active_port);
554 static pa_hook_result_t card_profile_changed_callback(pa_core *core, pa_card *card, struct userdata *u) {
559 info = pa_hashmap_get(u->card_infos, card);
561 new_profile = card->active_profile;
566 if (!card->save_profile)
569 update_preferred_input_port(card, old_profile, new_profile);
570 update_preferred_output_port(card, old_profile, new_profile);
579 pa_card_set_preferred_port(source->card, PA_DIRECTION_INPUT, source->active_port);
588 pa_card_set_preferred_port(sink->card, PA_DIRECTION_OUTPUT, sink->active_port);
595 pa_card *card;
603 PA_IDXSET_FOREACH(card, m->core->cards, idx)
604 card_info_new(u, card);