summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2022-12-13 16:09:22 -0800
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2022-12-15 13:04:33 -0800
commite51d6c5f2e5105669812667c49a053d0f38af6b5 (patch)
treeab0b76ed4666682945377bee72cba0df4761c91f
parent7b8c87ccc2480deafa8483e125eae742d289116f (diff)
downloadbluez-e51d6c5f2e5105669812667c49a053d0f38af6b5.tar.gz
client/player: Use bt_shell_echo to print transfer progress
This uses bt_shell_echo to print transfer progress.
-rw-r--r--client/player.c12
-rw-r--r--src/shared/shell.c10
2 files changed, 9 insertions, 13 deletions
diff --git a/client/player.c b/client/player.c
index 1f10387f8..e73ed6ac9 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 3c0e61dbc..3358b383e 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();