mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
bluez5: Clean up ASHA implementation
This commit is contained in:
parent
13c026417b
commit
e83f01a33b
2 changed files with 35 additions and 22 deletions
|
|
@ -2037,7 +2037,6 @@ int spa_bt_device_check_profiles(struct spa_bt_device *device, bool force)
|
||||||
connected_profiles |= SPA_BT_PROFILE_HEADSET_HEAD_UNIT;
|
connected_profiles |= SPA_BT_PROFILE_HEADSET_HEAD_UNIT;
|
||||||
if (connected_profiles & SPA_BT_PROFILE_HEADSET_AUDIO_GATEWAY)
|
if (connected_profiles & SPA_BT_PROFILE_HEADSET_AUDIO_GATEWAY)
|
||||||
connected_profiles |= SPA_BT_PROFILE_HEADSET_AUDIO_GATEWAY;
|
connected_profiles |= SPA_BT_PROFILE_HEADSET_AUDIO_GATEWAY;
|
||||||
connected_profiles |= SPA_BT_PROFILE_ASHA_SINK;
|
|
||||||
|
|
||||||
for (i = 0; i < SPA_N_ELEMENTS(direction_masks); ++i) {
|
for (i = 0; i < SPA_N_ELEMENTS(direction_masks); ++i) {
|
||||||
uint32_t mask = direction_masks[i] & device->profiles & connectable_profiles;
|
uint32_t mask = direction_masks[i] & device->profiles & connectable_profiles;
|
||||||
|
|
@ -2706,12 +2705,8 @@ static int remote_endpoint_update_props(struct spa_bt_remote_endpoint *remote_en
|
||||||
}
|
}
|
||||||
/* For ASHA */
|
/* For ASHA */
|
||||||
else if (spa_streq(key, "Transport")) {
|
else if (spa_streq(key, "Transport")) {
|
||||||
if (setup_asha_transport(remote_endpoint, monitor, value)) {
|
free(remote_endpoint->path);
|
||||||
spa_log_error(monitor->log, "Failed to create transport for remote_endpoint %p: %s=%s", remote_endpoint, key, value);
|
remote_endpoint->path = strdup(value);
|
||||||
goto next;
|
|
||||||
}
|
|
||||||
|
|
||||||
spa_log_info(monitor->log, "Created ASHA transport for %s", value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type == DBUS_TYPE_BOOLEAN) {
|
else if (type == DBUS_TYPE_BOOLEAN) {
|
||||||
|
|
@ -2803,11 +2798,18 @@ next:
|
||||||
profile = spa_bt_profile_from_uuid(remote_endpoint->uuid);
|
profile = spa_bt_profile_from_uuid(remote_endpoint->uuid);
|
||||||
if (profile & SPA_BT_PROFILE_BAP_AUDIO)
|
if (profile & SPA_BT_PROFILE_BAP_AUDIO)
|
||||||
spa_bt_device_add_profile(remote_endpoint->device, profile);
|
spa_bt_device_add_profile(remote_endpoint->device, profile);
|
||||||
|
|
||||||
|
if (spa_streq(remote_endpoint->uuid, SPA_BT_UUID_ASHA_SINK)) {
|
||||||
if (profile & SPA_BT_PROFILE_ASHA_SINK) {
|
if (profile & SPA_BT_PROFILE_ASHA_SINK) {
|
||||||
|
if (setup_asha_transport(remote_endpoint, monitor, remote_endpoint->path)) {
|
||||||
|
spa_log_error(monitor->log, "Failed to create transport for remote_endpoint %p", remote_endpoint);
|
||||||
|
} else {
|
||||||
spa_log_debug(monitor->log, "Adding profile for remote_endpoint %p: device -> %p", remote_endpoint, remote_endpoint->device);
|
spa_log_debug(monitor->log, "Adding profile for remote_endpoint %p: device -> %p", remote_endpoint, remote_endpoint->device);
|
||||||
spa_bt_device_add_profile(remote_endpoint->device, SPA_BT_PROFILE_ASHA_SINK);
|
spa_bt_device_add_profile(remote_endpoint->device, SPA_BT_PROFILE_ASHA_SINK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -4083,11 +4085,21 @@ static int setup_asha_transport(struct spa_bt_remote_endpoint *remote_endpoint,
|
||||||
const struct media_codec * const * const media_codecs = monitor->media_codecs;
|
const struct media_codec * const * const media_codecs = monitor->media_codecs;
|
||||||
const struct media_codec *codec = NULL;
|
const struct media_codec *codec = NULL;
|
||||||
struct spa_bt_transport *transport;
|
struct spa_bt_transport *transport;
|
||||||
|
char *tpath;
|
||||||
|
|
||||||
transport = spa_bt_transport_find(monitor, transport_path);
|
transport = spa_bt_transport_find(monitor, transport_path);
|
||||||
if (transport == NULL) {
|
if (transport != NULL) {
|
||||||
char *tpath = strdup(transport_path);
|
struct spa_bt_device *d = transport->device;
|
||||||
|
if (d != NULL)
|
||||||
|
device_free(d);
|
||||||
|
|
||||||
|
spa_log_debug(monitor->log, "transport %p: free %s",
|
||||||
|
transport, transport->path);
|
||||||
|
|
||||||
|
spa_bt_transport_free(transport);
|
||||||
|
}
|
||||||
|
|
||||||
|
tpath = strdup(transport_path);
|
||||||
transport = spa_bt_transport_create(monitor, tpath, 0);
|
transport = spa_bt_transport_create(monitor, tpath, 0);
|
||||||
if (transport == NULL) {
|
if (transport == NULL) {
|
||||||
spa_log_error(monitor->log, "Failed to create transport for %s", transport_path);
|
spa_log_error(monitor->log, "Failed to create transport for %s", transport_path);
|
||||||
|
|
@ -4098,7 +4110,6 @@ static int setup_asha_transport(struct spa_bt_remote_endpoint *remote_endpoint,
|
||||||
spa_bt_transport_set_implementation(transport, &transport_impl, transport);
|
spa_bt_transport_set_implementation(transport, &transport_impl, transport);
|
||||||
|
|
||||||
spa_log_debug(monitor->log, "Created ASHA transport for %s", transport_path);
|
spa_log_debug(monitor->log, "Created ASHA transport for %s", transport_path);
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; media_codecs[i]; i++) {
|
for (int i = 0; media_codecs[i]; i++) {
|
||||||
const struct media_codec *mcodec = media_codecs[i];
|
const struct media_codec *mcodec = media_codecs[i];
|
||||||
|
|
@ -6289,6 +6300,8 @@ int spa_bt_profiles_from_json_array(const char *str)
|
||||||
profiles |= SPA_BT_PROFILE_BAP_BROADCAST_SOURCE;
|
profiles |= SPA_BT_PROFILE_BAP_BROADCAST_SOURCE;
|
||||||
} else if (spa_streq(role_name, "bap_bcast_sink")) {
|
} else if (spa_streq(role_name, "bap_bcast_sink")) {
|
||||||
profiles |= SPA_BT_PROFILE_BAP_BROADCAST_SINK;
|
profiles |= SPA_BT_PROFILE_BAP_BROADCAST_SINK;
|
||||||
|
} else if (spa_streq(role_name, "asha_sink")) {
|
||||||
|
profiles |= SPA_BT_PROFILE_ASHA_SINK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1114,7 +1114,7 @@ static int emit_nodes(struct impl *this)
|
||||||
t = find_transport(this, SPA_BT_PROFILE_ASHA_SINK);
|
t = find_transport(this, SPA_BT_PROFILE_ASHA_SINK);
|
||||||
if (t) {
|
if (t) {
|
||||||
this->props.codec = t->media_codec->id;
|
this->props.codec = t->media_codec->id;
|
||||||
emit_node(this, t, DEVICE_ID_SOURCE, SPA_NAME_API_BLUEZ5_MEDIA_SINK, false);
|
emit_node(this, t, DEVICE_ID_SINK, SPA_NAME_API_BLUEZ5_MEDIA_SINK, false);
|
||||||
} else {
|
} else {
|
||||||
spa_log_warn(this->log, "Unable to find transport for ASHA");
|
spa_log_warn(this->log, "Unable to find transport for ASHA");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue