client/player: Use bt_shell_echo to print transfer progress
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 14 Dec 2022 00:09:22 +0000 (16:09 -0800)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 5 Jan 2024 10:11:34 +0000 (15:41 +0530)
This uses bt_shell_echo to print transfer progress.

client/player.c
src/shared/shell.c

index fd67876..4820702 100644 (file)
@@ -2999,11 +2999,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)",
@@ -3377,7 +3377,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]);
@@ -3399,13 +3398,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);
index 0d54d70..cf52944 100644 (file)
@@ -579,15 +579,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();