Commit e5f4dd37 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Still propagating clipworkflow refactoring.

Removing synchronisation stuff that is no longer needed.
parent a573e87d
......@@ -109,19 +109,13 @@ void TrackHandler::getOutput( qint64 currentFrame )
m_tmpAudioBuffer = NULL;
for ( unsigned int i = 0; i < m_trackCount; ++i )
{
if ( m_tracks[i].activated() == false )
if ( m_trackType == MainWorkflow::VideoTrack )
{
if ( m_tracks[i].hardDeactivated() == true )
{
++m_nbTracksToRender;
m_tracks[i]->simulateBlackOutputRender();
}
else
if ( m_tracks[i].activated() == false )
m_effectEngine->setInputFrame( *TrackHandler::nullOutput, i );
continue ;
else
m_effectEngine->setInputFrame( m_tracks[i]->getOutput( currentFrame ), i );
}
++m_nbTracksToRender;
m_tracks[i]->getOutput( currentFrame );
}
}
......@@ -310,7 +304,7 @@ void TrackHandler::tracksRenderCompleted( unsigned int trackId )
}
else
{
AudioClipWorkflow::AudioSample* buff = reinterpret_cast<AudioClipWorkflow::AudioSample*>( m_tracks[trackId]->getSynchroneOutput() );
AudioClipWorkflow::AudioSample* buff = reinterpret_cast<AudioClipWorkflow::AudioSample*>( m_tracks[trackId]->getOutput() );
m_tmpAudioBuffer = buff;
}
}
......
......@@ -83,8 +83,6 @@ class TrackHandler : public QObject
MainWorkflow::TrackType m_trackType;
qint64 m_length;
unsigned int m_highestTrackNumber;
unsigned int m_nbTracksToRender;
QMutex* m_nbTracksToRenderMutex;
bool m_paused;
bool m_endReached;
/**
......
......@@ -126,7 +126,7 @@ Clip* TrackWorkflow::getClip( const QUuid& uuid )
return NULL;
}
void TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
void* TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
qint64 start , bool needRepositioning )
{
cw->getStateLock()->lockForRead();
......@@ -137,6 +137,7 @@ void TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
cw->getStateLock()->unlock();
if ( needRepositioning == true )
adjustClipTime( currentFrame, start, cw );
return cw->getOutput( ClipWorkflow::Pop );
}
else if ( cw->getState() == ClipWorkflow::Stopped )
{
......@@ -146,20 +147,19 @@ void TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
{
adjustClipTime( currentFrame, start, cw );
}
//FIXME: comment this part ?!
if ( m_paused == true )
clipWorkflowRenderCompleted( cw );
cw->waitForCompleteInit();
return cw->getOutput( ClipWorkflow::Pop );
}
else if ( cw->getState() == ClipWorkflow::EndReached )
{
cw->getStateLock()->unlock();
clipWorkflowRenderCompleted( cw );
//The stopClipWorkflow() method will take care of that.
}
else
{
cw->getStateLock()->unlock();
}
return NULL;
}
void TrackWorkflow::preloadClip( ClipWorkflow* cw )
......@@ -221,14 +221,14 @@ void TrackWorkflow::stop()
m_lastFrame = 0;
}
bool TrackWorkflow::getOutput( qint64 currentFrame )
void* TrackWorkflow::getOutput( qint64 currentFrame )
{
QReadLocker lock( m_clipsLock );
QMap<qint64, ClipWorkflow*>::iterator it = m_clips.begin();
QMap<qint64, ClipWorkflow*>::iterator end = m_clips.end();
bool needRepositioning;
bool hasRendered = false;
void* ret = NULL;
if ( checkEnd( currentFrame ) == true )
{
......@@ -247,7 +247,6 @@ bool TrackWorkflow::getOutput( qint64 currentFrame )
else
needRepositioning = ( abs( currentFrame - m_lastFrame ) > 1 ) ? true : false;
}
m_nbClipToRender = 0;
while ( it != end )
{
......@@ -257,9 +256,9 @@ bool TrackWorkflow::getOutput( qint64 currentFrame )
// qDebug() << "Start:" << start << "Current Frame:" << currentFrame;
if ( start <= currentFrame && currentFrame <= start + cw->getClip()->getLength() )
{
m_nbClipToRender.fetchAndAddAcquire( 1 );
renderClip( cw, currentFrame, start, needRepositioning );
hasRendered = true;
if ( ret != NULL )
qCritical() << "There's more than one clip to render here. Undefined behaviour !";
ret = renderClip( cw, currentFrame, start, needRepositioning );
}
//Is it about to be rendered ?
else if ( start > currentFrame &&
......@@ -275,12 +274,8 @@ bool TrackWorkflow::getOutput( qint64 currentFrame )
++it;
}
if ( hasRendered == false )
{
clipWorkflowRenderCompleted( NULL );
}
m_lastFrame = currentFrame;
return hasRendered;
return ret;
}
void TrackWorkflow::pause()
......@@ -363,34 +358,6 @@ ClipWorkflow* TrackWorkflow::removeClipWorkflow( const QUuid& id )
return NULL;
}
void TrackWorkflow::clipWorkflowRenderCompleted( ClipWorkflow* cw )
{
// qDebug() << "Clip [" << QObject::sender() << "] render is completed on track" << m_trackId;
if ( cw != NULL )
{
m_synchroneRenderBuffer = cw->getOutput( ClipWorkflow::Pop );
}
else
{
m_synchroneRenderBuffer = NULL;
}
m_nbClipToRender.fetchAndAddAcquire( -1 );
//When there is nothing to render, m_nbClipToRender will be equal to one here, so we check for minus
//or equal to 0
if ( m_nbClipToRender <= 0 )
{
// qDebug() << "Track render completed";
emit renderCompleted( m_trackId );
}
// else
// qDebug() << "Track render not completed yet";
}
void* TrackWorkflow::getSynchroneOutput()
{
return m_synchroneRenderBuffer;
}
void TrackWorkflow::unpause()
{
m_paused = false;
......@@ -482,8 +449,3 @@ void TrackWorkflow::forceRepositionning()
QMutexLocker lock( m_forceRepositionningMutex );
m_forceRepositionning = true;
}
void TrackWorkflow::simulateBlackOutputRender()
{
clipWorkflowRenderCompleted( NULL );
}
......@@ -52,7 +52,7 @@ class TrackWorkflow : public QObject
TrackWorkflow( unsigned int trackId, MainWorkflow::TrackType type );
~TrackWorkflow();
bool getOutput( qint64 currentFrame );
void* getOutput( qint64 currentFrame );
qint64 getLength() const;
void stop();
void pause();
......@@ -65,11 +65,6 @@ class TrackWorkflow : public QObject
qint64 getClipPosition( const QUuid& uuid ) const;
Clip* getClip( const QUuid& uuid );
/**
* Returns the output that has been computed in synchrone mode.
*/
void* getSynchroneOutput();
//FIXME: this won't be reliable as soon as we change the fps from the configuration
static const unsigned int nbFrameBeforePreload = 60;
......@@ -78,12 +73,6 @@ class TrackWorkflow : public QObject
void forceRepositionning();
/**
* \brief This method is only to simulate a track render, which will render a black output.
* this is meant to render a muted track, though the Qt event loop (QueuedConnection signal)
*/
void simulateBlackOutputRender();
private:
void computeLength();
void renderClip( ClipWorkflow* cw, qint64 currentFrame,
......@@ -116,23 +105,13 @@ class TrackWorkflow : public QObject
bool m_paused;
QAtomicInt m_nbClipToPause;
QAtomicInt m_nbClipToUnpause;
QAtomicInt m_nbClipToRender;
void* m_synchroneRenderBuffer;
void* m_output;
MainWorkflow::TrackType m_trackType;
qint64 m_lastFrame;
private slots:
void clipWorkflowRenderCompleted( ClipWorkflow* );
signals:
void trackEndReached( unsigned int );
void trackPaused();
void trackUnpaused();
void renderCompleted( unsigned int );
};
#endif // TRACKWORKFLOW_H
......@@ -88,6 +88,7 @@ void* VideoClipWorkflow::getOutput( ClipWorkflow::GetMode mode )
{
QMutexLocker lock( m_renderLock );
qWarning() << "poping buffer";
if ( isEndReached() == true )
return NULL;
StackedBuffer<LightVideoFrame*>* buff;
......@@ -105,6 +106,7 @@ void VideoClipWorkflow::lock( VideoClipWorkflow* cw, void** pp_ret, int size
cw->m_renderLock->lock();
LightVideoFrame* lvf = cw->m_availableBuffers.pop();
cw->m_computedBuffers.push_back( lvf );
qWarning() << "feeding video buffer";
*pp_ret = (*(lvf))->frame.octets;
}
......
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