Lines Matching refs:card
42 #include <pulsecore/card.h>
148 static struct entry *entry_from_card(pa_card *card) {
154 pa_assert(card);
157 entry->profile_is_sticky = card->profile_is_sticky;
158 if (card->save_profile || entry->profile_is_sticky)
159 entry->profile = pa_xstrdup(card->active_profile->name);
161 if (card->preferred_input_port)
162 entry->preferred_input_port = pa_xstrdup(card->preferred_input_port->name);
163 if (card->preferred_output_port)
164 entry->preferred_output_port = pa_xstrdup(card->preferred_output_port->name);
166 PA_HASHMAP_FOREACH(port, card->ports, state) {
398 static void show_full_info(pa_card *card) {
399 pa_assert(card);
401 if (card->save_profile)
402 pa_log_info("Storing profile and port latency offsets for card %s.", card->name);
404 pa_log_info("Storing port latency offsets for card %s.", card->name);
407 static pa_hook_result_t card_put_hook_callback(pa_core *c, pa_card *card, struct userdata *u) {
410 pa_assert(card);
412 entry = entry_from_card(card);
414 if ((old = entry_read(u, card->name))) {
415 if (!card->save_profile)
421 show_full_info(card);
423 if (entry_write(u, card->name, entry))
434 static void update_profile_for_port(struct entry *entry, pa_card *card, pa_device_port *p) {
448 pa_log_info("Storing profile %s for port %s on card %s.", p_info->profile, p->name, card->name);
452 static pa_hook_result_t card_profile_changed_callback(pa_core *c, pa_card *card, struct userdata *u) {
458 pa_assert(card);
460 if (!card->save_profile && !card->profile_is_sticky)
463 if ((entry = entry_read(u, card->name))) {
465 entry->profile_is_sticky = card->profile_is_sticky;
466 entry->profile = pa_xstrdup(card->active_profile->name);
467 pa_log_info("Storing card profile for card %s.", card->name);
469 entry = entry_from_card(card);
470 show_full_info(card);
473 PA_IDXSET_FOREACH(sink, card->sinks, state)
474 update_profile_for_port(entry, card, sink->active_port);
475 PA_IDXSET_FOREACH(source, card->sources, state)
476 update_profile_for_port(entry, card, source->active_port);
478 if (entry_write(u, card->name, entry))
493 if (!(entry = entry_read(u, profile->card->name)))
497 if (pa_card_set_profile(profile->card, profile, true) >= 0)
498 pa_log_info("Restored profile '%s' for card %s.", profile->name, profile->card->name);
508 pa_card *card;
511 card = port->card;
513 if ((entry = entry_read(u, card->name))) {
523 pa_log_info("Storing latency offset for port %s on card %s.", port->name, card->name);
526 entry = entry_from_card(card);
527 show_full_info(card);
530 if (entry_write(u, card->name, entry))
551 pa_log_info("Restoring port latency offsets for card %s.", new_data->name);
577 static pa_hook_result_t card_choose_initial_profile_callback(pa_core *core, pa_card *card, struct userdata *u) {
580 if (!(e = entry_read(u, card->name)))
584 const char *s = pa_proplist_gets(card->proplist, PA_PROP_DEVICE_BUS);
589 card->profile_is_sticky = e->profile_is_sticky;
590 pa_log_info("Profile '%s' was previously %s for card %s.",
592 card->profile_is_sticky ? "sticky" : "automatically selected",
593 card->name);
598 profile = pa_hashmap_get(card->profiles, e->profile);
600 if (profile->available != PA_AVAILABLE_NO || card->profile_is_sticky) {
601 pa_log_info("Restoring profile '%s' for card %s.", profile->name, card->name);
602 pa_card_set_profile(card, profile, true);
604 pa_log_debug("Not restoring profile %s for card %s, because the profile is currently unavailable.",
605 profile->name, card->name);
607 pa_log_debug("Tried to restore profile %s for card %s, but the card doesn't have such profile.",
608 e->profile, card->name);
621 pa_card *card;
623 card = data->card;
625 e = entry_read(u, card->name);
627 e = entry_from_card(card);
631 e->preferred_input_port = pa_xstrdup(card->preferred_input_port ? card->preferred_input_port->name : NULL);
634 e->preferred_output_port = pa_xstrdup(card->preferred_output_port ? card->preferred_output_port->name : NULL);
637 if (entry_write(u, card->name, e))
681 if (!(u->database = pa_database_open(state_path, "card-database", true, true))) {