From 37f8bdb0ea1f9a5c6aed9912a31870a1d02d40ec Mon Sep 17 00:00:00 2001 From: bruceperens Date: Tue, 22 Apr 2014 04:51:25 +0000 Subject: [PATCH] Comment on sleep code. git-svn-id: https://svn.code.sf.net/p/freetel/code@1546 01035d8c-6547-0410-b346-abe4f91aad63 --- freedv-server/source/run.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/freedv-server/source/run.cpp b/freedv-server/source/run.cpp index 49e92798..e6b2f5d5 100644 --- a/freedv-server/source/run.cpp +++ b/freedv-server/source/run.cpp @@ -295,9 +295,19 @@ namespace FreeDV { int result = 0; + // Sometimes there are not any poll-capable devices to wake us when + // it's time to transmit the next audio frame. This happens when using + // the testing drivers for both input and output, and during the UnKey + // state. Testing drivers will run faster than the real rate if something + // doesn't limit then. + // + // FIX: Instead of nanosleep(), use a wall-clock sleep that wakes up when + // it is time for the next packet to arrive. This can more easily take + // compute time into account, and can properly time the testing drivers. + // if ( poll_fd_count > poll_fd_base ) result = IODevice::poll(poll_fds, poll_fd_count, 1000); - else { + else if ( state != UnKey ) { struct timespec request; request.tv_sec = 0; request.tv_nsec = AudioFrameDuration * 100000; -- 2.25.1