diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2022-12-14 13:01:07 -0800 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2022-12-15 13:04:45 -0800 |
commit | 318b1a19cb74db768797876ee36f3f9f78fcb5bf (patch) | |
tree | 2d912d1f4e9807aeab1682ebe498a9d778b1c07e /client | |
parent | e51d6c5f2e5105669812667c49a053d0f38af6b5 (diff) | |
download | bluez-318b1a19cb74db768797876ee36f3f9f78fcb5bf.tar.gz |
client/player: Print transport progress
This uses bt_shell_echo to print out the transfer progress on the echo
area.
Diffstat (limited to 'client')
-rw-r--r-- | client/player.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/client/player.c b/client/player.c index e73ed6ac9..6e33274d3 100644 --- a/client/player.c +++ b/client/player.c @@ -25,6 +25,7 @@ #include <sys/uio.h> #include <wordexp.h> #include <sys/timerfd.h> +#include <sys/stat.h> #include <glib.h> @@ -91,6 +92,7 @@ struct transport { uint16_t mtu[2]; char *filename; int fd; + struct stat stat; struct io *io; uint32_t seq; struct io *timer_io; @@ -3379,6 +3381,7 @@ 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 secs = 0, nsecs = 0; + off_t offset; ret = read(fd, buf, transport->mtu[1]); if (ret <= 0) { @@ -3399,10 +3402,19 @@ static int transport_send_seq(struct transport *transport, int fd, uint32_t num) elapsed_time(!transport->seq, &secs, &nsecs); - bt_shell_echo("[seq %d %d.%03ds] send: %zd bytes ", + if (!transport->seq && fstat(fd, &transport->stat) < 0) { + bt_shell_printf("fstat failed: %s (%d)", + strerror(errno), errno); + free(buf); + return -errno; + } + + offset = lseek(fd, 0, SEEK_CUR); + + bt_shell_echo("[seq %d %d.%03ds] send: %zd/%zd bytes", transport->seq, secs, (nsecs + 500000) / 1000000, - ret); + offset, transport->stat.st_size); } free(buf); |