Commit a6642d2f authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Workflow: Relocating AudioSample inside the Workflow namespace, in Workflow/Types.h

parent 35354d05
......@@ -182,7 +182,7 @@ WorkflowRenderer::lockAudio( EsHandler *handler, qint64 *pts, size_t *bufferSize
{
qint64 ptsDiff;
quint32 nbSample;
AudioClipWorkflow::AudioSample *renderAudioSample;
Workflow::AudioSample *renderAudioSample;
if ( m_stopping == false && m_paused == false )
{
......
......@@ -24,6 +24,7 @@
#include "AudioClipWorkflow.h"
#include "VLCMedia.h"
#include "Workflow/Types.h"
AudioClipWorkflow::AudioClipWorkflow( ClipHelper *ch ) :
ClipWorkflow( ch )
......@@ -41,7 +42,7 @@ AudioClipWorkflow::preallocate()
{
for ( quint32 i = 0; i < AudioClipWorkflow::nbBuffers; ++i )
{
AudioSample *as = new AudioSample;
Workflow::AudioSample *as = new Workflow::AudioSample;
as->buff = NULL;
m_availableBuffers.push_back( as );
}
......@@ -52,13 +53,13 @@ AudioClipWorkflow::releasePrealocated()
{
while ( m_availableBuffers.isEmpty() == false )
{
AudioSample *as = m_availableBuffers.takeFirst();
Workflow::AudioSample *as = m_availableBuffers.takeFirst();
delete as->buff;
delete as;
}
while ( m_computedBuffers.isEmpty() == false )
{
AudioSample *as = m_computedBuffers.takeFirst();
Workflow::AudioSample *as = m_computedBuffers.takeFirst();
delete as->buff;
delete as;
}
......@@ -87,7 +88,7 @@ AudioClipWorkflow::getOutput( ClipWorkflow::GetMode mode )
return NULL;
if ( mode == ClipWorkflow::Get )
qCritical() << "A sound buffer should never be asked with 'Get' mode";
::StackedBuffer<AudioSample*> *buff = new StackedBuffer(
::StackedBuffer<Workflow::AudioSample*> *buff = new StackedBuffer(
m_computedBuffers.dequeue(), this, true );
if ( m_previousPts == -1 )
{
......@@ -123,10 +124,10 @@ AudioClipWorkflow::initVlcOutput()
m_vlcMedia->addOption( ":no-sout-smem-time-sync" );
}
AudioClipWorkflow::AudioSample*
Workflow::AudioSample*
AudioClipWorkflow::createBuffer( size_t size )
{
AudioSample *as = new AudioSample;
Workflow::AudioSample *as = new Workflow::AudioSample;
as->buff = new uchar[size];
as->size = size;
return as;
......@@ -137,7 +138,7 @@ AudioClipWorkflow::lock( AudioClipWorkflow *cw, quint8 **pcm_buffer , quint32 si
{
cw->m_renderLock->lock();
AudioSample *as = NULL;
Workflow::AudioSample *as = NULL;
if ( cw->m_availableBuffers.isEmpty() == true )
as = cw->createBuffer( size );
else
......@@ -165,7 +166,7 @@ AudioClipWorkflow::unlock( AudioClipWorkflow *cw, quint8 *pcm_buffer,
Q_UNUSED( size );
pts -= cw->m_ptsOffset;
AudioSample* as = cw->m_computedBuffers.last();
Workflow::AudioSample* as = cw->m_computedBuffers.last();
if ( as->buff != NULL )
{
as->nbSample = nb_samples;
......@@ -190,10 +191,10 @@ AudioClipWorkflow::unlock( AudioClipWorkflow *cw, quint8 *pcm_buffer,
}
void
AudioClipWorkflow::insertPastBlock( AudioSample *as )
AudioClipWorkflow::insertPastBlock( Workflow::AudioSample *as )
{
QQueue<AudioSample*>::iterator it = m_computedBuffers.begin();
QQueue<AudioSample*>::iterator end = m_computedBuffers.end();
QQueue<Workflow::AudioSample*>::iterator it = m_computedBuffers.begin();
QQueue<Workflow::AudioSample*>::iterator end = m_computedBuffers.end();
while ( it != end )
{
......@@ -221,7 +222,7 @@ AudioClipWorkflow::getMaxComputedBuffers() const
}
void
AudioClipWorkflow::releaseBuffer( AudioSample *sample )
AudioClipWorkflow::releaseBuffer( Workflow::AudioSample *sample )
{
QMutexLocker lock( m_renderLock );
m_availableBuffers.enqueue( sample );
......@@ -238,10 +239,10 @@ AudioClipWorkflow::flushComputedBuffers()
}
}
AudioClipWorkflow::StackedBuffer::StackedBuffer( AudioClipWorkflow::AudioSample *as,
AudioClipWorkflow::StackedBuffer::StackedBuffer( Workflow::AudioSample *as,
AudioClipWorkflow *poolHandler,
bool mustBeReleased) :
::StackedBuffer<AudioClipWorkflow::AudioSample*>( as, mustBeReleased ),
::StackedBuffer<Workflow::AudioSample*>( as, mustBeReleased ),
m_poolHandler( poolHandler )
{
}
......
......@@ -28,24 +28,20 @@
#include <QPointer>
namespace Workflow
{
struct AudioSample;
}
class AudioClipWorkflow : public ClipWorkflow
{
Q_OBJECT
public:
struct AudioSample
{
unsigned char* buff;
size_t size;
quint32 nbSample;
quint32 nbChannels;
qint64 ptsDiff;
qint64 pts;
};
class StackedBuffer : public ::StackedBuffer<AudioSample*>
class StackedBuffer : public ::StackedBuffer<Workflow::AudioSample*>
{
public:
StackedBuffer( AudioSample* lvf, AudioClipWorkflow* poolHandler,
StackedBuffer( Workflow::AudioSample* lvf, AudioClipWorkflow* poolHandler,
bool mustBeReleased = true);
virtual void release();
private:
......@@ -66,10 +62,10 @@ class AudioClipWorkflow : public ClipWorkflow
void releasePrealocated();
private:
void releaseBuffer( AudioSample *sample );
void releaseBuffer( Workflow::AudioSample *sample );
void initVlcOutput();
AudioSample* createBuffer( size_t size );
void insertPastBlock( AudioSample* as );
Workflow::AudioSample* createBuffer( size_t size );
void insertPastBlock( Workflow::AudioSample* as );
static void lock( AudioClipWorkflow* clipWorkflow,
quint8** pcm_buffer , quint32 size );
static void unlock( AudioClipWorkflow* clipWorkflow,
......@@ -79,8 +75,8 @@ class AudioClipWorkflow : public ClipWorkflow
quint32 size, qint64 pts );
private:
QQueue<AudioSample*> m_computedBuffers;
QQueue<AudioSample*> m_availableBuffers;
QQueue<Workflow::AudioSample*> m_computedBuffers;
QQueue<Workflow::AudioSample*> m_availableBuffers;
qint64 m_ptsOffset;
static const quint32 nbBuffers = 256;
......
......@@ -136,7 +136,7 @@ MainWorkflow::getOutput( TrackType trackType, bool paused )
}
else
{
m_outputBuffers->audio = static_cast<AudioClipWorkflow::AudioSample*>( ret );
m_outputBuffers->audio = static_cast<Workflow::AudioSample*>( ret );
}
}
return m_outputBuffers;
......
......@@ -41,6 +41,7 @@ class TrackWorkflow;
namespace Workflow
{
class Frame;
class AudioSample;
}
#include <QObject>
......@@ -61,8 +62,8 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
*/
struct OutputBuffers
{
const Workflow::Frame* video;
AudioClipWorkflow::AudioSample* audio;
const Workflow::Frame *video;
Workflow::AudioSample *audio;
};
/**
* \enum Represents the potential Track types.
......
......@@ -138,8 +138,8 @@ TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
//m_tmpAudioBuffer is NULl by default, so it will remain NULL if we continue;
if ( ret == NULL )
continue ;
StackedBuffer<AudioClipWorkflow::AudioSample*>* stackedBuffer =
reinterpret_cast<StackedBuffer<AudioClipWorkflow::AudioSample*>*> ( ret );
StackedBuffer<Workflow::AudioSample*>* stackedBuffer =
reinterpret_cast<StackedBuffer<Workflow::AudioSample*>*> ( ret );
if ( stackedBuffer != NULL )
return stackedBuffer->get();
}
......
......@@ -319,7 +319,7 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
if ( m_trackType == MainWorkflow::VideoTrack )
m_videoStackedBuffer = reinterpret_cast<StackedBuffer<Workflow::Frame*>*>( ret );
else
m_audioStackedBuffer = reinterpret_cast<StackedBuffer<AudioClipWorkflow::AudioSample*>*>( ret );
m_audioStackedBuffer = reinterpret_cast<StackedBuffer<Workflow::AudioSample*>*>( ret );
}
//Is it about to be rendered?
else if ( start > currentFrame &&
......
......@@ -118,8 +118,8 @@ class TrackWorkflow : public QObject
MainWorkflow::TrackType m_trackType;
qint64 m_lastFrame;
StackedBuffer<Workflow::Frame*>* m_videoStackedBuffer;
StackedBuffer<AudioClipWorkflow::AudioSample*>* m_audioStackedBuffer;
StackedBuffer<Workflow::Frame*>* m_videoStackedBuffer;
StackedBuffer<Workflow::AudioSample*>* m_audioStackedBuffer;
signals:
void trackEndReached( unsigned int );
......
......@@ -57,6 +57,15 @@ namespace Workflow
quint8 *m_buffer;
quint32 m_size;
};
struct AudioSample
{
unsigned char* buff;
size_t size;
quint32 nbSample;
quint32 nbChannels;
qint64 ptsDiff;
qint64 pts;
};
}
#endif // TYPES_H
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