qmlfrontend/runqueue.cpp
author sheepluva
Sat, 06 Jan 2018 03:17:12 +0100
branchqmlfrontend
changeset 12882 bf58f2403953
parent 12861 488782d9aba9
permissions -rw-r--r--
whoops, I ruined the path of the unC0Rr

#include "runqueue.h"

#include "flib.h"

extern "C" {
extern RunEngine_t* flibRunEngine;
extern ipcToEngineRaw_t* flibIpcToEngineRaw;
extern ipcSetEngineBarrier_t* flibIpcSetEngineBarrier;
extern ipcRemoveBarrierFromEngineQueue_t* flibIpcRemoveBarrierFromEngineQueue;
}

RunQueue::RunQueue(QObject* parent)
    : QObject(parent)
{
}

void RunQueue::queue(const GameConfig& config)
{
    m_runQueue.prepend(config);

    flibIpcSetEngineBarrier();
    for (const QByteArray& b : m_runQueue.last().config()) {
        flibIpcToEngineRaw(b.data(), b.size());
    }

    if (m_runQueue.size() == 1)
        nextRun();
}

void RunQueue::onGameFinished()
{
    m_runQueue.pop_front();

    nextRun();
}

void RunQueue::nextRun()
{
    if (!m_runQueue.isEmpty()) {
        if (m_runQueue[0].isPreview())
            emit previewIsRendering();

        flibIpcRemoveBarrierFromEngineQueue();

        flibRunEngine(m_runQueue[0].argc(), m_runQueue[0].argv());
    }
}