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

Removing old and ugly flags from TrackWorkflow

parent 5e048989
......@@ -32,6 +32,9 @@ struct libvlc_instance_t;
namespace LibVLCpp
{
/**
* \warning This class should be released after every other LibVLCpp classes.
*/
class Instance : public QObject,
public Internal< libvlc_instance_t >,
public QSingleton<Instance>
......
......@@ -293,3 +293,20 @@ ClipWorkflow::unmute()
{
setState( Stopped );
}
void
ClipWorkflow::requireResync()
{
m_resyncRequired = 1;
}
bool
ClipWorkflow::isResyncRequired()
{
if ( m_resyncRequired == 1 )
{
m_resyncRequired = 0;
return true;
}
return false;
}
......@@ -174,6 +174,15 @@ class ClipWorkflow : public QObject
void mute();
void unmute();
void requireResync();
/**
* \return true if a resync is required.
*
* If a resync is required, true will be returned, and the flag will be
* set back to false
*/
bool isResyncRequired();
private:
void setState( State state );
void adjustBegin();
......@@ -198,6 +207,13 @@ class ClipWorkflow : public QObject
private:
WaitCondition* m_initWaitCond;
WaitCondition* m_pausingStateWaitCond;
/**
* \brief Used by the trackworkflow to query a clipworkflow resync.
*
* Basically, this will be used when a clip is moved, and therefore has to be
* updated.
*/
QAtomicInt m_resyncRequired;
protected:
LibVLCpp::MediaPlayer* m_mediaPlayer;
......
......@@ -200,14 +200,8 @@ TrackHandler::moveClip(const QUuid &clipUuid, unsigned int oldTrack,
}
else
{
bool needRepo;
if ( m_tracks[oldTrack]->getClipPosition( clipUuid ) != startingFrame )
needRepo = true;
ClipWorkflow* cw = m_tracks[oldTrack]->removeClipWorkflow( clipUuid );
m_tracks[newTrack]->addClip( cw, startingFrame );
if ( needRepo == true )
m_tracks[newTrack]->forceRepositionning();
activateTrack( oldTrack );
activateTrack( newTrack );
}
......
......@@ -36,13 +36,11 @@
TrackWorkflow::TrackWorkflow( unsigned int trackId, MainWorkflow::TrackType type ) :
m_trackId( trackId ),
m_length( 0 ),
m_forceRepositionning( false ),
m_trackType( type ),
m_lastFrame( 0 ),
m_videoStackedBuffer( NULL ),
m_audioStackedBuffer( NULL )
{
m_forceRepositionningMutex = new QMutex;
m_renderOneFrameMutex = new QMutex;
m_clipsLock = new QReadWriteLock;
}
......@@ -60,7 +58,6 @@ TrackWorkflow::~TrackWorkflow()
}
delete m_clipsLock;
delete m_renderOneFrameMutex;
delete m_forceRepositionningMutex;
}
void TrackWorkflow::addClip( Clip* clip, qint64 start )
......@@ -146,10 +143,9 @@ TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
cw->getState() == ClipWorkflow::UnpauseRequired )
{
cw->getStateLock()->unlock();
if ( needRepositioning == true )
{
if ( cw->isResyncRequired() == true || needRepositioning == true )
adjustClipTime( currentFrame, start, cw );
}
return cw->getOutput( mode );
}
else if ( cw->getState() == ClipWorkflow::Stopped )
......@@ -273,19 +269,13 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
}
}
{
QMutexLocker lock2( m_forceRepositionningMutex );
if ( m_forceRepositionning == true )
{
needRepositioning = true;
m_forceRepositionning = false;
}
// This is a bit hackish : when we want to pop a frame in renderOneFrame mode,
// we also set the position to avoid the stream to be missynchronized.
// this frame setting will most likely toggle the next condition as true
// If this condition is true, the clipworkflow will flush all its buffer
// as we need to resynchronize after a setTime, so this condition has to remain
// false. Easy ain't it ?
else if ( paused == true && subFrame != m_lastFrame && renderOneFrame == false)
if ( paused == true && subFrame != m_lastFrame && renderOneFrame == false)
needRepositioning = true;
else
needRepositioning = ( abs( subFrame - m_lastFrame ) > 1 ) ? true : false;
......@@ -335,8 +325,7 @@ void TrackWorkflow::moveClip( const QUuid& id, qint64 startingFrame )
ClipWorkflow* cw = it.value();
m_clips.erase( it );
m_clips[startingFrame] = cw;
QMutexLocker lock( m_forceRepositionningMutex );
m_forceRepositionning = true;
cw->requireResync();
computeLength();
return ;
}
......@@ -470,12 +459,6 @@ void TrackWorkflow::adjustClipTime( qint64 currentFrame, qint64 start, ClipWo
cw->setTime( startFrame );
}
void TrackWorkflow::forceRepositionning()
{
QMutexLocker lock( m_forceRepositionningMutex );
m_forceRepositionning = true;
}
void
TrackWorkflow::renderOneFrame()
{
......
......@@ -76,7 +76,6 @@ class TrackWorkflow : public QObject
void save( QDomDocument& doc, QDomElement& trackNode ) const;
void clear();
void forceRepositionning();
void renderOneFrame();
/**
......@@ -115,12 +114,6 @@ class TrackWorkflow : public QObject
*/
qint64 m_length;
/**
* \brief If a clip was moved, we may have to force repositionning.
* If this flag is set to true, we will force it anyway.
*/
bool m_forceRepositionning;
QMutex* m_forceRepositionningMutex;
bool m_renderOneFrame;
QMutex *m_renderOneFrameMutex;
......
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