mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-26 05:34:23 +08:00
Add object field to audio ipc messages.
This commit is contained in:
parent
9bdf6ba0c5
commit
47f426817d
@ -140,7 +140,7 @@ static struct audio_device *a2dp_get_dev(struct avdtp *session)
|
||||
|
||||
avdtp_get_peers(session, &src, &dst);
|
||||
|
||||
return manager_find_device(&src, &dst, NULL, FALSE);
|
||||
return manager_find_device(NULL, &src, &dst, NULL, FALSE);
|
||||
}
|
||||
|
||||
static gboolean finalize_config(struct a2dp_setup *s)
|
||||
|
@ -114,6 +114,7 @@ struct bt_get_capabilities_req {
|
||||
bt_audio_msg_header_t h;
|
||||
char source[18]; /* Address of the local Device */
|
||||
char destination[18];/* Address of the remote Device */
|
||||
char object[128]; /* DBus object path */
|
||||
uint8_t transport; /* Requested transport */
|
||||
uint8_t flags; /* Requested flags */
|
||||
} __attribute__ ((packed));
|
||||
@ -202,6 +203,7 @@ struct bt_get_capabilities_rsp {
|
||||
bt_audio_msg_header_t h;
|
||||
char source[18]; /* Address of the local Device */
|
||||
char destination[18];/* Address of the remote Device */
|
||||
char object[128]; /* DBus object path */
|
||||
uint8_t data[0]; /* First codec_capabilities_t */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
@ -209,6 +211,7 @@ struct bt_set_configuration_req {
|
||||
bt_audio_msg_header_t h;
|
||||
char source[18]; /* Address of the local Device */
|
||||
char destination[18];/* Address of the remote Device */
|
||||
char object[128]; /* DBus object path */
|
||||
uint8_t access_mode; /* Requested access mode */
|
||||
codec_capabilities_t codec; /* Requested codec */
|
||||
} __attribute__ ((packed));
|
||||
@ -217,6 +220,7 @@ struct bt_set_configuration_rsp {
|
||||
bt_audio_msg_header_t h;
|
||||
char source[18]; /* Address of the local Device */
|
||||
char destination[18];/* Address of the remote Device */
|
||||
char object[128]; /* DBus object path */
|
||||
uint8_t transport; /* Granted transport */
|
||||
uint8_t access_mode; /* Granted access mode */
|
||||
uint16_t link_mtu; /* Max length that transport supports */
|
||||
|
@ -89,7 +89,7 @@ static void sco_server_cb(GIOChannel *chan, GError *err, gpointer data)
|
||||
goto drop;
|
||||
}
|
||||
|
||||
device = manager_find_device(&src, &dst, NULL, FALSE);
|
||||
device = manager_find_device(NULL, &src, &dst, NULL, FALSE);
|
||||
if (!device)
|
||||
goto drop;
|
||||
|
||||
|
@ -681,16 +681,12 @@ static int audio_probe(struct btd_device *device, GSList *uuids)
|
||||
|
||||
static void audio_remove(struct btd_device *device)
|
||||
{
|
||||
struct btd_adapter *adapter;
|
||||
struct audio_device *dev;
|
||||
bdaddr_t src, dst;
|
||||
const char *path;
|
||||
|
||||
adapter = device_get_adapter(device);
|
||||
path = device_get_path(device);
|
||||
|
||||
adapter_get_address(adapter, &src);
|
||||
device_get_address(device, &dst);
|
||||
|
||||
dev = manager_find_device(&src, &dst, NULL, FALSE);
|
||||
dev = manager_find_device(path, NULL, NULL, NULL, FALSE);
|
||||
if (!dev)
|
||||
return;
|
||||
|
||||
@ -1015,7 +1011,8 @@ void audio_manager_exit(void)
|
||||
btd_unregister_device_driver(&audio_driver);
|
||||
}
|
||||
|
||||
struct audio_device *manager_find_device(const bdaddr_t *src,
|
||||
struct audio_device *manager_find_device(const char *path,
|
||||
const bdaddr_t *src,
|
||||
const bdaddr_t *dst,
|
||||
const char *interface,
|
||||
gboolean connected)
|
||||
@ -1025,10 +1022,13 @@ struct audio_device *manager_find_device(const bdaddr_t *src,
|
||||
for (l = devices; l != NULL; l = l->next) {
|
||||
struct audio_device *dev = l->data;
|
||||
|
||||
if (bacmp(src, BDADDR_ANY) && bacmp(&dev->src, src))
|
||||
if ((path && (strcmp(path, "")) && strcmp(dev->path, path)))
|
||||
continue;
|
||||
|
||||
if (bacmp(dst, BDADDR_ANY) && bacmp(&dev->dst, dst))
|
||||
if ((src && bacmp(src, BDADDR_ANY)) && bacmp(&dev->src, src))
|
||||
continue;
|
||||
|
||||
if ((dst && bacmp(dst, BDADDR_ANY)) && bacmp(&dev->dst, dst))
|
||||
continue;
|
||||
|
||||
if (interface && !strcmp(AUDIO_HEADSET_INTERFACE, interface)
|
||||
@ -1065,7 +1065,7 @@ struct audio_device *manager_get_device(const bdaddr_t *src,
|
||||
char addr[18];
|
||||
const char *path;
|
||||
|
||||
dev = manager_find_device(src, dst, NULL, FALSE);
|
||||
dev = manager_find_device(NULL, src, dst, NULL, FALSE);
|
||||
if (dev)
|
||||
return dev;
|
||||
|
||||
|
@ -36,7 +36,8 @@ void audio_manager_exit(void);
|
||||
|
||||
gboolean server_is_enabled(bdaddr_t *src, uint16_t svc);
|
||||
|
||||
struct audio_device *manager_find_device(const bdaddr_t *src,
|
||||
struct audio_device *manager_find_device(const char *path,
|
||||
const bdaddr_t *src,
|
||||
const bdaddr_t *dst,
|
||||
const char *interface,
|
||||
gboolean connected);
|
||||
|
26
audio/unix.c
26
audio/unix.c
@ -264,6 +264,7 @@ static void headset_discovery_complete(struct audio_device *dev, void *user_data
|
||||
rsp->h.length = sizeof(*rsp) + codec->length;
|
||||
ba2str(&dev->src, rsp->source);
|
||||
ba2str(&dev->dst, rsp->destination);
|
||||
strncpy(rsp->object, dev->path, sizeof(rsp->object));
|
||||
|
||||
unix_ipc_sendmsg(client, &rsp->h);
|
||||
|
||||
@ -293,6 +294,7 @@ static void headset_setup_complete(struct audio_device *dev, void *user_data)
|
||||
|
||||
ba2str(&dev->src, rsp->source);
|
||||
ba2str(&dev->dst, rsp->destination);
|
||||
strncpy(rsp->object, dev->path, sizeof(rsp->object));
|
||||
rsp->transport = BT_CAPABILITIES_TRANSPORT_SCO;
|
||||
rsp->access_mode = client->access_mode;
|
||||
rsp->link_mtu = 48;
|
||||
@ -480,6 +482,7 @@ static void a2dp_discovery_complete(struct avdtp *session, GSList *seps,
|
||||
rsp->h.length = sizeof(*rsp);
|
||||
ba2str(&client->dev->src, rsp->source);
|
||||
ba2str(&client->dev->dst, rsp->destination);
|
||||
strncpy(rsp->object, client->dev->path, sizeof(rsp->object));
|
||||
|
||||
for (l = seps; l; l = g_slist_next(l)) {
|
||||
struct avdtp_remote_sep *rsep = l->data;
|
||||
@ -553,6 +556,7 @@ static void a2dp_config_complete(struct avdtp *session, struct a2dp_sep *sep,
|
||||
|
||||
ba2str(&client->dev->src, rsp->source);
|
||||
ba2str(&client->dev->dst, rsp->destination);
|
||||
strncpy(rsp->object, client->dev->path, sizeof(rsp->object));
|
||||
rsp->transport = BT_CAPABILITIES_TRANSPORT_A2DP;
|
||||
client->access_mode = BT_CAPABILITIES_ACCESS_MODE_WRITE;
|
||||
rsp->access_mode = client->access_mode;
|
||||
@ -890,7 +894,8 @@ static void handle_getcapabilities_req(struct unix_client *client,
|
||||
bdaddr_t src, dst;
|
||||
int err = EIO;
|
||||
|
||||
if (!check_nul(req->source) || !check_nul(req->destination)) {
|
||||
if (!check_nul(req->source) || !check_nul(req->destination) ||
|
||||
!check_nul(req->object)) {
|
||||
err = EINVAL;
|
||||
goto failed;
|
||||
}
|
||||
@ -908,12 +913,14 @@ static void handle_getcapabilities_req(struct unix_client *client,
|
||||
else if (req->transport == BT_CAPABILITIES_TRANSPORT_A2DP)
|
||||
client->interface = g_strdup(AUDIO_SINK_INTERFACE);
|
||||
|
||||
if (!manager_find_device(&src, &dst, NULL, FALSE))
|
||||
if (!manager_find_device(req->object, &src, &dst, NULL, FALSE))
|
||||
goto failed;
|
||||
|
||||
dev = manager_find_device(&src, &dst, client->interface, TRUE);
|
||||
dev = manager_find_device(req->object, &src, &dst, client->interface,
|
||||
TRUE);
|
||||
if (!dev && (req->flags & BT_FLAG_AUTOCONNECT))
|
||||
dev = manager_find_device(&src, &dst, client->interface, FALSE);
|
||||
dev = manager_find_device(req->object, &src, &dst,
|
||||
client->interface, FALSE);
|
||||
|
||||
if (!dev) {
|
||||
error("Unable to find a matching device");
|
||||
@ -1036,7 +1043,8 @@ static void handle_setconfiguration_req(struct unix_client *client,
|
||||
int err = 0;
|
||||
|
||||
if (!req->access_mode || !check_nul(req->source) ||
|
||||
!check_nul(req->destination)) {
|
||||
!check_nul(req->destination) ||
|
||||
!check_nul(req->object)) {
|
||||
err = EINVAL;
|
||||
goto failed;
|
||||
}
|
||||
@ -1058,12 +1066,14 @@ static void handle_setconfiguration_req(struct unix_client *client,
|
||||
}
|
||||
}
|
||||
|
||||
if (!manager_find_device(&src, &dst, NULL, FALSE))
|
||||
if (!manager_find_device(req->object, &src, &dst, NULL, FALSE))
|
||||
goto failed;
|
||||
|
||||
dev = manager_find_device(&src, &dst, client->interface, TRUE);
|
||||
dev = manager_find_device(req->object, &src, &dst, client->interface,
|
||||
TRUE);
|
||||
if (!dev)
|
||||
dev = manager_find_device(&src, &dst, client->interface, FALSE);
|
||||
dev = manager_find_device(req->object, &src, &dst,
|
||||
client->interface, FALSE);
|
||||
|
||||
if (!dev)
|
||||
goto failed;
|
||||
|
Loading…
Reference in New Issue
Block a user