diff options
author | Daniel Schürmann <daschuer@mixxx.org> | 2019-05-16 00:06:42 +0200 |
---|---|---|
committer | Daniel Schürmann <daschuer@mixxx.org> | 2019-05-16 00:06:42 +0200 |
commit | 9f5b4211e840ae4c48afdd37b58811863ce67fb6 (patch) | |
tree | 8813352726d097b14a616def19b1c0bffa4de738 | |
parent | 2deef1a3c5717d1e22793d14021d3b18801ca999 (diff) |
Dejerk spinnies by vSyncThread as well.
-rw-r--r-- | src/skin/legacyskinparser.cpp | 4 | ||||
-rw-r--r-- | src/waveform/visualplayposition.cpp | 11 | ||||
-rw-r--r-- | src/waveform/visualplayposition.h | 2 | ||||
-rw-r--r-- | src/waveform/waveformwidgetfactory.cpp | 4 | ||||
-rw-r--r-- | src/waveform/waveformwidgetfactory.h | 2 | ||||
-rw-r--r-- | src/widget/wspinny.cpp | 11 | ||||
-rw-r--r-- | src/widget/wspinny.h | 3 |
7 files changed, 19 insertions, 18 deletions
diff --git a/src/skin/legacyskinparser.cpp b/src/skin/legacyskinparser.cpp index 89d8068f8b..fa178ec713 100644 --- a/src/skin/legacyskinparser.cpp +++ b/src/skin/legacyskinparser.cpp @@ -1193,8 +1193,8 @@ QWidget* LegacySkinParser::parseSpinny(const QDomElement& node) { m_pVCManager, pPlayer); commonWidgetSetup(node, spinny); - connect(waveformWidgetFactory, SIGNAL(renderSpinnies()), - spinny, SLOT(render())); + connect(waveformWidgetFactory, SIGNAL(renderSpinnies(VSyncThread*)), + spinny, SLOT(render(VSyncThread*))); connect(waveformWidgetFactory, SIGNAL(swapSpinnies()), spinny, SLOT(swap())); connect(spinny, SIGNAL(trackDropped(QString, QString)), diff --git a/src/waveform/visualplayposition.cpp b/src/waveform/visualplayposition.cpp index bf1e7a43bf..008a7fc61c 100644 --- a/src/waveform/visualplayposition.cpp +++ b/src/waveform/visualplayposition.cpp @@ -50,14 +50,14 @@ void VisualPlayPosition::set(double playPos, double rate, double positionStep, m_valid = true; } -double VisualPlayPosition::getAtNextVSync(VSyncThread* vsyncThread) { +double VisualPlayPosition::getAtNextVSync(VSyncThread* vSyncThread) { //static double testPos = 0; //testPos += 0.000017759; //0.000016608; // 1.46257e-05; //return testPos; if (m_valid) { VisualPlayPositionData data = m_data.getValue(); - int refToVSync = vsyncThread->fromTimerToNextSyncMicros(data.m_referenceTime); + int refToVSync = vSyncThread->fromTimerToNextSyncMicros(data.m_referenceTime); int offset = refToVSync - data.m_callbackEntrytoDac; offset = math_min(offset, m_audioBufferMicros * kMaxOffsetBufferCnt); double playPos = data.m_enginePlayPos; // load playPos for the first sample in Buffer @@ -70,16 +70,15 @@ double VisualPlayPosition::getAtNextVSync(VSyncThread* vsyncThread) { return -1; } -void VisualPlayPosition::getPlaySlipAt(int fromNowMicros, double* pPlayPosition, double* pSlipPosition) { +void VisualPlayPosition::getPlaySlipAtNextVSync(VSyncThread* vSyncThread, double* pPlayPosition, double* pSlipPosition) { //static double testPos = 0; //testPos += 0.000017759; //0.000016608; // 1.46257e-05; //return testPos; if (m_valid) { VisualPlayPositionData data = m_data.getValue(); - int elapsed = data.m_referenceTime.elapsed().toIntegerMicros(); - int dacFromNow = elapsed - data.m_callbackEntrytoDac; - int offset = dacFromNow - fromNowMicros; + int refToVSync = vSyncThread->fromTimerToNextSyncMicros(data.m_referenceTime); + int offset = refToVSync - data.m_callbackEntrytoDac; offset = math_min(offset, m_audioBufferMicros * kMaxOffsetBufferCnt); double playPos = data.m_enginePlayPos; // load playPos for the first sample in Buffer playPos += data.m_positionStep * offset * data.m_rate / m_audioBufferMicros; diff --git a/src/waveform/visualplayposition.h b/src/waveform/visualplayposition.h index 0095a3b57f..badbf6b77e 100644 --- a/src/waveform/visualplayposition.h +++ b/src/waveform/visualplayposition.h @@ -49,7 +49,7 @@ class VisualPlayPosition : public QObject { void set(double playPos, double rate, double positionStep, double slipPosition, double tempoTrackSeconds); double getAtNextVSync(VSyncThread* vsyncThread); - void getPlaySlipAt(int usFromNow, double* playPosition, double* slipPosition); + void getPlaySlipAtNextVSync(VSyncThread* vSyncThread, double* playPosition, double* slipPosition); double getEnginePlayPos(); void getTrackTime(double* pPlayPosition, double* pTempoTrackSeconds); diff --git a/src/waveform/waveformwidgetfactory.cpp b/src/waveform/waveformwidgetfactory.cpp index b13cc608f0..b3f8cb3755 100644 --- a/src/waveform/waveformwidgetfactory.cpp +++ b/src/waveform/waveformwidgetfactory.cpp @@ -107,7 +107,7 @@ WaveformWidgetFactory::WaveformWidgetFactory() : m_openGlesAvailable(false), m_openGLShaderAvailable(false), m_beatGridAlpha(90), - m_vsyncThread(NULL), + m_vsyncThread(nullptr), m_pGuiTick(nullptr), m_pVisualsManager(nullptr), m_frameCnt(0), @@ -628,7 +628,7 @@ void WaveformWidgetFactory::render() { // WSpinnys are also double-buffered QGLWidgets, like all the waveform // renderers. Render all the WSpinny widgets now. - emit(renderSpinnies()); + emit(renderSpinnies(m_vsyncThread)); // Notify all other waveform-like widgets (e.g. WSpinny's) that they should // update. diff --git a/src/waveform/waveformwidgetfactory.h b/src/waveform/waveformwidgetfactory.h index eee7a0c4a8..e2ffef8f9b 100644 --- a/src/waveform/waveformwidgetfactory.h +++ b/src/waveform/waveformwidgetfactory.h @@ -116,7 +116,7 @@ class WaveformWidgetFactory : public QObject, public Singleton<WaveformWidgetFac signals: void waveformUpdateTick(); void waveformMeasured(float frameRate, int droppedFrames); - void renderSpinnies(); + void renderSpinnies(VSyncThread*); void swapSpinnies(); protected: diff --git a/src/widget/wspinny.cpp b/src/widget/wspinny.cpp index 56bd8f1879..ee39401268 100644 --- a/src/widget/wspinny.cpp +++ b/src/widget/wspinny.cpp @@ -301,7 +301,7 @@ void WSpinny::paintEvent(QPaintEvent *e) { Q_UNUSED(e); } -void WSpinny::render() { +void WSpinny::render(VSyncThread* vSyncThread) { if (!isValid() || !isVisible()) { return; } @@ -311,10 +311,11 @@ void WSpinny::render() { return; } - if (!m_pVisualPlayPos.isNull()) { - m_pVisualPlayPos->getPlaySlipAt(0, - &m_dAngleCurrentPlaypos, - &m_dGhostAngleCurrentPlaypos); + if (!m_pVisualPlayPos.isNull() && vSyncThread) { + m_pVisualPlayPos->getPlaySlipAtNextVSync( + vSyncThread, + &m_dAngleCurrentPlaypos, + &m_dGhostAngleCurrentPlaypos); } QPainter p(this); diff --git a/src/widget/wspinny.h b/src/widget/wspinny.h index ada8d92a2f..28c1f33dbd 100644 --- a/src/widget/wspinny.h +++ b/src/widget/wspinny.h @@ -21,6 +21,7 @@ class ControlProxy; class VisualPlayPosition; class VinylControlManager; +class VSyncThread; class WSpinny : public QGLWidget, public WBaseWidget, public VinylSignalQualityListener, public TrackDropTarget { @@ -45,7 +46,7 @@ class WSpinny : public QGLWidget, public WBaseWidget, public VinylSignalQualityL void updateVinylControlEnabled(double enabled); void updateVinylControlSignalEnabled(double enabled); void updateSlipEnabled(double enabled); - void render(); + void render(VSyncThread* vSyncThread); void swap(); protected slots: |