Commit 33dbf530 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen
Browse files

Empty audio buffer isn't static anymore.

This wasn't safe, as the size of the buffer can change from a render to
another.
parent 98ed159a
...@@ -35,8 +35,6 @@ ...@@ -35,8 +35,6 @@
#include "Clip.h" #include "Clip.h"
#include "VLCMediaPlayer.h" #include "VLCMediaPlayer.h"
quint8* WorkflowRenderer::silencedAudioBuffer = NULL;
WorkflowRenderer::WorkflowRenderer() : WorkflowRenderer::WorkflowRenderer() :
m_mainWorkflow( MainWorkflow::getInstance() ), m_mainWorkflow( MainWorkflow::getInstance() ),
m_stopping( false ), m_stopping( false ),
...@@ -45,7 +43,8 @@ WorkflowRenderer::WorkflowRenderer() : ...@@ -45,7 +43,8 @@ WorkflowRenderer::WorkflowRenderer() :
m_renderVideoFrame( NULL ), m_renderVideoFrame( NULL ),
m_media( NULL ), m_media( NULL ),
m_width( 0 ), m_width( 0 ),
m_height( 0 ) m_height( 0 ),
m_silencedAudioBuffer( NULL )
{ {
} }
...@@ -193,10 +192,10 @@ WorkflowRenderer::lockAudio( qint64 *pts, size_t *bufferSize, void **buffer ) ...@@ -193,10 +192,10 @@ WorkflowRenderer::lockAudio( qint64 *pts, size_t *bufferSize, void **buffer )
{ {
nbSample = m_rate / m_outputFps; nbSample = m_rate / m_outputFps;
unsigned int buffSize = m_nbChannels * 2 * nbSample; unsigned int buffSize = m_nbChannels * 2 * nbSample;
if ( WorkflowRenderer::silencedAudioBuffer == NULL ) if ( m_silencedAudioBuffer == NULL )
WorkflowRenderer::silencedAudioBuffer = new uint8_t[ buffSize ]; m_silencedAudioBuffer = new uint8_t[ buffSize ];
memset( WorkflowRenderer::silencedAudioBuffer, 0, buffSize ); memset( m_silencedAudioBuffer, 0, buffSize );
*buffer = WorkflowRenderer::silencedAudioBuffer; *buffer = m_silencedAudioBuffer;
*bufferSize = buffSize; *bufferSize = buffSize;
ptsDiff = m_pts - m_audioPts; ptsDiff = m_pts - m_audioPts;
} }
...@@ -295,6 +294,8 @@ WorkflowRenderer::killRenderer() ...@@ -295,6 +294,8 @@ WorkflowRenderer::killRenderer()
m_stopping = true; m_stopping = true;
m_mediaPlayer->stop(); m_mediaPlayer->stop();
m_mainWorkflow->stop(); m_mainWorkflow->stop();
delete[] m_silencedAudioBuffer;
m_silencedAudioBuffer = NULL;
} }
qint64 WorkflowRenderer::getCurrentFrame() const qint64 WorkflowRenderer::getCurrentFrame() const
......
...@@ -269,7 +269,7 @@ class WorkflowRenderer : public GenericRenderer ...@@ -269,7 +269,7 @@ class WorkflowRenderer : public GenericRenderer
* \brief When there's no sound to play, this is the buffer that'll * \brief When there's no sound to play, this is the buffer that'll
* be injected * be injected
*/ */
static quint8* silencedAudioBuffer; quint8 *m_silencedAudioBuffer;
size_t m_videoBuffSize; size_t m_videoBuffSize;
EsHandler* m_videoEsHandler; EsHandler* m_videoEsHandler;
EsHandler* m_audioEsHandler; EsHandler* m_audioEsHandler;
......
Supports Markdown
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