Skip to content

Commit

Permalink
Don't request a visual playposition for an outdated frame
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Jan 7, 2024
1 parent e4758f2 commit 869e525
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/waveform/vsyncthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void VSyncThread::run() {
//qDebug() << "VSyncThread::run()";
switch (m_vSyncMode) {
case ST_FREE:
m_waitToSwapMicros = 1000;
runFree();
break;
case ST_PLL:
Expand Down Expand Up @@ -65,8 +66,8 @@ void VSyncThread::runFree() {
m_semaVsyncSlot.acquire();

m_sinceLastSwap = m_timer.restart();
m_waitToSwapMicros = 1000;
usleep(1000);
m_waitToSwapMicros = m_waitToSwapMicros;

Check failure on line 69 in src/waveform/vsyncthread.cpp

View workflow job for this annotation

GitHub Actions / clazy

assigning field to itself [-Werror,-Wself-assign-field]
usleep(m_waitToSwapMicros);
}
}

Expand Down Expand Up @@ -187,6 +188,12 @@ void VSyncThread::setVSyncType(int type) {
int VSyncThread::fromTimerToNextSyncMicros(const PerformanceTimer& timer) {
int difference = static_cast<int>(m_timer.difference(timer).toIntegerMicros());
// int math is fine here, because we do not expect times > 4.2 s
int toNextSync = difference + m_waitToSwapMicros;
while (toNextSync < 0) {
// this function is called during rendering. A negative value indicates
// an attempt to render an outdated frame. Render the next frame instead
toNextSync += m_syncIntervalTimeMicros

Check failure on line 195 in src/waveform/vsyncthread.cpp

View workflow job for this annotation

GitHub Actions / clazy

expected ';' after expression

Check failure on line 195 in src/waveform/vsyncthread.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04 (gcc)

expected ‘;’ before ‘}’ token

Check failure on line 195 in src/waveform/vsyncthread.cpp

View workflow job for this annotation

GitHub Actions / coverage

expected ‘;’ before ‘}’ token
}

Check failure on line 196 in src/waveform/vsyncthread.cpp

View workflow job for this annotation

GitHub Actions / Windows 2019 (MSVC)

syntax error: missing ';' before '}'
return difference + m_waitToSwapMicros;
}

Expand Down

0 comments on commit 869e525

Please sign in to comment.