X-Git-Url: https://code.octet-stream.net/m17rt/blobdiff_plain/608ca7e33ab51d812607ddcc3429bfa9aa3c34b0..3903e719137aba15d30dd58b8d917965ec602400:/m17app/src/soundmodem.rs?ds=inline diff --git a/m17app/src/soundmodem.rs b/m17app/src/soundmodem.rs index 974fd45..391bfad 100644 --- a/m17app/src/soundmodem.rs +++ b/m17app/src/soundmodem.rs @@ -138,8 +138,12 @@ fn spawn_soundmodem_worker( let mut ptt = false; while let Ok(ev) = event_rx.recv() { // Update clock on TNC before we do anything - let sample_time = (start.elapsed().as_nanos() / 48000) as u64; - tnc.set_now(sample_time); + let sample_time = start.elapsed(); + let secs = sample_time.as_secs(); + let nanos = sample_time.subsec_nanos(); + // Accurate to within approx 1 sample + let now_samples = 48000 * secs + (nanos as u64 / 20833); + tnc.set_now(now_samples); // Handle event match ev {