mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
bluetooth: Expose card profile availability
Use the transport's state to not only update the ports availability, but also to update the card profile availability flag. The interpretation is as follows: - PA_AVAILABLE_UNKNOWN: BT profile is connected but no audio streaming - PA_AVAILABLE_NO: BT profile disconnected - PA_AVAILABLE_YES: BT profile connected and audio streaming
This commit is contained in:
parent
cfa79a84fc
commit
966a827d77
1 changed files with 15 additions and 1 deletions
|
|
@ -1215,6 +1215,7 @@ static void handle_transport_state_change(struct userdata *u, struct pa_bluetoot
|
||||||
bool acquire = false;
|
bool acquire = false;
|
||||||
bool release = false;
|
bool release = false;
|
||||||
enum profile profile;
|
enum profile profile;
|
||||||
|
pa_card_profile *cp;
|
||||||
pa_bluetooth_transport_state_t state;
|
pa_bluetooth_transport_state_t state;
|
||||||
|
|
||||||
pa_assert(u);
|
pa_assert(u);
|
||||||
|
|
@ -1223,9 +1224,13 @@ static void handle_transport_state_change(struct userdata *u, struct pa_bluetoot
|
||||||
profile = transport->profile;
|
profile = transport->profile;
|
||||||
state = transport->state;
|
state = transport->state;
|
||||||
|
|
||||||
if (!pa_hashmap_get(u->card->profiles, pa_bt_profile_to_string(profile)))
|
/* Update profile availability */
|
||||||
|
if (!(cp = pa_hashmap_get(u->card->profiles, pa_bt_profile_to_string(profile))))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
pa_card_profile_set_available(cp, transport_state_to_availability(state));
|
||||||
|
|
||||||
|
/* Update port availability */
|
||||||
switch (profile) {
|
switch (profile) {
|
||||||
case PROFILE_HFGW: {
|
case PROFILE_HFGW: {
|
||||||
pa_device_port *port;
|
pa_device_port *port;
|
||||||
|
|
@ -1301,6 +1306,7 @@ static void handle_transport_state_change(struct userdata *u, struct pa_bluetoot
|
||||||
pa_assert_not_reached();
|
pa_assert_not_reached();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Acquire or release transport as needed */
|
||||||
if (acquire)
|
if (acquire)
|
||||||
if (bt_transport_acquire(u, true) >= 0) {
|
if (bt_transport_acquire(u, true) >= 0) {
|
||||||
if (u->source) {
|
if (u->source) {
|
||||||
|
|
@ -2263,6 +2269,13 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid
|
||||||
*d = PROFILE_HFGW;
|
*d = PROFILE_HFGW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (p) {
|
||||||
|
pa_bluetooth_transport *t;
|
||||||
|
|
||||||
|
if ((t = u->device->transports[*d]))
|
||||||
|
p->available = transport_state_to_availability(t->state);
|
||||||
|
}
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2324,6 +2337,7 @@ static int add_card(struct userdata *u) {
|
||||||
pa_assert(!pa_hashmap_isempty(data.profiles));
|
pa_assert(!pa_hashmap_isempty(data.profiles));
|
||||||
|
|
||||||
p = pa_card_profile_new("off", _("Off"), sizeof(enum profile));
|
p = pa_card_profile_new("off", _("Off"), sizeof(enum profile));
|
||||||
|
p->available = PA_AVAILABLE_YES;
|
||||||
d = PA_CARD_PROFILE_DATA(p);
|
d = PA_CARD_PROFILE_DATA(p);
|
||||||
*d = PROFILE_OFF;
|
*d = PROFILE_OFF;
|
||||||
pa_hashmap_put(data.profiles, p->name, p);
|
pa_hashmap_put(data.profiles, p->name, p);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue