Commit 68f40c44 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Next frame mode is kind of working, though it sometimes return 2 frames...

parent 7f77e61f
......@@ -48,6 +48,7 @@ MainWorkflow::MainWorkflow( QObject* parent, int trackCount ) :
connect( m_tracks[i], SIGNAL( trackEndReached( unsigned int ) ), this, SLOT( trackEndReached(unsigned int) ) );
}
m_renderStartedLock = new QReadWriteLock;
m_lastRenderedFrame = MainWorkflow::blackOutput;
}
MainWorkflow::~MainWorkflow()
......@@ -91,7 +92,13 @@ void MainWorkflow::startRender()
unsigned char* MainWorkflow::getOutput()
{
QReadLocker lock( m_renderStartedLock );
qDebug() << "New frame asked";
if ( m_renderOnlyOneFrame == 1 && m_lastRenderedFrame != NULL )
{
qDebug() << "Returning last frame";
return m_lastRenderedFrame;
}
if ( m_renderStarted == true )
{
unsigned char* ret;
......@@ -106,11 +113,16 @@ unsigned char* MainWorkflow::getOutput()
if ( ret == NULL )
ret = MainWorkflow::blackOutput;
nextFrame();
if ( m_renderOnlyOneFrame == 0 )
nextFrame();
m_lastRenderedFrame = ret;
return ret;
}
else
{
m_lastRenderedFrame = MainWorkflow::blackOutput;
return MainWorkflow::blackOutput;
}
}
void MainWorkflow::pause()
......@@ -124,6 +136,7 @@ void MainWorkflow::pause()
void MainWorkflow::nextFrame()
{
qDebug() << "Going to next frame";
++m_currentFrame;
//FIXME: This is probably a bit much...
emit frameChanged( m_currentFrame );
......@@ -218,3 +231,9 @@ void MainWorkflow::clipMoved( QUuid clipUuid, int oldTrack, int newTra
m_tracks[newTrack].activate();
}
}
void MainWorkflow::activateOneFrameOnly()
{
m_renderOnlyOneFrame = 1;
// m_lastRenderedFrame = NULL;
}
......@@ -26,6 +26,8 @@
#include <QObject>
#include <QReadWriteLock>
#include <QAtomicInt>
#include <QAtomicPointer>
#include "tools/Toggleable.hpp"
#include "TrackWorkflow.h"
......@@ -73,6 +75,13 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
static unsigned char* blackOutput;
void nextFrame();
void previousFrame();
/**
* \brief By calling this method, you ensure that the MainWorkflow will
* only return one frame to you, until you restore the normal render mode,
* or until you call this method again.
*/
void activateOneFrameOnly();
static MainWorkflow* getInstance();
......@@ -89,6 +98,14 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
bool m_renderStarted;
QReadWriteLock* m_renderStartedLock;
/**
* \brief This will be used in case of next frame, to avoid rendering more than one frame
* at a time
*/
QAtomicPointer<unsigned char> m_lastRenderedFrame;
QAtomicInt m_renderOnlyOneFrame;
public slots:
void clipMoved( QUuid, int, int, qint64 );
......
......@@ -246,7 +246,7 @@ unsigned char* TrackWorkflow::getOutput( qint64 currentFrame )
m_forceRepositionning = false;
}
else
needRepositioning = ( abs( currentFrame - lastFrame ) > 1 ) ? true : false;
needRepositioning = ( currentFrame - lastFrame != 1 ) ? true : false;
}
while ( it != end )
{
......
......@@ -127,7 +127,11 @@ void RenderPreviewWidget::nextFrame()
QWriteLocker lock( m_framePlayedLock );
m_framePlayed = false;
}
//FIXME: MainWorkflow should be paused
m_mainWorkflow->nextFrame();
qDebug() << "Activated one frame only";
m_mainWorkflow->activateOneFrameOnly();
m_mainWorkflow->pause();
m_mediaPlayer->play();
bool framePlayed = false;
while ( framePlayed == false )
......@@ -137,6 +141,7 @@ void RenderPreviewWidget::nextFrame()
framePlayed = m_framePlayed;
}
m_mediaPlayer->pause();
m_mainWorkflow->pause();
}
void RenderPreviewWidget::previousFrame()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment