MT#55283 convert mix_buffer to int64_t

Change-Id: I13343b4cce82440e9a54fd9c26731f27abe57ba5
pull/1855/merge
Richard Fuchs 2 weeks ago
parent 358723e1c2
commit 283abdf465

@ -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);

@ -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);
}

@ -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);

Loading…
Cancel
Save