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