From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v2 2/2] client/player: Fix using unicast QoS for broadcast
Date: Fri, 19 Apr 2024 16:23:41 -0400 [thread overview]
Message-ID: <20240419202341.1635591-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20240419202341.1635591-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The code needs to identify first if the parameters refers to a broadcast
stream or unicast.
---
client/player.c | 34 ++++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/client/player.c b/client/player.c
index 65f771039258..6b70e9ed3f9d 100644
--- a/client/player.c
+++ b/client/player.c
@@ -34,6 +34,7 @@
#include "lib/bluetooth.h"
#include "lib/uuid.h"
+#include "lib/iso.h"
#include "profiles/audio/a2dp-codecs.h"
#include "src/shared/lc3.h"
@@ -143,6 +144,7 @@ struct transport {
struct io *io;
uint32_t seq;
struct io *timer_io;
+ int num;
};
static void endpoint_unregister(void *data)
@@ -5008,7 +5010,6 @@ static bool transport_timer_read(struct io *io, void *user_data)
struct bt_iso_qos qos;
socklen_t len;
int ret, fd;
- uint32_t num;
uint64_t exp;
if (transport->fd < 0)
@@ -5032,11 +5033,7 @@ static bool transport_timer_read(struct io *io, void *user_data)
return false;
}
- /* num of packets = ROUND_CLOSEST(latency (ms) / interval (us)) */
- num = ROUND_CLOSEST(qos.ucast.out.latency * 1000,
- qos.ucast.out.interval);
-
- ret = transport_send_seq(transport, transport->fd, num);
+ ret = transport_send_seq(transport, transport->fd, transport->num);
if (ret < 0) {
bt_shell_printf("Unable to send: %s (%d)\n",
strerror(-ret), ret);
@@ -5052,7 +5049,7 @@ static bool transport_timer_read(struct io *io, void *user_data)
}
static int transport_send(struct transport *transport, int fd,
- struct bt_iso_qos *qos)
+ struct bt_iso_io_qos *qos)
{
struct itimerspec ts;
int timer_fd;
@@ -5070,14 +5067,15 @@ static int transport_send(struct transport *transport, int fd,
return -errno;
memset(&ts, 0, sizeof(ts));
- ts.it_value.tv_nsec = qos->ucast.out.latency * 1000000;
- ts.it_interval.tv_nsec = qos->ucast.out.latency * 1000000;
+ ts.it_value.tv_nsec = qos->latency * 1000000;
+ ts.it_interval.tv_nsec = qos->latency * 1000000;
if (timerfd_settime(timer_fd, TFD_TIMER_ABSTIME, &ts, NULL) < 0)
return -errno;
transport->fd = fd;
-
+ /* num of packets = ROUND_CLOSEST(latency (ms) / interval (us)) */
+ transport->num = ROUND_CLOSEST(qos->latency * 1000, qos->interval);
transport->timer_io = io_new(timer_fd);
io_set_read_handler(transport->timer_io, transport_timer_read,
@@ -5131,8 +5129,20 @@ static void cmd_send_transport(int argc, char *argv[])
bt_shell_printf("Unable to getsockopt(BT_ISO_QOS): %s",
strerror(errno));
err = transport_send(transport, fd, NULL);
- } else
- err = transport_send(transport, fd, &qos);
+ } else {
+ struct sockaddr_iso addr;
+ socklen_t optlen;
+
+ err = getpeername(transport->sk, &addr, &optlen);
+ if (!err) {
+ if (!(bacmp(&addr.iso_bdaddr, BDADDR_ANY)))
+ err = transport_send(transport, fd,
+ &qos.bcast.out);
+ else
+ err = transport_send(transport, fd,
+ &qos.ucast.out);
+ }
+ }
if (err < 0) {
bt_shell_printf("Unable to send: %s (%d)",
--
2.44.0
next prev parent reply other threads:[~2024-04-19 20:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-19 20:23 [PATCH BlueZ v2 1/2] client/player: Fix calculation of number of packet Luiz Augusto von Dentz
2024-04-19 20:23 ` Luiz Augusto von Dentz [this message]
2024-04-22 16:46 ` [PATCH BlueZ v2 2/2] client/player: Fix using unicast QoS for broadcast Pauli Virtanen
2024-04-19 22:27 ` [BlueZ,v2,1/2] client/player: Fix calculation of number of packet bluez.test.bot
2024-04-22 15:40 ` [PATCH BlueZ v2 1/2] " patchwork-bot+bluetooth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240419202341.1635591-2-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox