Commit 2496ff14 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Audio is kind or working for non screwed test cases.

It doesn't take care of channel number, audio rate, and probably more.
Still, it *KINDA* work :)
parent 633f2827
......@@ -35,7 +35,7 @@ WorkflowRenderer::WorkflowRenderer() :
m_pauseAsked( false ),
m_unpauseAsked( false )
{
char buffer[64];
char buffer[256];
m_actionsLock = new QReadWriteLock;
......@@ -74,6 +74,10 @@ WorkflowRenderer::WorkflowRenderer() :
m_media->addOption( ":imem-cat=2" );
m_media->addOption( ":imem-caching=0" );
sprintf( buffer, ":input-slave=imem://data=%lld:cat=1:codec=s16l:samplerate=48000:channels=2",
(qint64)m_audioEsHandler );
m_media->addOption( buffer );
m_condMutex = new QMutex;
m_waitCond = new QWaitCondition;
......@@ -141,10 +145,11 @@ int WorkflowRenderer::lockVideo( WorkflowRenderer* self, int64_t *pts, size_
int WorkflowRenderer::lockAudio( WorkflowRenderer* self, int64_t *pts, size_t *bufferSize, void **buffer )
{
Q_UNUSED( self );
Q_UNUSED( pts );
Q_UNUSED( bufferSize );
Q_UNUSED( buffer );
*buffer = self->m_renderAudioSample->buff;
*bufferSize = self->m_renderAudioSample->size;
*pts = ( self->m_audioPts * 1000000 ) / 48000;
// qDebug() << ">>>" << *pts;
self->m_audioPts += 2; //chanel number
return 0;
}
......@@ -200,6 +205,7 @@ void WorkflowRenderer::startPreview()
m_paused = false;
m_stopping = false;
m_pts = 0;
m_audioPts = 0;
m_mediaPlayer->play();
}
......
......@@ -89,7 +89,7 @@ class WorkflowRenderer : public GenericRenderer
private:
unsigned char* m_renderVideoFrame;
size_t m_videoBuffSize;
unsigned char* m_renderAudioSample;
AudioClipWorkflow::AudioSample* m_renderAudioSample;
QStack<Actions> m_actions;
QReadWriteLock* m_actionsLock;
bool m_pauseAsked;
......@@ -103,6 +103,7 @@ class WorkflowRenderer : public GenericRenderer
* It's the number of frame rendered since the render has started.
*/
qint64 m_pts;
qint64 m_audioPts;
public slots:
virtual void setClip( Clip* ){}
......
......@@ -25,15 +25,17 @@
#include "AudioClipWorkflow.h"
AudioClipWorkflow::AudioClipWorkflow( Clip* clip ) :
ClipWorkflow( clip ),
m_buffer( NULL )
ClipWorkflow( clip )
{
m_buffer = new AudioSample;
m_buffer->buff = NULL;
}
AudioClipWorkflow::~AudioClipWorkflow()
{
if ( m_buffer != NULL )
delete[] m_buffer;
if ( m_buffer->buff != NULL )
delete[] m_buffer->buff;
delete m_buffer;
}
void* AudioClipWorkflow::getLockCallback()
......@@ -63,7 +65,8 @@ void AudioClipWorkflow::initVlcOutput()
m_vlcMedia->setAudioLockCallback( reinterpret_cast<void*>( getLockCallback() ) );
m_vlcMedia->setAudioUnlockCallback( reinterpret_cast<void*>( getUnlockCallback() ) );
m_vlcMedia->addOption( ":sout-transcode-acodec=s16l" );
m_vlcMedia->addOption( ":sout-transcode-samplerate=48000" );
m_vlcMedia->addOption( ":sout-transcode-channels=2" );
if ( m_fullSpeedRender == true )
{
m_vlcMedia->addOption( ":no-sout-smem-time-sync" );
......@@ -75,17 +78,21 @@ void AudioClipWorkflow::initVlcOutput()
void AudioClipWorkflow::lock( AudioClipWorkflow* cw, uint8_t** pcm_buffer , unsigned int size )
{
// qDebug() << "<<<<<<<<<<<<<<<<<<<< state:" << cw->m_state;
if ( cw->m_buffer == NULL )
cw->m_buffer = new unsigned char[size];
if ( cw->m_buffer->buff == NULL )
{
cw->m_buffer->buff = new unsigned char[size];
cw->m_buffer->size = size;
}
cw->m_renderLock->lock();
*pcm_buffer = cw->m_buffer;
*pcm_buffer = cw->m_buffer->buff;
}
void AudioClipWorkflow::unlock( AudioClipWorkflow* cw, uint8_t* pcm_buffer,
unsigned int channels, unsigned int rate,
unsigned int nb_samples, unsigned int bits_per_sample,
unsigned int size, int pts )
unsigned int size, qint64 pts )
{
// qDebug() << "pts:" << pts << "nb channels" << channels << "rate:" << rate;
Q_UNUSED( pcm_buffer );
Q_UNUSED( channels );
Q_UNUSED( rate );
......
......@@ -28,6 +28,11 @@
class AudioClipWorkflow : public ClipWorkflow
{
public:
struct AudioSample
{
unsigned char* buff;
size_t size;
};
AudioClipWorkflow( Clip* clip );
~AudioClipWorkflow();
void* getLockCallback();
......@@ -35,13 +40,14 @@ class AudioClipWorkflow : public ClipWorkflow
virtual void* getOutput();
private:
unsigned char* m_buffer;
//FIXME: this should be temporary
AudioSample* m_buffer;
void initVlcOutput();
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, int pts );
unsigned int size, qint64 pts );
};
#endif // AUDIOCLIPWORKFLOW_H
......@@ -44,8 +44,8 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
public:
struct OutputBuffers
{
const LightVideoFrame* video;
unsigned char* audio;
const LightVideoFrame* video;
AudioClipWorkflow::AudioSample* audio;
};
void addClip( Clip* clip, unsigned int trackId, qint64 start, TrackWorkflow::TrackType type );
......
......@@ -302,7 +302,8 @@ void TrackHandler::tracksRenderCompleted( unsigned int trackId )
}
else
{
m_tmpAudioBuffer = reinterpret_cast<unsigned char*>( m_tracks[trackId]->getSynchroneOutput() );
AudioClipWorkflow::AudioSample* buff = reinterpret_cast<AudioClipWorkflow::AudioSample*>( m_tracks[trackId]->getSynchroneOutput() );
m_tmpAudioBuffer = buff;
}
}
//We check for minus or equal, since we can have 0 frame to compute,
......
......@@ -27,6 +27,9 @@
#include "Toggleable.hpp"
#include "TrackWorkflow.h"
#include "EffectsEngine.h"
//TEMPORARY:
#include "AudioClipWorkflow.h"
class TrackHandler : public QObject
{
......@@ -58,7 +61,7 @@ class TrackHandler : public QObject
void setFullSpeedRender( bool value );
//FIXME: remove this. This should go by the effect engine.
unsigned char* getTmpAudioBuffer() { return m_tmpAudioBuffer; }
AudioClipWorkflow::AudioSample* getTmpAudioBuffer() { return m_tmpAudioBuffer; }
bool isPaused() const;
bool allTracksRendered() const;
......@@ -88,7 +91,7 @@ class TrackHandler : public QObject
*/
bool m_renderCompleted;
EffectsEngine* m_effectEngine;
unsigned char* m_tmpAudioBuffer;
AudioClipWorkflow::AudioSample* m_tmpAudioBuffer;
private slots:
......
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