3
0
Fork 0
mirror of https://github.com/lubosz/overte.git synced 2025-04-26 11:15:23 +02:00

split sleep timing from check time timing

This commit is contained in:
Stephen Birarda 2018-09-05 16:29:11 -07:00
parent 996e033dee
commit 925c39cbd3
2 changed files with 12 additions and 5 deletions
assignment-client/src/audio

View file

@ -283,6 +283,7 @@ void AudioMixer::sendStatsPacket() {
};
addTiming(_ticTiming, "tic");
addTiming(_checkTimeTiming, "check_time");
addTiming(_sleepTiming, "sleep");
addTiming(_frameTiming, "frame");
addTiming(_packetsTiming, "packets");
@ -391,7 +392,7 @@ void AudioMixer::start() {
auto ticTimer = _ticTiming.timer();
{
auto timer = _sleepTiming.timer();
auto timer = _checkTimeTiming.timer();
auto frameDuration = timeFrame(frameTimestamp);
throttle(frameDuration, frame);
}
@ -459,10 +460,14 @@ chrono::microseconds AudioMixer::timeFrame(p_high_resolution_clock::time_point&
// set the new frame timestamp
timestamp = max(now, nextTimestamp);
// sleep until the next frame should start
// WIN32 sleep_until is broken until VS2015 Update 2
// instead, max (above) guarantees that timestamp >= now, so we can sleep_for
this_thread::sleep_for(timestamp - now);
{
auto timer = _sleepTiming.timer();
// sleep until the next frame should start
// WIN32 sleep_until is broken until VS2015 Update 2
// instead, max (above) guarantees that timestamp >= now, so we can sleep_for
this_thread::sleep_for(timestamp - now);
}
return duration;
}

View file

@ -125,7 +125,9 @@ private:
uint64_t _history[TIMER_TRAILING_SECONDS] {};
int _index { 0 };
};
Timer _ticTiming;
Timer _checkTimeTiming;
Timer _sleepTiming;
Timer _frameTiming;
Timer _prepareTiming;