client/player: Fix calculation of number of packet

The calculation shall attempt to round to number of packets to the
closest integer otherwise it can result in 0 packets to be sent at each
latency.
This commit is contained in:
Luiz Augusto von Dentz 2024-04-19 15:59:21 -04:00
parent a08ec1a4e9
commit 92c1c1c366

View File

@ -63,6 +63,7 @@
#define NSEC_USEC(_t) (_t / 1000L)
#define SEC_USEC(_t) (_t * 1000000L)
#define TS_USEC(_ts) (SEC_USEC((_ts)->tv_sec) + NSEC_USEC((_ts)->tv_nsec))
#define ROUND_CLOSEST(_x, _y) (((_x) + (_y / 2)) / (_y))
#define EP_SRC_LOCATIONS 0x00000003
#define EP_SNK_LOCATIONS 0x00000003
@ -5031,8 +5032,9 @@ static bool transport_timer_read(struct io *io, void *user_data)
return false;
}
/* num of packets = latency (ms) / interval (us) */
num = (qos.ucast.out.latency * 1000 / qos.ucast.out.interval);
/* 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);
if (ret < 0) {