On Tue, 2015-05-05 at 17:01 +0200, David Henningsson wrote: > diff --git a/src/modules/module-card-restore.c b/src/modules/module-card-restore.c > index 5c55cec..5d278c1 100644 > --- a/src/modules/module-card-restore.c > +++ b/src/modules/module-card-restore.c > @@ -375,8 +385,44 @@ finish: > Â Â Â Â Â return PA_HOOK_OK; > Â } > Â > +static const char* profile_name_for_dir(pa_card_profile *cp, pa_direction_t dir) { > +Â Â Â Â if (dir == PA_DIRECTION_OUTPUT && cp->output_name) > +Â Â Â Â Â Â Â Â return cp->output_name; > +Â Â Â Â if (dir == PA_DIRECTION_INPUT && cp->input_name) > +Â Â Â Â Â Â Â Â return cp->input_name; > +Â Â Â Â return cp->name; > +} > + > +static void update_profile_for_port(struct entry *entry, pa_card *card, pa_device_port *p) { > +Â Â Â Â struct port_info *p_info; > +Â Â Â Â const char *profilename; > + > +Â Â Â Â if (p == NULL) > +Â Â Â Â Â Â Â Â return; > + > +Â Â Â Â if (!(p_info = pa_hashmap_get(entry->ports, p->name))) { > +Â Â Â Â Â Â Â Â p_info = port_info_new(p); > +Â Â Â Â Â Â Â Â pa_assert_se(pa_hashmap_put(entry->ports, p_info->name, p_info) >= 0); > +Â Â Â Â } > + > +Â Â Â Â profilename = profile_name_for_dir(card->active_profile, p->direction); > +Â Â Â Â if (pa_safe_streq(p_info->profile, profilename)) > +Â Â Â Â Â Â Â Â return; > + > +Â Â Â Â pa_xfree(p->preferred_profile); > +Â Â Â Â p->preferred_profile = pa_xstrdup(profilename); I don't think updating the preferred sink or source belongs in module- card-restore. module-card-restore should only concern itself with updating the database, and restoring things when new cards appear. pa_card_set_profile() seems like a better place to me to set pa_device_port.preferred_device (my previous suggestion to name the field "preferred_sink" was obviously bad, since we need to cover sources too). I'd also use add a function to the pa_device_port API to set the preferred device name, to keep writes to the struct encapsulated within device-port.c. --Â Tanu