[pulseaudio-commits] 2 commits - src/modules
David Henningsson
diwic at kemper.freedesktop.org
Fri Dec 19 02:52:17 PST 2014
src/modules/bluetooth/module-bluez5-device.c | 4 ++-
src/modules/module-card-restore.c | 34 +++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 1 deletion(-)
New commits:
commit 1d3fd4f8627942b931ab6db4137186a567fe6939
Author: Tanu Kaskinen <tanu.kaskinen at linux.intel.com>
Date: Tue Dec 16 13:14:41 2014 +0200
card-restore: Fix profile restoring with bluetooth
The bluetooth card is created when the first profile becomes
available, which means that the card may have profiles that are not
available when the card is initialized. If module-card-restore tries
to restore such profile, that will fail, and the card will be
initialized with the "off" profile active.
This patch modifies module-card-restore so that if follows the profile
availability status, and when the saved profile becomes available, it
is activated. Additionally, module-card-restore is modified so that it
doesn't even try to restore unavailable profiles, when the necessary
information is available. In practice there are two existing places
where the profile is restored, and only one of those contexts has the
necessary information available. Unfortunately, it's the more
important context (card creation) where the information is not
available. This means that module-card-restore will set the initial
profile of a new card even if the profile is unavailable, and this
will cause an ugly warning in the log, even though there's nothing
abnormal happening.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=87081
diff --git a/src/modules/module-card-restore.c b/src/modules/module-card-restore.c
index 681acca..beb748e 100644
--- a/src/modules/module-card-restore.c
+++ b/src/modules/module-card-restore.c
@@ -66,6 +66,7 @@ struct userdata {
pa_hook_slot *card_put_hook_slot;
pa_hook_slot *card_profile_changed_hook_slot;
pa_hook_slot *card_profile_added_hook_slot;
+ pa_hook_slot *profile_available_changed_hook_slot;
pa_hook_slot *port_offset_hook_slot;
pa_time_event *save_time_event;
pa_database *database;
@@ -412,6 +413,9 @@ static pa_hook_result_t card_profile_added_callback(pa_core *c, pa_card_profile
pa_assert(profile);
+ if (profile->available == PA_AVAILABLE_NO)
+ return PA_HOOK_OK;
+
if (!(entry = entry_read(u, profile->card->name)))
return PA_HOOK_OK;
@@ -425,6 +429,33 @@ static pa_hook_result_t card_profile_added_callback(pa_core *c, pa_card_profile
return PA_HOOK_OK;
}
+static pa_hook_result_t profile_available_changed_callback(void *hook_data, void *call_data, void *userdata) {
+ pa_card_profile *profile = call_data;
+ pa_card *card;
+ struct userdata *u = userdata;
+ struct entry *entry;
+
+ pa_assert(profile);
+ pa_assert(u);
+
+ card = profile->card;
+
+ if (profile->available == PA_AVAILABLE_NO)
+ return PA_HOOK_OK;
+
+ entry = entry_read(u, card->name);
+ if (!entry)
+ return PA_HOOK_OK;
+
+ if (!pa_streq(profile->name, entry->profile))
+ return PA_HOOK_OK;
+
+ pa_log_info("Card %s profile %s became available, activating.", card->name, profile->name);
+ pa_card_set_profile(profile->card, profile, true);
+
+ return PA_HOOK_OK;
+}
+
static pa_hook_result_t port_offset_change_callback(pa_core *c, pa_device_port *port, struct userdata *u) {
struct entry *entry;
pa_card *card;
@@ -511,6 +542,8 @@ int pa__init(pa_module*m) {
u->card_put_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_CARD_PUT], PA_HOOK_NORMAL, (pa_hook_cb_t) card_put_hook_callback, u);
u->card_profile_changed_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_CARD_PROFILE_CHANGED], PA_HOOK_NORMAL, (pa_hook_cb_t) card_profile_changed_callback, u);
u->card_profile_added_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_CARD_PROFILE_ADDED], PA_HOOK_NORMAL, (pa_hook_cb_t) card_profile_added_callback, u);
+ u->profile_available_changed_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_CARD_PROFILE_AVAILABLE_CHANGED],
+ PA_HOOK_NORMAL, profile_available_changed_callback, u);
u->port_offset_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_PORT_LATENCY_OFFSET_CHANGED], PA_HOOK_NORMAL, (pa_hook_cb_t) port_offset_change_callback, u);
u->hooks_connected = true;
@@ -551,6 +584,7 @@ void pa__done(pa_module*m) {
pa_hook_slot_free(u->card_put_hook_slot);
pa_hook_slot_free(u->card_profile_changed_hook_slot);
pa_hook_slot_free(u->card_profile_added_hook_slot);
+ pa_hook_slot_free(u->profile_available_changed_hook_slot);
pa_hook_slot_free(u->port_offset_hook_slot);
}
commit de1e78a47cd13496c38f627d56944045a629053e
Author: David Henningsson <david.henningsson at canonical.com>
Date: Fri Dec 19 10:24:47 2014 +0100
bluez5: Do not suspend on no -> unknown profile transitions
In case a transport is currently disconnected and transitions to
idle, that should not count as a "remote hang up" event.
Signed-off-by: David Henningsson <david.henningsson at canonical.com>
diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c
index e6a8071..995e550 100644
--- a/src/modules/bluetooth/module-bluez5-device.c
+++ b/src/modules/bluetooth/module-bluez5-device.c
@@ -1968,11 +1968,13 @@ static void handle_transport_state_change(struct userdata *u, struct pa_bluetoot
bool release = false;
pa_card_profile *cp;
pa_device_port *port;
+ pa_available_t oldavail;
pa_assert(u);
pa_assert(t);
pa_assert_se(cp = pa_hashmap_get(u->card->profiles, pa_bluetooth_profile_to_string(t->profile)));
+ oldavail = cp->available;
pa_card_profile_set_available(cp, transport_state_to_availability(t->state));
/* Update port availability */
@@ -1983,7 +1985,7 @@ static void handle_transport_state_change(struct userdata *u, struct pa_bluetoot
/* Acquire or release transport as needed */
acquire = (t->state == PA_BLUETOOTH_TRANSPORT_STATE_PLAYING && u->profile == t->profile);
- release = (t->state != PA_BLUETOOTH_TRANSPORT_STATE_PLAYING && u->profile == t->profile);
+ release = (oldavail != PA_AVAILABLE_NO && t->state != PA_BLUETOOTH_TRANSPORT_STATE_PLAYING && u->profile == t->profile);
if (acquire && transport_acquire(u, true) >= 0) {
if (u->source) {
More information about the pulseaudio-commits
mailing list