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