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

Allow position setting in new clip workflow

parent 934fa5c8
......@@ -67,7 +67,7 @@ void WorkflowRenderer::initializeRenderer()
strcat( inputSlave, audioParameters );
m_media = new LibVLCpp::Media( "imem://" + QString( videoString ) );
m_media->addOption( inputSlave );
// m_media->addOption( inputSlave );
sprintf( callbacks, "imem-get=%lld", (qint64)WorkflowRenderer::lock );
m_media->addOption( callbacks );
......
......@@ -145,7 +145,7 @@ void AudioClipWorkflow::unlock( AudioClipWorkflow* cw, uint8_t* pcm_buffe
cw->m_computedBuffersMutex->unlock();
}
uint32_t AudioClipWorkflow::getComputedBuffers() const
uint32_t AudioClipWorkflow::getNbComputedBuffers() const
{
return m_computedBuffers.count();
}
......@@ -160,3 +160,14 @@ void AudioClipWorkflow::releaseBuffer( AudioSample *sample )
QMutexLocker lock( m_availableBuffersMutex );
m_availableBuffers.enqueue( sample );
}
void AudioClipWorkflow::flushComputedBuffers()
{
QMutexLocker lock( m_computedBuffersMutex );
QMutexLocker lock2( m_availableBuffersMutex );
while ( m_computedBuffers.isEmpty() == false )
{
m_availableBuffers.enqueue( m_computedBuffers.dequeue() );
}
}
......@@ -46,8 +46,9 @@ class AudioClipWorkflow : public ClipWorkflow
virtual void* getOutput( ClipWorkflow::GetMode mode );
protected:
virtual uint32_t getComputedBuffers() const;
virtual uint32_t getNbComputedBuffers() const;
virtual uint32_t getMaxComputedBuffers() const;
void flushComputedBuffers();
private:
void releaseBuffer( AudioSample* sample );
......
......@@ -152,6 +152,7 @@ void ClipWorkflow::stop()
void ClipWorkflow::setTime( qint64 time )
{
m_mediaPlayer->setTime( time );
flushComputedBuffers();
}
bool ClipWorkflow::isRendering() const
......@@ -197,7 +198,7 @@ void ClipWorkflow::preGetOutput()
QMutexLocker lock( m_feedingCondWait->getMutex() );
//Computed buffer mutex is already locked by underlying clipworkflow getoutput method
if ( getComputedBuffers() == 0 )
if ( getNbComputedBuffers() == 0 )
{
// qWarning() << "Waiting for buffer to be fed";
m_renderLock->unlock();
......@@ -212,7 +213,7 @@ void ClipWorkflow::preGetOutput()
void ClipWorkflow::postGetOutput()
{
//If we're running out of computed buffers, refill our stack.
if ( getComputedBuffers() < getMaxComputedBuffers() / 3 )
if ( getNbComputedBuffers() < getMaxComputedBuffers() / 3 )
{
QWriteLocker lock( m_stateLock );
if ( m_state == ClipWorkflow::Paused )
......@@ -231,13 +232,13 @@ void ClipWorkflow::commonUnlock()
{
//Don't test using availableBuffer, as it may evolve if a buffer is required while
//no one is available : we would spawn a new buffer, thus modifying the number of available buffers
if ( getComputedBuffers() == getMaxComputedBuffers() )
if ( getNbComputedBuffers() == getMaxComputedBuffers() )
{
qWarning() << "Pausing clip workflow. Type:" << debugType;
setState( ClipWorkflow::PauseRequired );
m_mediaPlayer->pause();
}
if ( getComputedBuffers() == 1 )
if ( getNbComputedBuffers() == 1 )
{
// qDebug() << "Waking feeding cont wait... acquiring lock. Type:" << debugType;
QMutexLocker lock( m_feedingCondWait->getMutex() );
......
......@@ -124,6 +124,10 @@ class ClipWorkflow : public QObject
\brief Stop this workflow.
*/
void stop();
/**
* \brief Set the rendering position
* \param time The position in millisecond
*/
void setTime( qint64 time );
/**
......@@ -156,10 +160,19 @@ class ClipWorkflow : public QObject
protected:
void computePtsDiff( qint64 pts );
void commonUnlock();
/// \warning Must be called from a thread safe context.
/// This thread safe context has to be set from the underlying ClipWorkflow implementation.
virtual uint32_t getComputedBuffers() const = 0;
/**
* \warning Must be called from a thread safe context.
* This thread safe context has to be set
* from the underlying ClipWorkflow implementation.
*/
virtual uint32_t getNbComputedBuffers() const = 0;
virtual uint32_t getMaxComputedBuffers() const = 0;
/**
* \brief Will empty the computed buffers stack.
* This has to be implemented in the underlying
* clipworkflow implementation.
*/
virtual void flushComputedBuffers() = 0;
private:
LibVLCpp::MediaPlayer* m_mediaPlayer;
......
......@@ -148,7 +148,7 @@ void VideoClipWorkflow::unlock( VideoClipWorkflow* cw, void* buffer, int widt
cw->m_computedBuffersMutex->unlock();
}
uint32_t VideoClipWorkflow::getComputedBuffers() const
uint32_t VideoClipWorkflow::getNbComputedBuffers() const
{
return m_computedBuffers.count();
}
......@@ -163,3 +163,14 @@ void VideoClipWorkflow::releaseBuffer( LightVideoFrame *lvf )
QMutexLocker lock( m_availableBuffersMutex );
m_availableBuffers.enqueue( lvf );
}
void VideoClipWorkflow::flushComputedBuffers()
{
QMutexLocker lock( m_computedBuffersMutex );
QMutexLocker lock2( m_availableBuffersMutex );
while ( m_computedBuffers.isEmpty() == false )
{
m_availableBuffers.enqueue( m_computedBuffers.dequeue() );
}
}
......@@ -41,9 +41,11 @@ class VideoClipWorkflow : public ClipWorkflow
protected:
virtual void initVlcOutput();
virtual uint32_t getComputedBuffers() const;
virtual uint32_t getNbComputedBuffers() const;
virtual uint32_t getMaxComputedBuffers() const;
void releaseBuffer( LightVideoFrame* lvf );
void flushComputedBuffers();
private:
QQueue<LightVideoFrame*> m_computedBuffers;
QQueue<LightVideoFrame*> m_availableBuffers;
......
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