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

Staying consistant in clipworkflow stacking order.

parent 3ddbee6e
......@@ -52,7 +52,7 @@ public:
T ret = m_pool.dequeue();
return ret;
}
T head()
const T& head() const
{
QMutexLocker lock( m_mutex );
return m_pool.head();
......@@ -83,6 +83,11 @@ public:
QMutexLocker lock( m_mutex );
m_pool.push_front( val );
}
const T& last() const
{
QMutexLocker lock( m_mutex );
return m_pool.last();
}
private:
QQueue<T> m_pool;
......
......@@ -57,12 +57,9 @@ void* AudioClipWorkflow::getOutput( ClipWorkflow::GetMode mode )
QMutexLocker lock( m_renderLock );
preGetOutput();
qWarning() << "Audio. Available:" << m_availableBuffers.count() << "Computed:" << m_computedBuffers.count();
// qWarning() << "Audio. Available:" << m_availableBuffers.count() << "Computed:" << m_computedBuffers.count();
if ( isEndReached() == true )
{
qDebug() << "Audio end reached";
return NULL;
}
if ( mode == ClipWorkflow::Get )
qCritical() << "A sound buffer should never be asked with 'Get' mode";
StackedBuffer<AudioSample*>* buff = new StackedBuffer<AudioSample*>( m_computedBuffers.pop(), &m_availableBuffers, true );
......@@ -113,7 +110,7 @@ void AudioClipWorkflow::lock( AudioClipWorkflow* cw, uint8_t** pcm_buffer
}
else
as = cw->m_availableBuffers.pop();
cw->m_computedBuffers.push_front( as );
cw->m_computedBuffers.push_back( as );
*pcm_buffer = as->buff;
}
......@@ -130,7 +127,7 @@ void AudioClipWorkflow::unlock( AudioClipWorkflow* cw, uint8_t* pcm_buffe
Q_UNUSED( size );
cw->computePtsDiff( pts );
AudioSample* as = cw->m_computedBuffers.head();
AudioSample* as = cw->m_computedBuffers.last();
// qWarning() << "Computing audio PTS: pts:" << pts << "m_currentPts:" << cw->m_currentPts << "m_previousPts:" << cw->m_previousPts << "for buffer#" << as->debugId;
if ( as->buff != NULL )
{
......@@ -138,8 +135,6 @@ void AudioClipWorkflow::unlock( AudioClipWorkflow* cw, uint8_t* pcm_buffe
as->nbChannels = channels;
as->ptsDiff = cw->m_currentPts - cw->m_previousPts;
}
else
qCritical() << "Got NULL audio buffer";
cw->commonUnlock();
cw->m_renderLock->unlock();
}
......
......@@ -255,7 +255,7 @@ void* TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFra
m_forceRepositionning = false;
}
else if ( m_paused == true && subFrame != m_lastFrame )
needRepositioning = true;
needRepositioning = true;
else
needRepositioning = ( abs( subFrame - m_lastFrame ) > 1 ) ? true : false;
}
......@@ -268,7 +268,6 @@ void* TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFra
// qDebug() << "Start:" << start << "Current Frame:" << currentFrame;
if ( start <= currentFrame && currentFrame <= start + cw->getClip()->getLength() )
{
qDebug() << "Rendering clip... type:" << m_trackType;
if ( ret != NULL )
qCritical() << "There's more than one clip to render here. Undefined behaviour !";
ret = renderClip( cw, currentFrame, start, needRepositioning );
......@@ -276,21 +275,14 @@ void* TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFra
m_videoStackedBuffer = reinterpret_cast<StackedBuffer<LightVideoFrame*>*>( ret );
else
m_audioStackedBuffer = reinterpret_cast<StackedBuffer<AudioClipWorkflow::AudioSample*>*>( ret );
qDebug() << "Rendered buffer. Type:" << m_trackType << "ret:" << (void*)ret;
}
//Is it about to be rendered ?
else if ( start > currentFrame &&
start - currentFrame < TrackWorkflow::nbFrameBeforePreload )
{
qDebug() << "Preloading clip.";
preloadClip( cw );
}
//Is it supposed to be stopped ?
else
{
qDebug() << "Stopping clip";
stopClipWorkflow( cw );
}
++it;
}
m_lastFrame = subFrame;
......
......@@ -122,7 +122,7 @@ void VideoClipWorkflow::lock( VideoClipWorkflow* cw, void** pp_ret, int size
}
else
lvf = cw->m_availableBuffers.pop();
cw->m_computedBuffers.push_front( lvf );
cw->m_computedBuffers.push_back( lvf );
// qWarning() << ">>>VideoGeneration. Available:" << cw->m_availableBuffers.count() << "Computed:" << cw->m_computedBuffers.count();
// qWarning() << "feeding video buffer";
*pp_ret = (*(lvf))->frame.octets;
......@@ -138,7 +138,7 @@ void VideoClipWorkflow::unlock( VideoClipWorkflow* cw, void* buffer, int widt
Q_UNUSED( size );
cw->computePtsDiff( pts );
LightVideoFrame* lvf = cw->m_computedBuffers.head();
LightVideoFrame* lvf = cw->m_computedBuffers.last();
(*(lvf))->ptsDiff = cw->m_currentPts - cw->m_previousPts;
//If this is the first buffer that has been rendered, there may be a waiting TrackWorkflow.
cw->commonUnlock();
......
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