From be49c92a381d433704438c810ce8e1b09b9aa550 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Mon, 5 Jan 2009 19:12:43 -0300 Subject: Send packets with proper size. --- src/modules/bluetooth/module-bluetooth-device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index 5974d485..492ee203 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -127,7 +127,7 @@ static int bt_audioservice_send(int sk, const bt_audio_msg_header_t *msg) { type = bt_audio_strtype(msg->type); name = bt_audio_strname(msg->name); pa_log_debug("sending: %s -> %s", type, name); - if (send(sk, msg, BT_SUGGESTED_BUFFER_SIZE, 0) > 0) + if (send(sk, msg, msg->length, 0) > 0) e = 0; else { e = -errno; -- cgit From 1a96c9b0a6dceeeb1701703fef8bdb15572662cf Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Tue, 6 Jan 2009 11:00:44 -0300 Subject: Fix send and recv message sizes. --- src/modules/bluetooth/module-bluetooth-device.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index 492ee203..2546c694 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -123,11 +123,13 @@ static const char* const valid_modargs[] = { static int bt_audioservice_send(int sk, const bt_audio_msg_header_t *msg) { int e; const char *type, *name; + uint16_t length; + length = msg->length ? msg->length : BT_SUGGESTED_BUFFER_SIZE; type = bt_audio_strtype(msg->type); name = bt_audio_strname(msg->name); pa_log_debug("sending: %s -> %s", type, name); - if (send(sk, msg, msg->length, 0) > 0) + if (send(sk, msg, length, 0) > 0) e = 0; else { e = -errno; @@ -139,9 +141,12 @@ static int bt_audioservice_send(int sk, const bt_audio_msg_header_t *msg) { static int bt_audioservice_recv(int sk, bt_audio_msg_header_t *inmsg, uint16_t expected_length) { int e; const char *type, *name; + uint16_t length; + + length = expected_length ? expected_length : BT_SUGGESTED_BUFFER_SIZE; pa_log_debug("trying to receive msg from audio service..."); - if (recv(sk, inmsg, expected_length ? : BT_SUGGESTED_BUFFER_SIZE, 0) > 0) { + if (recv(sk, inmsg, length, 0) > 0) { type = bt_audio_strtype(inmsg->type); name = bt_audio_strname(inmsg->name); if (type && name) { -- cgit From e7e6f86bbe0dda37e906ed31144b44a83327ee02 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Tue, 6 Jan 2009 11:02:16 -0300 Subject: Fix sending wrong codec capability length. --- src/modules/bluetooth/module-bluetooth-device.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index 2546c694..cb4746a4 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -458,9 +458,12 @@ static int bt_setconf(struct userdata *u) { strncpy(msg.setconf_req.device, u->addr, 18); msg.setconf_req.codec.transport = u->transport; - if (u->transport == BT_CAPABILITIES_TRANSPORT_A2DP) + if (u->transport == BT_CAPABILITIES_TRANSPORT_A2DP) { memcpy(&msg.setconf_req.codec, &u->a2dp.sbc_capabilities, sizeof(u->a2dp.sbc_capabilities)); + msg.setconf_req.h.length += msg.setconf_req.codec.length + - sizeof(msg.setconf_req.codec); + } msg.setconf_req.access_mode = BT_CAPABILITIES_ACCESS_MODE_WRITE; e = bt_audioservice_send(u->audioservice_fd, &msg.setconf_req.h); -- cgit