[PATCH BlueZ v2 3/5] client/player: Use bt_shell_echo to print transfer progress

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>

This uses bt_shell_echo to print transfer progress.
---
 client/player.c    | 12 ++++--------
 src/shared/shell.c | 10 +++++-----
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/client/player.c b/client/player.c
index 1f10387f89ad..e73ed6ac925a 100644
--- a/client/player.c
+++ b/client/player.c
@@ -3000,11 +3000,11 @@ static bool transport_recv(struct io *io, void *user_data)
 		return true;
 	}
 
-	bt_shell_printf("[seq %d] recv: %u bytes\n", transport->seq, ret);
+	bt_shell_echo("[seq %d] recv: %u bytes", transport->seq, ret);
 
 	transport->seq++;
 
-	if (transport->fd) {
+	if (transport->fd >= 0) {
 		len = write(transport->fd, buf, ret);
 		if (len < 0)
 			bt_shell_printf("Unable to write: %s (%d)",
@@ -3378,7 +3378,6 @@ static int transport_send_seq(struct transport *transport, int fd, uint32_t num)
 
 	for (i = 0; i < num; i++, transport->seq++) {
 		ssize_t ret;
-		int queued;
 		int secs = 0, nsecs = 0;
 
 		ret = read(fd, buf, transport->mtu[1]);
@@ -3400,13 +3399,10 @@ static int transport_send_seq(struct transport *transport, int fd, uint32_t num)
 
 		elapsed_time(!transport->seq, &secs, &nsecs);
 
-		ioctl(transport->sk, TIOCOUTQ, &queued);
-
-		bt_shell_printf("[seq %d %d.%03ds] send: %zd bytes "
-				"(TIOCOUTQ %d bytes)\n",
+		bt_shell_echo("[seq %d %d.%03ds] send: %zd bytes ",
 				transport->seq, secs,
 				(nsecs + 500000) / 1000000,
-				ret, queued);
+				ret);
 	}
 
 	free(buf);
diff --git a/src/shared/shell.c b/src/shared/shell.c
index 3c0e61dbc414..3358b383e9e4 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -580,15 +580,15 @@ void bt_shell_echo(const char *fmt, ...)
 {
 	va_list args;
 	char *str;
-	int err;
+	int ret;
 
 	va_start(args, fmt);
-	err = vasprintf(&str, fmt, args);
-	if (!err)
-		err = asprintf(&str, COLOR_HIGHLIGHT "%s#" COLOR_OFF, str);
+	ret = vasprintf(&str, fmt, args);
+	if (ret >= 0)
+		ret = asprintf(&str, COLOR_HIGHLIGHT "%s " COLOR_OFF "#", str);
 	va_end(args);
 
-	if (err)
+	if (ret < 0)
 		return;
 
 	rl_save_prompt();
-- 
2.37.3




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux