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

Some attemps to resolve a graphic bug when changing position

parent bc134e98
......@@ -90,6 +90,7 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev
self->emit timeChanged();
break;
case libvlc_MediaPlayerPositionChanged:
// qDebug() << "Position changed" << event->u.media_player_position_changed.new_position;
self->emit positionChanged();
break;
//TODO: activate this when switching to VLC 1.1
......
......@@ -56,9 +56,14 @@ ClipWorkflow::~ClipWorkflow()
unsigned char* ClipWorkflow::getOutput()
{
// qDebug() << "Getting output";
QReadLocker lock( m_backBufferLock );
if ( m_usingBackBuffer == true )
{
// qDebug() << "Returning frontbuffer";
return m_buffer;
}
// qDebug() << "Returning backbuffer";
return m_backBuffer;
}
......@@ -68,25 +73,31 @@ void ClipWorkflow::checkStateChange()
QWriteLocker lock2( m_stateLock );
if ( m_requiredState != ClipWorkflow::None )
{
qDebug() << "Setting required state : " << m_requiredState;
m_state = m_requiredState;
m_requiredState = ClipWorkflow::None;
}
}
void ClipWorkflow::lock( ClipWorkflow* clipWorkflow, void** pp_ret )
void ClipWorkflow::lock( ClipWorkflow* cw, void** pp_ret )
{
// qDebug() << "Locking in ClipWorkflow::lock";
QReadLocker lock( clipWorkflow->m_backBufferLock );
QReadLocker lock( cw->m_backBufferLock );
if ( clipWorkflow->m_usingBackBuffer )
*pp_ret = clipWorkflow->m_backBuffer;
if ( cw->m_usingBackBuffer )
{
// qDebug() << "Using backbuffer";
*pp_ret = cw->m_backBuffer;
}
else
*pp_ret = clipWorkflow->m_buffer;
{
// qDebug() << "Using frontbuffer";
*pp_ret = cw->m_buffer;
}
}
void ClipWorkflow::unlock( ClipWorkflow* cw )
{
// qDebug() << "UnLocking in ClipWorkflow::unlock";
cw->m_stateLock->lockForWrite();
if ( cw->m_state == Rendering )
......@@ -94,21 +105,21 @@ void ClipWorkflow::unlock( ClipWorkflow* cw )
cw->m_state = Sleeping;
cw->m_stateLock->unlock();
// qDebug() << "Sleeping....";
QMutexLocker lock( cw->m_condMutex );
cw->m_waitCond->wait( cw->m_condMutex );
cw->m_stateLock->lockForWrite();
cw->m_state = Rendering;
// qDebug() << "Waiking";
{
QWriteLocker lock2( cw->m_backBufferLock );
cw->m_usingBackBuffer = !cw->m_usingBackBuffer;
}
cw->m_stateLock->lockForWrite();
cw->m_state = Rendering;
}
else
qDebug() << cw->m_state;
cw->m_stateLock->unlock();
cw->checkStateChange();
// qDebug() << "UnLocking in ClipWorkflow::unlock";
}
void ClipWorkflow::setVmem()
......
......@@ -87,12 +87,16 @@ unsigned char* TrackWorkflow::renderClip( ClipWorkflow* cw, bool needReposi
if ( cw->getState() == ClipWorkflow::Sleeping )
{
cw->getStateLock()->unlock();
ret = cw->getOutput();
if ( needRepositioning == true )
{
cw->setPosition( pos );
}
ret = cw->getOutput();
// qDebug() << "Waking renderer";
cw->wake();
// qDebug() << "Awaken renderer";
//FIXME: sometimes, the renderer isn't awake soon enough, and we can
//pass though this function many times before the frame is actually rendered.
}
else if ( cw->getState() == ClipWorkflow::Stopped )
{
......@@ -110,7 +114,7 @@ unsigned char* TrackWorkflow::renderClip( ClipWorkflow* cw, bool needReposi
}
else
{
qDebug() << "Unexpected ClipWorkflow::State when rendering:" << cw->getState();
// qDebug() << "Unexpected ClipWorkflow::State when rendering:" << cw->getState();
cw->getStateLock()->unlock();
}
return ret;
......@@ -165,7 +169,7 @@ void TrackWorkflow::stopClipWorkflow( ClipWorkflow* cw )
}
else
{
qDebug() << "Unexpected ClipWorkflow::State when stopping :" << cw->getState();
// qDebug() << "Unexpected ClipWorkflow::State when stopping :" << cw->getState();
cw->getStateLock()->unlock();
}
}
......@@ -178,7 +182,7 @@ unsigned char* TrackWorkflow::getOutput( qint64 currentFrame )
static qint64 lastFrame = 0;
bool needRepositioning;
needRepositioning = ( abs( currentFrame - lastFrame ) > 3 ) ? true : false;
needRepositioning = ( abs( currentFrame - lastFrame ) > 1 ) ? true : false;
while ( it != end )
{
qint64 start = it.key();
......@@ -189,6 +193,7 @@ unsigned char* TrackWorkflow::getOutput( qint64 currentFrame )
{
if ( needRepositioning == true )
{
// qDebug() << "Repositionning to" << currentFrame << '(' << (float)( currentFrame - start ) / (float)(cw->getClip()->getLength()) << ')';
ret = renderClip( cw, true,
( (float)( currentFrame - start ) / (float)(cw->getClip()->getLength()) ) );
}
......
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