mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-18 08:56:45 -05:00
bluez: Update BT profiles
Only provide high-level A2DP and HSP/HFP profiles in pw. Expose nodes based on pw profiles and BT profiles available on remote device.
This commit is contained in:
parent
a520335581
commit
0b970ec965
1 changed files with 46 additions and 43 deletions
|
|
@ -111,24 +111,37 @@ static struct spa_bt_transport *find_transport(struct impl *this, int profile)
|
||||||
static int emit_nodes(struct impl *this)
|
static int emit_nodes(struct impl *this)
|
||||||
{
|
{
|
||||||
struct spa_bt_transport *t;
|
struct spa_bt_transport *t;
|
||||||
|
int index = 0;
|
||||||
t = find_transport(this, this->profile);
|
|
||||||
if (t == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
switch (this->profile) {
|
switch (this->profile) {
|
||||||
case SPA_BT_PROFILE_A2DP_SOURCE:
|
case 1:
|
||||||
emit_node(this, t, 0, SPA_NAME_API_BLUEZ5_A2DP_SOURCE);
|
if (this->bt_dev->connected_profiles & SPA_BT_PROFILE_A2DP_SOURCE) {
|
||||||
|
t = find_transport(this, SPA_BT_PROFILE_A2DP_SOURCE);
|
||||||
|
if (t)
|
||||||
|
emit_node(this, t, index++, SPA_NAME_API_BLUEZ5_A2DP_SOURCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->bt_dev->connected_profiles & SPA_BT_PROFILE_A2DP_SINK) {
|
||||||
|
t = find_transport(this, SPA_BT_PROFILE_A2DP_SINK);
|
||||||
|
if (t)
|
||||||
|
emit_node(this, t, index++, SPA_NAME_API_BLUEZ5_A2DP_SINK);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SPA_BT_PROFILE_A2DP_SINK:
|
case 2:
|
||||||
emit_node(this, t, 0, SPA_NAME_API_BLUEZ5_A2DP_SINK);
|
if (this->bt_dev->connected_profiles &
|
||||||
break;
|
(SPA_BT_PROFILE_HEADSET_HEAD_UNIT | SPA_BT_PROFILE_HEADSET_AUDIO_GATEWAY) ) {
|
||||||
case SPA_BT_PROFILE_HSP_HS:
|
int i;
|
||||||
case SPA_BT_PROFILE_HSP_AG:
|
|
||||||
case SPA_BT_PROFILE_HFP_HF:
|
for (i = SPA_BT_PROFILE_HSP_HS ; i <= SPA_BT_PROFILE_HFP_AG ; i <<= 1) {
|
||||||
case SPA_BT_PROFILE_HFP_AG:
|
t = find_transport(this, i);
|
||||||
emit_node(this, t, 0, SPA_NAME_API_BLUEZ5_SCO_SOURCE);
|
if (t)
|
||||||
emit_node(this, t, 1, SPA_NAME_API_BLUEZ5_SCO_SINK);
|
break;
|
||||||
|
}
|
||||||
|
if (t == NULL)
|
||||||
|
return 0;
|
||||||
|
emit_node(this, t, index++, SPA_NAME_API_BLUEZ5_SCO_SOURCE);
|
||||||
|
emit_node(this, t, index++, SPA_NAME_API_BLUEZ5_SCO_SINK);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
@ -142,14 +155,10 @@ static int set_profile(struct impl *this, uint32_t profile)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (this->profile) {
|
switch (this->profile) {
|
||||||
case SPA_BT_PROFILE_A2DP_SOURCE:
|
case 1:
|
||||||
case SPA_BT_PROFILE_A2DP_SINK:
|
|
||||||
spa_device_emit_object_info(&this->hooks, 0, NULL);
|
spa_device_emit_object_info(&this->hooks, 0, NULL);
|
||||||
break;
|
break;
|
||||||
case SPA_BT_PROFILE_HSP_HS:
|
case 2:
|
||||||
case SPA_BT_PROFILE_HSP_AG:
|
|
||||||
case SPA_BT_PROFILE_HFP_HF:
|
|
||||||
case SPA_BT_PROFILE_HFP_AG:
|
|
||||||
spa_device_emit_object_info(&this->hooks, 0, NULL);
|
spa_device_emit_object_info(&this->hooks, 0, NULL);
|
||||||
spa_device_emit_object_info(&this->hooks, 1, NULL);
|
spa_device_emit_object_info(&this->hooks, 1, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
@ -215,18 +224,6 @@ static int impl_sync(void *object, int seq)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int maskn(int v, int n)
|
|
||||||
{
|
|
||||||
int pos = 0, cnt = 0;
|
|
||||||
while (v) {
|
|
||||||
if ((v & 1) == 1 && (++cnt == n))
|
|
||||||
return 1 << pos;
|
|
||||||
v >>= 1;
|
|
||||||
pos++;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int impl_enum_params(void *object, int seq,
|
static int impl_enum_params(void *object, int seq,
|
||||||
uint32_t id, uint32_t start, uint32_t num,
|
uint32_t id, uint32_t start, uint32_t num,
|
||||||
const struct spa_pod *filter)
|
const struct spa_pod *filter)
|
||||||
|
|
@ -252,8 +249,6 @@ static int impl_enum_params(void *object, int seq,
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case SPA_PARAM_EnumProfile:
|
case SPA_PARAM_EnumProfile:
|
||||||
{
|
{
|
||||||
int profile;
|
|
||||||
|
|
||||||
switch (result.index) {
|
switch (result.index) {
|
||||||
case 0:
|
case 0:
|
||||||
param = spa_pod_builder_add_object(&b,
|
param = spa_pod_builder_add_object(&b,
|
||||||
|
|
@ -261,18 +256,26 @@ static int impl_enum_params(void *object, int seq,
|
||||||
SPA_PARAM_PROFILE_index, SPA_POD_Int(0),
|
SPA_PARAM_PROFILE_index, SPA_POD_Int(0),
|
||||||
SPA_PARAM_PROFILE_name, SPA_POD_String("Off"));
|
SPA_PARAM_PROFILE_name, SPA_POD_String("Off"));
|
||||||
break;
|
break;
|
||||||
default:
|
case 1:
|
||||||
{
|
if (!(device->connected_profiles &
|
||||||
profile = maskn(device->connected_profiles, result.index);
|
(SPA_BT_PROFILE_A2DP_SINK | SPA_BT_PROFILE_A2DP_SOURCE)))
|
||||||
if (profile == 0)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
param = spa_pod_builder_add_object(&b,
|
param = spa_pod_builder_add_object(&b,
|
||||||
SPA_TYPE_OBJECT_ParamProfile, id,
|
SPA_TYPE_OBJECT_ParamProfile, id,
|
||||||
SPA_PARAM_PROFILE_index, SPA_POD_Int(profile),
|
SPA_PARAM_PROFILE_index, SPA_POD_Int(1),
|
||||||
SPA_PARAM_PROFILE_name, SPA_POD_String(spa_bt_profile_name(profile)));
|
SPA_PARAM_PROFILE_name, SPA_POD_String("A2DP"));
|
||||||
break;
|
break;
|
||||||
}
|
case 2:
|
||||||
|
if (!(device->connected_profiles &
|
||||||
|
(SPA_BT_PROFILE_HEADSET_HEAD_UNIT | SPA_BT_PROFILE_HEADSET_AUDIO_GATEWAY)))
|
||||||
|
return 0;
|
||||||
|
param = spa_pod_builder_add_object(&b,
|
||||||
|
SPA_TYPE_OBJECT_ParamProfile, id,
|
||||||
|
SPA_PARAM_PROFILE_index, SPA_POD_Int(2),
|
||||||
|
SPA_PARAM_PROFILE_name, SPA_POD_String("HSP/HFP"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue