@@ -13,7 +13,8 @@ double VisualPlayPosition::m_dCallbackEntryToDacSecs = 0;
13
13
14
14
VisualPlayPosition::VisualPlayPosition (const QString& key)
15
15
: m_valid(false ),
16
- m_key(key) {
16
+ m_key(key),
17
+ m_noTransport(false ) {
17
18
}
18
19
19
20
VisualPlayPosition::~VisualPlayPosition () {
@@ -63,14 +64,31 @@ double VisualPlayPosition::calcOffsetAtNextVSync(
63
64
const int refToVSync = pVSyncThread->fromTimerToNextSyncMicros (data.m_referenceTime );
64
65
const int syncIntervalTimeMicros = pVSyncThread->getSyncIntervalTimeMicros ();
65
66
#endif
66
- // The offset is limited to the audio buffer + waveform sync interval
67
+ // The offset is limited to the audio buffer + 2 x waveform sync interval
67
68
// This should be sufficient to compensate jitter, but does not continue
68
69
// in case of underflows.
69
- const int maxOffset = static_cast <int >(data.m_audioBufferMicroS + syncIntervalTimeMicros);
70
+ const int maxOffset = static_cast <int >(
71
+ data.m_audioBufferMicroS + 2 * syncIntervalTimeMicros);
70
72
// Calculate the offset in micros for the position of the sample that will be transferred
71
73
// to the DAC when the next display frame is displayed
72
- const int offset = math_clamp (
73
- refToVSync - data.m_callbackEntrytoDac , -maxOffset, maxOffset);
74
+ int offset = refToVSync - data.m_callbackEntrytoDac ;
75
+ if (offset < -maxOffset) {
76
+ offset = -maxOffset;
77
+ if (!m_noTransport) {
78
+ qWarning () << " VisualPlayPosition::calcOffsetAtNextVSync"
79
+ << m_key << " no transport (offset < -maxOffset)" ;
80
+ m_noTransport = true ;
81
+ }
82
+ } else if (offset > maxOffset) {
83
+ offset = maxOffset;
84
+ if (!m_noTransport) {
85
+ qWarning () << " VisualPlayPosition::calcOffsetAtNextVSync"
86
+ << m_key << " no transport (offset > maxOffset)" ;
87
+ m_noTransport = true ;
88
+ }
89
+ } else {
90
+ m_noTransport = false ;
91
+ }
74
92
// Apply the offset proportional to m_positionStep
75
93
return data.m_positionStep * static_cast <double >(offset) / data.m_audioBufferMicroS ;
76
94
}
0 commit comments