mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-31 22:25:33 -04:00
bluetooth: handle Acquire API change
Acquire now return input and output MTU of the file descriptor so it is no longer necessary to get those after acquiring the fd, which less round trips and faster response time when switching profiles.
This commit is contained in:
parent
dda564f50b
commit
8c982a4afe
3 changed files with 12 additions and 47 deletions
|
|
@ -934,10 +934,11 @@ const pa_bluetooth_transport* pa_bluetooth_device_get_transport(const pa_bluetoo
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int pa_bluetooth_transport_acquire(const pa_bluetooth_transport *t, const char *accesstype) {
|
||||
int pa_bluetooth_transport_acquire(const pa_bluetooth_transport *t, const char *accesstype, size_t *imtu, size_t *omtu) {
|
||||
DBusMessage *m, *r;
|
||||
DBusError err;
|
||||
int ret;
|
||||
uint16_t i, o;
|
||||
|
||||
pa_assert(t);
|
||||
pa_assert(t->y);
|
||||
|
|
@ -955,7 +956,7 @@ int pa_bluetooth_transport_acquire(const pa_bluetooth_transport *t, const char *
|
|||
}
|
||||
|
||||
#ifdef DBUS_TYPE_UNIX_FD
|
||||
if (!dbus_message_get_args(r, &err, DBUS_TYPE_UNIX_FD, &ret, DBUS_TYPE_INVALID)) {
|
||||
if (!dbus_message_get_args(r, &err, DBUS_TYPE_UNIX_FD, &ret, DBUS_TYPE_UINT16, &i, DBUS_TYPE_UINT16, &o, DBUS_TYPE_INVALID)) {
|
||||
pa_log("Failed to parse org.bluez.MediaTransport.Acquire(): %s", err.message);
|
||||
ret = -1;
|
||||
dbus_error_free(&err);
|
||||
|
|
@ -963,6 +964,12 @@ int pa_bluetooth_transport_acquire(const pa_bluetooth_transport *t, const char *
|
|||
}
|
||||
#endif
|
||||
|
||||
if (imtu)
|
||||
*imtu = i;
|
||||
|
||||
if (omtu)
|
||||
*omtu = o;
|
||||
|
||||
fail:
|
||||
dbus_message_unref(r);
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ const pa_bluetooth_device* pa_bluetooth_discovery_get_by_address(pa_bluetooth_di
|
|||
const pa_bluetooth_transport* pa_bluetooth_discovery_get_transport(pa_bluetooth_discovery *y, const char *path);
|
||||
const pa_bluetooth_transport* pa_bluetooth_device_get_transport(const pa_bluetooth_device *d, enum profile profile);
|
||||
|
||||
int pa_bluetooth_transport_acquire(const pa_bluetooth_transport *t, const char *accesstype);
|
||||
int pa_bluetooth_transport_acquire(const pa_bluetooth_transport *t, const char *accesstype, size_t *imtu, size_t *omtu);
|
||||
void pa_bluetooth_transport_release(const pa_bluetooth_transport *t, const char *accesstype);
|
||||
|
||||
pa_hook* pa_bluetooth_discovery_hook(pa_bluetooth_discovery *d);
|
||||
|
|
|
|||
|
|
@ -910,7 +910,8 @@ static int bt_transport_acquire(struct userdata *u, pa_bool_t start) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
u->stream_fd = pa_bluetooth_transport_acquire(t, accesstype);
|
||||
/* FIXME: Handle in/out MTU properly when unix socket is not longer supported */
|
||||
u->stream_fd = pa_bluetooth_transport_acquire(t, accesstype, NULL, &u->link_mtu);
|
||||
if (u->stream_fd < 0)
|
||||
return -1;
|
||||
|
||||
|
|
@ -2164,53 +2165,10 @@ static int parse_transport_property(struct userdata *u, DBusMessageIter *i) {
|
|||
|
||||
/* Run from main thread */
|
||||
static int bt_transport_open(struct userdata *u) {
|
||||
DBusMessage *m, *r;
|
||||
DBusMessageIter arg_i, element_i;
|
||||
DBusError err;
|
||||
|
||||
if (bt_transport_acquire(u, FALSE) < 0)
|
||||
return -1;
|
||||
|
||||
dbus_error_init(&err);
|
||||
|
||||
pa_assert_se(m = dbus_message_new_method_call("org.bluez", u->transport, "org.bluez.MediaTransport", "GetProperties"));
|
||||
r = dbus_connection_send_with_reply_and_block(pa_dbus_connection_get(u->connection), m, -1, &err);
|
||||
|
||||
if (dbus_error_is_set(&err) || !r) {
|
||||
pa_log("Failed to get transport properties: %s", err.message);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!dbus_message_iter_init(r, &arg_i)) {
|
||||
pa_log("GetProperties reply has no arguments.");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (dbus_message_iter_get_arg_type(&arg_i) != DBUS_TYPE_ARRAY) {
|
||||
pa_log("GetProperties argument is not an array.");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
dbus_message_iter_recurse(&arg_i, &element_i);
|
||||
while (dbus_message_iter_get_arg_type(&element_i) != DBUS_TYPE_INVALID) {
|
||||
|
||||
if (dbus_message_iter_get_arg_type(&element_i) == DBUS_TYPE_DICT_ENTRY) {
|
||||
DBusMessageIter dict_i;
|
||||
|
||||
dbus_message_iter_recurse(&element_i, &dict_i);
|
||||
|
||||
parse_transport_property(u, &dict_i);
|
||||
}
|
||||
|
||||
if (!dbus_message_iter_next(&element_i))
|
||||
break;
|
||||
}
|
||||
|
||||
return bt_transport_config(u);
|
||||
|
||||
fail:
|
||||
dbus_message_unref(r);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Run from main thread */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue