Commit 8c319cba authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Cleaned AudioClipWorkflow and WorkflowRenderer

parent 383a36e0
......@@ -24,7 +24,6 @@
#include <QThread>
#include <QWaitCondition>
#include "vlmc.h"
#include "WorkflowRenderer.h"
#include "timeline/Timeline.h"
#include "SettingsManager.h"
......@@ -58,7 +57,6 @@ void WorkflowRenderer::initializeRenderer()
m_videoEsHandler = new EsHandler;
m_videoEsHandler->self = this;
m_videoEsHandler->type = Video;
m_audioEsHandler = new EsHandler;
m_audioEsHandler->self = this;
m_audioEsHandler->type = Audio;
......@@ -67,7 +65,8 @@ void WorkflowRenderer::initializeRenderer()
m_rate = 48000;
sprintf( videoString, "width=%i:height=%i:dar=%s:fps=%s:data=%lld:codec=%s:cat=2:caching=0",
m_mainWorkflow->getWidth(), m_mainWorkflow->getHeight(), "4/3", "30/1", (qint64)m_videoEsHandler, "RV24" );
m_mainWorkflow->getWidth(), m_mainWorkflow->getHeight(), "4/3", "30/1",
(qint64)m_videoEsHandler, "RV24" );
sprintf( audioParameters, "data=%lld:cat=1:codec=s16l:samplerate=%u:channels=%u:caching=0",
(qint64)m_audioEsHandler, m_rate, m_nbChannels );
strcpy( inputSlave, ":input-slave=imem://" );
......@@ -109,21 +108,16 @@ int WorkflowRenderer::lock( void *datas, int64_t *dts, int64_t *pts, unsigne
*flags = 0;
if ( handler->type == Video )
{
// qDebug() << "entering lock video";
ret = handler->self->lockVideo( pts, bufferSize, buffer );
handler->self->m_mainWorkflow->goToNextFrame( MainWorkflow::VideoTrack );
// qDebug() << "leaved lock video";
}
else if ( handler->type == Audio )
{
// qDebug() << "entering lock audio";
ret = handler->self->lockAudio( pts, bufferSize, buffer );
handler->self->m_mainWorkflow->goToNextFrame( MainWorkflow::AudioTrack );
// qDebug() << "leaved lock audio";
}
else
qCritical() << "Invalid ES type";
// qDebug() << "ES Type:" << handler->type << "pts:" << *pts;
return ret;
}
......@@ -146,9 +140,6 @@ int WorkflowRenderer::lockVideo( int64_t *pts, size_t *bufferSize, void **bu
ptsDiff = 1000000 / m_outputFps;
}
m_pts = *pts = ptsDiff + m_pts;
// qDebug() << "Video pts" << m_pts << "diff" << ptsDiff;
//*pts = qRound64( (float)( m_pts * 1000000.0f ) / m_outputFps );
//++m_pts;
*buffer = m_renderVideoFrame;
*bufferSize = m_videoBuffSize;
return 0;
......@@ -160,9 +151,7 @@ int WorkflowRenderer::lockAudio( int64_t *pts, size_t *bufferSize, void **b
if ( m_stopping == false )
{
// qDebug() << "getting MainWorkflow audio output";
MainWorkflow::OutputBuffers* ret = m_mainWorkflow->getOutput( MainWorkflow::AudioTrack );
// qDebug() << "got mainworkflow audio output";
m_renderAudioSample = ret->audio;
}
uint32_t nbSample;
......@@ -185,9 +174,6 @@ int WorkflowRenderer::lockAudio( int64_t *pts, size_t *bufferSize, void **b
ptsDiff = m_pts - m_audioPts;
}
m_audioPts = *pts = m_audioPts + ptsDiff;
// qDebug() << "Audio pts" << m_audioPts << "debug id:" << m_renderAudioSample->debugId << "diff:" << ptsDiff;
//*pts = m_audioPts * 1000000.0f / m_rate;
//m_audioPts += nbSample * m_nbChannels;
return 0;
}
......
......@@ -57,38 +57,23 @@ void* AudioClipWorkflow::getUnlockCallback()
void* AudioClipWorkflow::getOutput( ClipWorkflow::GetMode mode )
{
// qDebug() << "entering audio get output";
QMutexLocker lock( m_renderLock );
// qDebug() << "got audio render lock";
QMutexLocker lock2( m_computedBuffersMutex );
// qDebug() << "got computed buffers mutex";
if ( preGetOutput() == false )
{
// qDebug() << "audio preGetOutput() returned false";
return NULL;
}
// qWarning() << "Audio. Available:" << m_availableBuffers.count() << "Computed:" << m_computedBuffers.count();
if ( isEndReached() == true )
{
// qDebug() << "audio end is reached";
return NULL;
}
if ( mode == ClipWorkflow::Get )
qCritical() << "A sound buffer should never be asked with 'Get' mode";
::StackedBuffer<AudioSample*>* buff = new StackedBuffer(
m_computedBuffers.dequeue(), this, true );
// qDebug() << "calling audio postGetOutput();";
postGetOutput();
// qDebug() << "returning audio buffer";
return buff;
}
void AudioClipWorkflow::initVlcOutput()
{
// m_vlcMedia->addOption( ":verbose 3" );
// m_vlcMedia->addOption( ":vvv" );
m_vlcMedia->addOption( ":no-sout-video" );
m_vlcMedia->addOption( ":no-video" );
m_vlcMedia->addOption( ":sout=#transcode{}:smem" );
......@@ -99,12 +84,10 @@ void AudioClipWorkflow::initVlcOutput()
m_vlcMedia->addOption( ":sout-transcode-samplerate=48000" );
m_vlcMedia->addOption( ":sout-transcode-channels=2" );
m_vlcMedia->addOption( ":sout-smem-time-sync" );
// m_vlcMedia->addOption( ":no-sout-smem-time-sync" );
}
AudioClipWorkflow::AudioSample* AudioClipWorkflow::createBuffer( size_t size )
{
qDebug() << "Creating new buffer of size:" << size;
AudioSample* as = new AudioSample;
as->buff = new uchar[size];
as->size = size;
......@@ -118,13 +101,9 @@ void AudioClipWorkflow::lock( AudioClipWorkflow* cw, uint8_t** pcm_buffer
cw->m_renderLock->lock();
cw->m_computedBuffersMutex->lock();
// qWarning() << ">>>AudioGeneration. Available:" << cw->m_availableBuffers.count() << "Computed:" << cw->m_computedBuffers.count() << "position" << cw->m_mediaPlayer->getPosition();
AudioSample* as = NULL;
if ( cw->m_availableBuffers.isEmpty() == true )
{
// qCritical() << cw << "Late buffer generation. Spawning new audio buffer.";
as = cw->createBuffer( size );
}
else
{
as = cw->m_availableBuffers.dequeue();
......@@ -143,8 +122,6 @@ void AudioClipWorkflow::unlock( AudioClipWorkflow* cw, uint8_t* pcm_buffe
unsigned int nb_samples, unsigned int bits_per_sample,
unsigned int size, qint64 pts )
{
// qDebug() << "pts:" << pts << "nb channels" << channels << "rate:" << rate <<
// "size:" << size << "nb_samples:" << nb_samples;
Q_UNUSED( pcm_buffer );
Q_UNUSED( rate );
Q_UNUSED( bits_per_sample );
......@@ -158,7 +135,6 @@ void AudioClipWorkflow::unlock( AudioClipWorkflow* cw, uint8_t* pcm_buffe
as->nbChannels = channels;
as->ptsDiff = cw->m_currentPts - cw->m_previousPts;
}
// qWarning() << "::::Computing audio PTS: debugId:" << as->debugId << "ptsdiff:" << as->ptsDiff;
cw->commonUnlock();
cw->m_renderLock->unlock();
cw->m_computedBuffersMutex->unlock();
......
......@@ -71,10 +71,12 @@ class AudioClipWorkflow : public ClipWorkflow
QQueue<AudioSample*> m_availableBuffers;
void initVlcOutput();
AudioSample* createBuffer( size_t size );
static void lock( AudioClipWorkflow* clipWorkflow, uint8_t** pcm_buffer , unsigned int size );
static void unlock( AudioClipWorkflow* clipWorkflow, uint8_t* pcm_buffer,
unsigned int channels, unsigned int rate,
unsigned int nb_samples, unsigned int bits_per_sample,
static void lock( AudioClipWorkflow* clipWorkflow,
uint8_t** pcm_buffer , unsigned int size );
static void unlock( AudioClipWorkflow* clipWorkflow,
uint8_t* pcm_buffer, unsigned int channels,
unsigned int rate, unsigned int nb_samples,
unsigned int bits_per_sample,
unsigned int size, qint64 pts );
//FIXME: this is totally random powered ! Please adjust with a value that does make sense...
......
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