Commit c1221fba authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen
Browse files

Resolved potential synchronisation problem for frame by frame mode

parent 58c91b98
......@@ -86,11 +86,11 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev
{
qDebug() << "Event received" << event->type;
case libvlc_MediaPlayerPlaying:
// qDebug() << "Media player playing";
qDebug() << "Media player playing";
self->emit playing();
break;
case libvlc_MediaPlayerPaused:
// qDebug() << "Media player paused";
qDebug() << "Media player paused";
self->emit paused();
break;
case libvlc_MediaPlayerStopped:
......
......@@ -60,8 +60,8 @@ WorkflowRenderer::WorkflowRenderer( MainWorkflow* mainWorkflow ) :
m_mediaPlayer->setMedia( m_media );
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( __videoPlaying() ) );
connect( m_mediaPlayer, SIGNAL( paused() ), this, SLOT( __videoPaused() ) );
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( __videoPlaying() ), Qt::DirectConnection );
connect( m_mediaPlayer, SIGNAL( paused() ), this, SLOT( __videoPaused() ), Qt::DirectConnection );
connect( m_mediaPlayer, SIGNAL( stopped() ), this, SLOT( __videoStopped() ) );
connect( m_mainWorkflow, SIGNAL( mainWorkflowEndReached() ), this, SLOT( __endReached() ) );
connect( m_mainWorkflow, SIGNAL( positionChanged( float ) ), this, SLOT( __positionChanged( float ) ) );
......@@ -84,27 +84,37 @@ WorkflowRenderer::~WorkflowRenderer()
void* WorkflowRenderer::lock( void* datas )
{
qDebug() << "WorkflowRenderer::lock()";
WorkflowRenderer* self = reinterpret_cast<WorkflowRenderer*>( datas );
//If we're not playing, then where in a paused media player.
if ( self->m_pausedMediaPlayer == true )
{
qDebug() << "Returning last frame, since media player is paused";
return self->m_lastFrame;
}
if ( self->m_oneFrameOnly < 2 )
{
void* ret = self->m_mainWorkflow->getOutput();
self->m_lastFrame = static_cast<unsigned char*>( ret );
qDebug() << "Returning new frame";
return ret;
}
else
{
qDebug() << "Returning last frame, due to m_oneFrameOnly flag (" << self->m_oneFrameOnly << ")";
return self->m_lastFrame;
}
}
void WorkflowRenderer::unlock( void* datas )
{
qDebug() << __func__;
WorkflowRenderer* self = reinterpret_cast<WorkflowRenderer*>( datas );
if ( self->m_oneFrameOnly == 1 )
{
self->m_mediaPlayer->pause();
qDebug() << "Switching m_oneFrameOnly flag to 2";
self->m_oneFrameOnly = 2;
}
self->m_framePlayed = true;
......@@ -186,8 +196,10 @@ void WorkflowRenderer::previousFrame()
void WorkflowRenderer::pauseMainWorkflow()
{
qDebug() << "Pausing main workflow, setting m_pausedMediaPlayer to true... ?";
if ( m_paused == true )
return ;
qDebug() << "Indeed. Setting m_pausedMediaPlayer to true";
m_pausedMediaPlayer = true;
m_mainWorkflow->pause();
}
......@@ -262,6 +274,7 @@ void WorkflowRenderer::__videoPaused()
void WorkflowRenderer::__videoPlaying()
{
emit playing();
qDebug() << "Setting m_pausedMediaPlayer to false";
m_pausedMediaPlayer = false;
m_paused = false;
}
......
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