[pulseaudio-discuss] [PATCH 5/8] card-restore: Save and restore "preferred profile" of port
Tanu Kaskinen
tanuk at iki.fi
Mon Oct 19 21:20:03 PDT 2015
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
More information about the pulseaudio-discuss
mailing list