Commit 7f77e61f authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Solved render pause problem, however, it will require a VLC patch

(coming soon :p )
parent 4182597e
......@@ -32,7 +32,7 @@ Instance::Instance()
{
char const *argv[] =
{
"-vvvvv",
// "-vvvvv",
"--no-skip-frames",
// "--intf", "dummy",
//"--no-audio",
......
......@@ -74,9 +74,11 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev
switch ( event->type )
{
case libvlc_MediaPlayerPlaying:
// qDebug() << "Media player playing";
self->emit playing();
break;
case libvlc_MediaPlayerPaused:
// qDebug() << "Media player paused";
self->emit paused();
break;
case libvlc_MediaPlayerStopped:
......
......@@ -70,6 +70,7 @@ void ClipWorkflow::checkStateChange()
QWriteLocker lock2( m_stateLock );
if ( m_requiredState != ClipWorkflow::None )
{
// qDebug() << "Changed state from" << m_state << "to state" << m_requiredState;
m_state = m_requiredState;
m_requiredState = ClipWorkflow::None;
}
......@@ -86,7 +87,7 @@ void ClipWorkflow::lock( ClipWorkflow* cw, void** pp_ret )
// else
// {
*pp_ret = cw->m_buffer;
qDebug() << "Clip workflow locking";
// qDebug() << "Clip workflow locking";
// }
}
......@@ -100,9 +101,10 @@ void ClipWorkflow::unlock( ClipWorkflow* cw )
cw->m_stateLock->unlock();
QMutexLocker lock( cw->m_condMutex );
qDebug() << "Entering condwait";
// qDebug() << "Entering condwait";
cw->m_waitCond->wait( cw->m_condMutex );
qDebug() << "Leaved condwait";
// qDebug() << "Leaved condwait";
cw->m_stateLock->lockForWrite();
cw->m_state = Rendering;
// {
......@@ -110,7 +112,6 @@ void ClipWorkflow::unlock( ClipWorkflow* cw )
// cw->m_usingBackBuffer = !cw->m_usingBackBuffer;
// }
}
qDebug() << "Clip Workflow unlocking";
cw->m_stateLock->unlock();
cw->checkStateChange();
}
......@@ -271,15 +272,17 @@ void ClipWorkflow::reinitialize()
void ClipWorkflow::pause()
{
qDebug() << "Clip workflow is pausing";
m_mediaPlayer->pause();
setState( Paused );
QMutexLocker lock( m_requiredStateLock );
m_requiredState = ClipWorkflow::None;
}
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 );
QMutexLocker lock( m_requiredStateLock );
m_requiredState = ClipWorkflow::None;
}
......@@ -50,6 +50,7 @@ class ClipWorkflow : public QObject
Ready,
Rendering,
Sleeping,
Pausing,
Paused,
Stopping,
EndReached,
......
......@@ -276,6 +276,48 @@ unsigned char* TrackWorkflow::getOutput( qint64 currentFrame )
return ret;
}
void TrackWorkflow::pauseClipWorkflow( ClipWorkflow* cw )
{
cw->getStateLock()->lockForRead();
if ( cw->getState() == ClipWorkflow::Sleeping ||
cw->getState() == ClipWorkflow::Ready ||
cw->getState() == ClipWorkflow::EndReached )
{
cw->getStateLock()->unlock();
cw->queryStateChange( ClipWorkflow::Pausing );
cw->wake();
}
else if ( cw->getState() == ClipWorkflow::Rendering )
{
cw->getStateLock()->unlock();
while ( cw->isRendering() == true )
SleepMS( 1 );
cw->queryStateChange( ClipWorkflow::Pausing );
cw->wake();
}
else if ( cw->getState() == ClipWorkflow::Initializing )
{
cw->getStateLock()->unlock();
while ( cw->isReady() == false )
SleepMS( 1 );
}
else
{
// qDebug() << "Unexpected ClipWorkflow::State when pausing:" << cw->getState();
cw->getStateLock()->unlock();
}
bool pausing = false;
while ( pausing == false )
{
cw->getStateLock()->lockForRead();
pausing = ( cw->getState() == ClipWorkflow::Pausing );
SleepMS( 1 );
cw->getStateLock()->unlock();
}
cw->pause();
}
void TrackWorkflow::pause()
{
QReadLocker lock( m_clipsLock );
......@@ -287,25 +329,10 @@ void TrackWorkflow::pause()
{
ClipWorkflow* cw = it.value();
//TODO: try to do this with the State
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();
pauseClipWorkflow( cw );
}
else
{
......@@ -317,13 +344,11 @@ void TrackWorkflow::pause()
}
else
{
qDebug() << "State when unpausing is (wierdly) ==" << cw->getState();
cw->getStateLock()->unlock();
}
}
++it;
}
qDebug() << "End of loop";
m_paused = !m_paused;
}
......
......@@ -67,6 +67,7 @@ class TrackWorkflow : public QObject
qint64 start, bool needRepositioning );
void preloadClip( ClipWorkflow* cw );
void stopClipWorkflow( ClipWorkflow* cw );
void pauseClipWorkflow( ClipWorkflow* cw );
bool checkEnd( qint64 currentFrame ) const;
private:
......
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