Ejemplo n.º 1
0
void WaveformWidgetFactory::startVSync(QWidget *parent) {
    if (m_vsyncThread) {
        disconnect(m_vsyncThread, SIGNAL(vsyncRender()), this, SLOT(render()));
        disconnect(m_vsyncThread, SIGNAL(vsyncSwap()), this, SLOT(swap()));
        delete m_vsyncThread;
    }
    m_vsyncThread = new VSyncThread(parent);
    m_vsyncThread->start();

    connect(m_vsyncThread, SIGNAL(vsyncRender()),
            this, SLOT(render()));
    connect(m_vsyncThread, SIGNAL(vsyncSwap()),
            this, SLOT(swap()));

}
Ejemplo n.º 2
0
void WaveformWidgetFactory::startVSync(MixxxMainWindow* mixxxMainWindow) {
    m_vsyncThread = new VSyncThread(mixxxMainWindow);
    m_vsyncThread->start();

    connect(m_vsyncThread, SIGNAL(vsyncRender()),
            this, SLOT(render()));
    connect(m_vsyncThread, SIGNAL(vsyncSwap()),
            this, SLOT(swap()));
}
Ejemplo n.º 3
0
void WaveformWidgetFactory::startVSync(GuiTick* pGuiTick) {
    m_vsyncThread = new VSyncThread(this, pGuiTick);
    m_vsyncThread->start(QThread::NormalPriority);

    connect(m_vsyncThread, SIGNAL(vsyncRender()),
            this, SLOT(render()));
    connect(m_vsyncThread, SIGNAL(vsyncSwap()),
            this, SLOT(swap()));
}
Ejemplo n.º 4
0
void VSyncThread::run() {
    QThread::currentThread()->setObjectName("VSyncThread");

    int usRemainingForSwap;
    int usLastSwapTime;

    m_usWaitToSwap = m_usSyncIntervalTime;
    m_timer.start();

    while (doRendering) {
        if (m_vSyncMode == ST_FREE) {
            // for benchmark only!
            emit(vsyncRender()); // renders the waveform, Possible delayed due to anti tearing
            m_semaVsyncSlot.acquire();
            emit(vsyncSwap()); // swaps the new waveform to front
            m_semaVsyncSlot.acquire();
            m_timer.restart();
            m_usWaitToSwap = 1000;
            usleep(1000);
        } else { // if (m_vSyncMode == ST_TIMER) {
            emit(vsyncRender()); // renders the new waveform.
            m_semaVsyncSlot.acquire(); // wait until rendering was scheduled. It might be delayed due a pending swap (depends one driver vSync settings)
            // qDebug() << "ST_TIMER                      " << usLast << usRest;
            usRemainingForSwap = m_usWaitToSwap - (int)m_timer.elapsed() / 1000;
            // waiting for interval by sleep
            if (usRemainingForSwap > 100) {
                usleep(usRemainingForSwap);
            }

            emit(vsyncSwap()); // swaps the new waveform to front in case of gl-wf
            m_semaVsyncSlot.acquire(); // wait until swap was scheduled. It might be delayed due to driver vSync settings  
            // <- Assume we are VSynced here ->
            usLastSwapTime = (int)m_timer.restart() / 1000;
            if (usRemainingForSwap < 0) {
                // Our swapping call was already delayed
                // The real swap might happens on the following VSync, depending on driver settings 
                m_rtErrorCnt++; // Count as Real Time Error
            }
            // try to stay in right intervals
            usRemainingForSwap = m_usWaitToSwap - usLastSwapTime;
            m_usWaitToSwap = m_usSyncIntervalTime + (usRemainingForSwap % m_usSyncIntervalTime);
        }
    }
}
Ejemplo n.º 5
0
void VSyncThread::run() {
    Counter droppedFrames("VsyncThread real time error");
    QThread::currentThread()->setObjectName("VSyncThread");

    m_usWaitToSwap = m_usSyncIntervalTime;
    m_timer.start();

    while (m_bDoRendering) {
        if (m_vSyncMode == ST_FREE) {
            // for benchmark only!

            Event::start("VsyncThread vsync render");
            // renders the waveform, Possible delayed due to anti tearing
            emit(vsyncRender());
            m_semaVsyncSlot.acquire();
            Event::end("VsyncThread vsync render");

            Event::start("VsyncThread vsync swap");
            emit(vsyncSwap()); // swaps the new waveform to front
            m_semaVsyncSlot.acquire();
            Event::end("VsyncThread vsync swap");

            m_timer.restart();
            m_usWaitToSwap = 1000;
            usleep(1000);
        } else { // if (m_vSyncMode == ST_TIMER) {

            Event::start("VsyncThread vsync render");
            emit(vsyncRender()); // renders the new waveform.

            // wait until rendering was scheduled. It might be delayed due a
            // pending swap (depends one driver vSync settings)
            m_semaVsyncSlot.acquire();
            Event::end("VsyncThread vsync render");

            // qDebug() << "ST_TIMER                      " << usLast << usRest;
            int usRemainingForSwap = m_usWaitToSwap - (int)m_timer.elapsed() / 1000;
            // waiting for interval by sleep
            if (usRemainingForSwap > 100) {
                Event::start("VsyncThread usleep for VSync");
                usleep(usRemainingForSwap);
                Event::end("VsyncThread usleep for VSync");
            }

            Event::start("VsyncThread vsync swap");
            // swaps the new waveform to front in case of gl-wf
            emit(vsyncSwap());

            // wait until swap occurred. It might be delayed due to driver vSync
            // settings.
            m_semaVsyncSlot.acquire();
            Event::end("VsyncThread vsync swap");

            // <- Assume we are VSynced here ->
            int usLastSwapTime = (int)m_timer.restart() / 1000;
            if (usRemainingForSwap < 0) {
                // Our swapping call was already delayed
                // The real swap might happens on the following VSync, depending on driver settings
                m_droppedFrames++; // Count as Real Time Error
                droppedFrames.increment();
            }
            // try to stay in right intervals
            m_usWaitToSwap = m_usSyncIntervalTime +
                    ((m_usWaitToSwap - usLastSwapTime) % m_usSyncIntervalTime);
        }

        // Qt timers are not that useful in our case, because they
        // are handled with priority without respecting the callback
        m_pGuiTick->process();
    }
}