Commit 09a34dc0 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

ClipWorkflow: Release preallocated buffers when stopping.

parent 9397a6ad
......@@ -27,6 +27,18 @@
AudioClipWorkflow::AudioClipWorkflow( Clip *clip ) :
ClipWorkflow( clip )
{
debugType = 1;
m_ptsOffset = 0;
}
AudioClipWorkflow::~AudioClipWorkflow()
{
releasePrealocated();
}
void
AudioClipWorkflow::preallocate()
{
for ( quint32 i = 0; i < AudioClipWorkflow::nbBuffers; ++i )
{
......@@ -35,16 +47,23 @@ AudioClipWorkflow::AudioClipWorkflow( Clip *clip ) :
m_availableBuffers.push_back( as );
as->debugId = i;
}
debugType = 1;
m_ptsOffset = 0;
}
AudioClipWorkflow::~AudioClipWorkflow()
void
AudioClipWorkflow::releasePrealocated()
{
while ( m_availableBuffers.isEmpty() == false )
delete m_availableBuffers.dequeue();
{
AudioSample *as = m_availableBuffers.takeFirst();
delete as->buff;
delete as;
}
while ( m_computedBuffers.isEmpty() == false )
delete m_computedBuffers.dequeue();
{
AudioSample *as = m_computedBuffers.takeFirst();
delete as->buff;
delete as;
}
}
void*
......@@ -90,6 +109,7 @@ AudioClipWorkflow::getOutput( ClipWorkflow::GetMode mode )
void
AudioClipWorkflow::initVlcOutput()
{
preallocate();
m_vlcMedia->addOption( ":no-sout-video" );
m_vlcMedia->addOption( ":no-video" );
m_vlcMedia->addOption( ":sout=#transcode{}:smem" );
......
......@@ -63,6 +63,8 @@ class AudioClipWorkflow : public ClipWorkflow
virtual quint32 getNbComputedBuffers() const;
virtual quint32 getMaxComputedBuffers() const;
void flushComputedBuffers();
void preallocate();
void releasePrealocated();
private:
void releaseBuffer( AudioSample *sample );
......
......@@ -135,6 +135,7 @@ void ClipWorkflow::stop()
setState( Stopped );
delete m_vlcMedia;
flushComputedBuffers();
releasePrealocated();
}
else
qDebug() << "ClipWorkflow has already been stopped";
......
......@@ -204,6 +204,11 @@ class ClipWorkflow : public QObject
*/
virtual void flushComputedBuffers() = 0;
/**
* \brief Release the preallocated buffers
*/
virtual void releasePrealocated() = 0;
private:
WaitCondition* m_initWaitCond;
WaitCondition* m_pausingStateWaitCond;
......
......@@ -47,6 +47,7 @@ class ImageClipWorkflow : public ClipWorkflow
virtual quint32 getNbComputedBuffers() const;
virtual quint32 getMaxComputedBuffers() const;
virtual void flushComputedBuffers();
virtual void releasePrealocated(){}
private:
static void lock( ImageClipWorkflow* clipWorkflow, void** pp_ret,
int size );
......
......@@ -39,6 +39,12 @@ VideoClipWorkflow::VideoClipWorkflow( Clip *clip ) :
}
VideoClipWorkflow::~VideoClipWorkflow()
{
releasePrealocated();
}
void
VideoClipWorkflow::releasePrealocated()
{
while ( m_availableBuffers.isEmpty() == false )
delete m_availableBuffers.dequeue();
......
......@@ -64,6 +64,7 @@ class VideoClipWorkflow : public ClipWorkflow
* \brief Pre-allocate some image buffers.
*/
void preallocate();
void releasePrealocated();
private:
QQueue<LightVideoFrame*> m_computedBuffers;
......
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