From 283abdf46507ff4ae9e17aabf99beec86ec992fb Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 15 Apr 2025 11:30:03 -0400 Subject: [PATCH] MT#55283 convert mix_buffer to int64_t Change-Id: I13343b4cce82440e9a54fd9c26731f27abe57ba5 --- lib/mix_buffer.c | 8 ++++---- lib/mix_buffer.h | 4 ++-- t/test-mix-buffer.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/mix_buffer.c b/lib/mix_buffer.c index 89c4ce4cf..66fa33ad1 100644 --- a/lib/mix_buffer.c +++ b/lib/mix_buffer.c @@ -250,11 +250,11 @@ static void mix_buffer_src_init_pos(struct mix_buffer *mb, mix_buffer_ssrc_sourc static void mix_buff_src_shift_delay(struct mix_buffer *mb, mix_buffer_ssrc_source *src, - const struct timeval last, const struct timeval now) + const int64_t last, const int64_t now) { - if (!last.tv_sec || !now.tv_sec) + if (!last || !now) return; - int64_t diff_us = timeval_diff(now, last); + int64_t diff_us = now - last; if (diff_us <= 0) return; unsigned int samples = mb->clockrate * diff_us / 1000000; @@ -265,7 +265,7 @@ static void mix_buff_src_shift_delay(struct mix_buffer *mb, mix_buffer_ssrc_sour // takes the difference between two time stamps into account, scaled to the given clock rate, // to add an additional write-delay for a newly created source bool mix_buffer_write_delay(struct mix_buffer *mb, uint32_t ssrc, const void *buf, unsigned int samples, - const struct timeval last, const struct timeval now) + const int64_t last, const int64_t now) { LOCK(&mb->lock); diff --git a/lib/mix_buffer.h b/lib/mix_buffer.h index 202bc5b6d..72e207543 100644 --- a/lib/mix_buffer.h +++ b/lib/mix_buffer.h @@ -72,10 +72,10 @@ void mix_buffer_destroy(struct mix_buffer *); void *mix_buffer_read_fast(struct mix_buffer *, unsigned int samples, unsigned int *size); void mix_buffer_read_slow(struct mix_buffer *, void *outbuf, unsigned int samples); bool mix_buffer_write_delay(struct mix_buffer *, uint32_t ssrc, const void *buf, unsigned int samples, - const struct timeval, const struct timeval); + const int64_t, const int64_t); INLINE bool mix_buffer_write(struct mix_buffer *mb, uint32_t ssrc, const void *buf, unsigned int samples) { - return mix_buffer_write_delay(mb, ssrc, buf, samples, (struct timeval) {0,0}, (struct timeval) {0,0}); + return mix_buffer_write_delay(mb, ssrc, buf, samples, 0, 0); } diff --git a/t/test-mix-buffer.c b/t/test-mix-buffer.c index 6bfa3faf3..0f405d17f 100644 --- a/t/test-mix-buffer.c +++ b/t/test-mix-buffer.c @@ -487,8 +487,8 @@ int main(void) { // caught up now. add new source with extra delay: // 10 ms constant, 15 ms extra = 25 ms total = 12.5 sampes (12) - struct timeval last = { 100, 200 }; - struct timeval now = { 100, 15200 }; + int64_t last = 100 * 1000000LL + 200; + int64_t now = 100 * 1000000LL + 15200; ret = mix_buffer_write_delay(&mb, 0x3333, (int16_t[]){11,22,33,44,55}, 5, last, now); assert(ret == true);