From 5488641c58da2fe196612eaf35af3534b62867f7 Mon Sep 17 00:00:00 2001 From: FRIGN Date: Sun, 5 Oct 2014 21:01:50 +0200 Subject: Fix timing issue I don't know why I missed that 1) of course we have to check tv_sec, not tv_nsec 2) when we do a nanosleep, but use the "now"-val for the lastsent- time, we obviously keep the wrong time. This leads to the program thinking more time elapsed than really has, leading to less nanosleep and thus higher playback-speed. Now this is fixed, and apart from state-transition issues, call-receiving now works perfectly. ;) --- ratox.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ratox.c') diff --git a/ratox.c b/ratox.c index b57b2a0..4d31fb6 100644 --- a/ratox.c +++ b/ratox.c @@ -600,11 +600,11 @@ sendfriendcalldata(struct friend *f) clock_gettime(CLOCK_MONOTONIC, &now); diff = timediff(f->av.lastsent, now); - if (diff.tv_nsec == 0 && diff.tv_nsec < toxavconfig.audio_frame_duration * 1E6) { + if (diff.tv_sec == 0 && diff.tv_nsec < toxavconfig.audio_frame_duration * 1E6) { diff.tv_nsec = toxavconfig.audio_frame_duration * 1E6 - diff.tv_nsec; nanosleep(&diff, NULL); } - f->av.lastsent = now; + clock_gettime(CLOCK_MONOTONIC, &f->av.lastsent); toxav_send_audio(toxav, f->av.num, f->av.payload, payloadsize); } -- cgit v1.2.3