summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Henningsson <david.henningsson@canonical.com>2015-11-17 15:10:32 +0100
committerTanu Kaskinen <tanuk@iki.fi>2015-11-22 04:59:25 +0200
commit5c545ba38be33bfc5334a70edacba24f06271af5 (patch)
treea9c1bd0287bef20599b48a1b03a8b99a7b8e34a5
parentb1d9b4f62c2f132292efaba862e8490114882ad2 (diff)
downloadpulseaudio-5c545ba38be33bfc5334a70edacba24f06271af5.tar.gz
card: Update preferred_profile for ports when profile changes
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
-rw-r--r--src/pulsecore/card.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c
index bb21d0f14..0ca78bb7f 100644
--- a/src/pulsecore/card.c
+++ b/src/pulsecore/card.c
@@ -250,8 +250,19 @@ void pa_card_add_profile(pa_card *c, pa_card_profile *profile) {
pa_hook_fire(&c->core->hooks[PA_CORE_HOOK_CARD_PROFILE_ADDED], profile);
}
+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;
+}
+
int pa_card_set_profile(pa_card *c, pa_card_profile *profile, bool save) {
int r;
+ pa_sink *sink;
+ pa_source *source;
+ uint32_t state;
pa_assert(c);
pa_assert(profile);
@@ -277,6 +288,13 @@ int pa_card_set_profile(pa_card *c, pa_card_profile *profile, bool save) {
c->active_profile = profile;
c->save_profile = save;
+ PA_IDXSET_FOREACH(sink, c->sinks, state)
+ if (sink->active_port)
+ pa_device_port_set_preferred_profile(sink->active_port, profile_name_for_dir(profile, PA_DIRECTION_OUTPUT));
+ PA_IDXSET_FOREACH(source, c->sources, state)
+ if (source->active_port)
+ pa_device_port_set_preferred_profile(source->active_port, profile_name_for_dir(profile, PA_DIRECTION_INPUT));
+
pa_hook_fire(&c->core->hooks[PA_CORE_HOOK_CARD_PROFILE_CHANGED], c);
return 0;