Commit 4182597e authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Started project render preview pausing debugging.

parent cdb7ab4b
......@@ -32,8 +32,9 @@ Instance::Instance()
{
char const *argv[] =
{
// "-vvvvv",
"-vvvvv",
"--no-skip-frames",
// "--intf", "dummy",
//"--no-audio",
//"--plugin-path", VLC_TREE "/modules",
"--disable-screensaver",
......
......@@ -86,6 +86,7 @@ void ClipWorkflow::lock( ClipWorkflow* cw, void** pp_ret )
// else
// {
*pp_ret = cw->m_buffer;
qDebug() << "Clip workflow locking";
// }
}
......@@ -99,7 +100,9 @@ void ClipWorkflow::unlock( ClipWorkflow* cw )
cw->m_stateLock->unlock();
QMutexLocker lock( cw->m_condMutex );
qDebug() << "Entering condwait";
cw->m_waitCond->wait( cw->m_condMutex );
qDebug() << "Leaved condwait";
cw->m_stateLock->lockForWrite();
cw->m_state = Rendering;
// {
......@@ -107,6 +110,7 @@ void ClipWorkflow::unlock( ClipWorkflow* cw )
// cw->m_usingBackBuffer = !cw->m_usingBackBuffer;
// }
}
qDebug() << "Clip Workflow unlocking";
cw->m_stateLock->unlock();
cw->checkStateChange();
}
......@@ -264,3 +268,18 @@ void ClipWorkflow::reinitialize()
m_state = Stopped;
queryStateChange( None );
}
void ClipWorkflow::pause()
{
qDebug() << "Clip workflow is pausing";
m_mediaPlayer->pause();
setState( Paused );
}
void ClipWorkflow::unpause()
{
qDebug() << "Unpausing clipworkflow";
//Since VLC will detect that the media player is paused and unpause it, we can do this safely
m_mediaPlayer->pause();
setState( ClipWorkflow::Rendering );
}
......@@ -50,6 +50,7 @@ class ClipWorkflow : public QObject
Ready,
Rendering,
Sleeping,
Paused,
Stopping,
EndReached,
};
......@@ -84,7 +85,7 @@ class ClipWorkflow : public QObject
bool isStopped() const;
/**
* Return true ONLY if the state is equal to Stopped.
* Return true ONLY if the state is equal to Rendering.
* In any other cases, this will return false.
*/
bool isRendering() const;
......@@ -114,6 +115,7 @@ class ClipWorkflow : public QObject
\brief Stop this workflow.
*/
void stop();
void pause();
void setPosition( float pos );
/**
......@@ -142,6 +144,8 @@ class ClipWorkflow : public QObject
*/
void reinitialize();
void unpause();
private:
static void lock( ClipWorkflow* clipWorkflow, void** pp_ret );
static void unlock( ClipWorkflow* clipWorkflow );
......
......@@ -113,6 +113,15 @@ unsigned char* MainWorkflow::getOutput()
return MainWorkflow::blackOutput;
}
void MainWorkflow::pause()
{
for ( unsigned int i = 0; i < m_trackCount; ++i )
{
if ( m_tracks[i].activated() == true )
m_tracks[i]->pause();
}
}
void MainWorkflow::nextFrame()
{
++m_currentFrame;
......
......@@ -65,6 +65,11 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
*/
void stop();
/**
* Pause the main workflow and all its sub-workflows
*/
void pause();
static unsigned char* blackOutput;
void nextFrame();
void previousFrame();
......
......@@ -28,7 +28,8 @@
TrackWorkflow::TrackWorkflow( unsigned int trackId ) :
m_trackId( trackId ),
m_length( 0 ),
m_forceRepositionning( false )
m_forceRepositionning( false ),
m_paused( false )
{
m_forceRepositionningMutex = new QMutex;
m_clipsLock = new QReadWriteLock;
......@@ -275,6 +276,57 @@ unsigned char* TrackWorkflow::getOutput( qint64 currentFrame )
return ret;
}
void TrackWorkflow::pause()
{
QReadLocker lock( m_clipsLock );
QMap<qint64, ClipWorkflow*>::iterator it = m_clips.begin();
QMap<qint64, ClipWorkflow*>::iterator end = m_clips.end();
while ( it != end )
{
ClipWorkflow* cw = it.value();
if ( m_paused == false )
{
cw->getStateLock()->lockForRead();
if ( cw->getState() != ClipWorkflow::Sleeping &&
cw->getState() != ClipWorkflow::Rendering )
{
qDebug() << "State when pausing ==" << cw->getState();
cw->getStateLock()->unlock();
++it;
continue ; //No need to pause if nothing is happening
}
if ( cw->getState() == ClipWorkflow::Sleeping )
{
cw->getStateLock()->unlock();
cw->wake();
}
else
cw->getStateLock()->unlock();
cw->pause();
}
else
{
cw->getStateLock()->lockForRead();
if ( cw->getState() == ClipWorkflow::Paused )
{
cw->getStateLock()->unlock();
cw->unpause();
}
else
{
qDebug() << "State when unpausing is (wierdly) ==" << cw->getState();
cw->getStateLock()->unlock();
}
}
++it;
}
qDebug() << "End of loop";
m_paused = !m_paused;
}
void TrackWorkflow::moveClip( const QUuid& id, qint64 startingFrame )
{
QWriteLocker lock( m_clipsLock );
......
......@@ -52,6 +52,7 @@ class TrackWorkflow : public QObject
unsigned char* getOutput( qint64 currentFrame );
qint64 getLength() const;
void stop();
void pause();
void moveClip( const QUuid& id, qint64 startingFrame );
Clip* removeClip( const QUuid& id );
void addClip( Clip*, qint64 start );
......@@ -86,6 +87,8 @@ class TrackWorkflow : public QObject
QMutex* m_forceRepositionningMutex;
QReadWriteLock* m_clipsLock;
bool m_paused;
signals:
void trackEndReached( unsigned int );
};
......
......@@ -52,6 +52,11 @@ RenderPreviewWidget::RenderPreviewWidget( MainWorkflow* mainWorkflow, QWidget* r
m_media->addOption( buffer );
sprintf( buffer, ":invmem-data=%lld", (qint64)this );
m_media->addOption( buffer );
sprintf( buffer, ":width=%i", VIDEOWIDTH );
m_media->addOption( buffer );
sprintf( buffer, ":height=%i", VIDEOHEIGHT );
m_media->addOption( buffer );
m_mediaPlayer->setMedia( m_media );
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( __videoPlaying() ) );
......@@ -149,6 +154,8 @@ void RenderPreviewWidget::togglePlayPause( bool forcePause )
if ( m_paused == true && forcePause == false )
{
m_mediaPlayer->play();
//This will automaticly unpause... no worries
m_mainWorkflow->pause();
m_paused = false;
}
else
......@@ -158,6 +165,7 @@ void RenderPreviewWidget::togglePlayPause( bool forcePause )
if ( m_paused == false )
{
m_mediaPlayer->pause();
m_mainWorkflow->pause();
m_paused = true;
}
}
......
......@@ -41,7 +41,7 @@ TracksView::TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidg
m_tracksHeight = 25;
m_tracksCount = mainWorkflow->getTrackCount();
m_fps = 30;
m_fps = FPS;
m_numAudioTrack = 0;
m_numVideoTrack = 0;
......
......@@ -107,6 +107,11 @@ INCLUDEPATH += src/LibVLCpp \
src/gui \
src/tools \
src
# QMAKE_CFLAGS+=-pg
# QMAKE_CXXFLAGS+=-pg
# QMAKE_LFLAGS+=-pg
LIBS = -L/usr/local/lib \
-lvlc
SUBDIRS += modules
......
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