Commit 6cd92916 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Audio does work !!!!

parent 3ede23cb
......@@ -85,15 +85,15 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev
switch ( event->type )
{
case libvlc_MediaPlayerPlaying:
qDebug() << "Media player playing";
// qDebug() << "Media player playing";
self->emit playing();
break;
case libvlc_MediaPlayerPaused:
qDebug() << "Media player paused";
// qDebug() << "Media player paused";
self->emit paused();
break;
case libvlc_MediaPlayerStopped:
qDebug() << "Media player stopped";
// qDebug() << "Media player stopped";
self->emit stopped();
break;
case libvlc_MediaPlayerEndReached:
......
......@@ -167,7 +167,7 @@ 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 << "diff" << 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;
......
......@@ -140,13 +140,17 @@ void AudioClipWorkflow::unlock( AudioClipWorkflow* cw, uint8_t* pcm_buffe
cw->computePtsDiff( pts );
AudioSample* as = cw->m_computedBuffers.last();
// qWarning() << "Computing audio PTS: pts:" << pts << "m_currentPts:" << cw->m_currentPts << "m_previousPts:" << cw->m_previousPts << "for buffer#" << as->debugId;
if ( as->buff != NULL )
{
as->nbSample = nb_samples;
as->nbChannels = channels;
as->ptsDiff = cw->m_currentPts - cw->m_previousPts;
}
qWarning() << "::::Computing audio PTS: debugId:" << as->debugId << "ptsdiff:" << as->ptsDiff;
if ( as->ptsDiff > 100000 )
{
qWarning() << "Probably invalid pts diff.";
}
cw->commonUnlock();
cw->m_renderLock->unlock();
cw->m_computedBuffersMutex->unlock();
......
......@@ -91,8 +91,8 @@ void ClipWorkflow::loadingComplete()
{
adjustBegin();
disconnect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( loadingComplete() ) );
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( mediaPlayerUnpaused() ) );
connect( m_mediaPlayer, SIGNAL( paused() ), this, SLOT( mediaPlayerPaused() ) );
connect( m_mediaPlayer, SIGNAL( playing() ), this, SLOT( mediaPlayerUnpaused() ), Qt::DirectConnection );
connect( m_mediaPlayer, SIGNAL( paused() ), this, SLOT( mediaPlayerPaused() ), Qt::DirectConnection );
QMutexLocker lock( m_initWaitCond->getMutex() );
setState( Rendering );
m_initWaitCond->wake();
......@@ -150,6 +150,7 @@ void ClipWorkflow::stop()
void ClipWorkflow::setTime( qint64 time )
{
qDebug() << "setting clipworkflow time:" << time;
m_mediaPlayer->setTime( time );
flushComputedBuffers();
}
......@@ -199,10 +200,12 @@ void ClipWorkflow::preGetOutput()
//Computed buffer mutex is already locked by underlying clipworkflow getoutput method
if ( getNbComputedBuffers() == 0 )
{
qWarning() << "Waiting for buffer to be fed";
if ( debugType == 1)
qWarning() << "Waiting for buffer to be fed";
m_renderLock->unlock();
m_computedBuffersMutex->unlock();
qDebug() << "Unlocked render lock, entering cond wait";
if ( debugType == 1)
qDebug() << "Unlocked render lock, entering cond wait";
m_feedingCondWait->waitLocked();
m_computedBuffersMutex->lock();
m_renderLock->lock();
......@@ -212,19 +215,18 @@ void ClipWorkflow::preGetOutput()
void ClipWorkflow::postGetOutput()
{
//If we're running out of computed buffers, refill our stack.
if ( debugType == 1 )
qDebug() << "AudioClipWorkflow::postGetOutput";
if ( getNbComputedBuffers() < getMaxComputedBuffers() / 3 )
{
QWriteLocker lock( m_stateLock );
if ( m_state == ClipWorkflow::Paused )
{
qWarning() << "Unpausing media player. type:" << debugType;
if ( debugType == 1)
qWarning() << "Unpausing media player. type:" << debugType;
m_state = ClipWorkflow::UnpauseRequired;
// This will act like an "unpause";
m_mediaPlayer->pause();
}
else
else if ( debugType == 1)
qCritical() << "Running out of computed buffers !";
}
}
......@@ -262,7 +264,8 @@ void ClipWorkflow::computePtsDiff( qint64 pts )
m_currentPts = pts;
if ( m_pauseDuration != -1 )
{
// qDebug() << "In pause mode";
if ( debugType == 1 )
qDebug() << "In pause mode";
m_previousPts = m_currentPts + m_pauseDuration;
m_pauseDuration = -1;
}
......@@ -282,15 +285,20 @@ void ClipWorkflow::computePtsDiff( qint64 pts )
void ClipWorkflow::mediaPlayerPaused()
{
qWarning() << "\n\nMedia player paused, waiting for buffers to be consumed.Type:" << debugType << "\n\n";
if ( debugType == 1)
qWarning() << "\n\nMedia player paused, waiting for buffers to be consumed.Type:" << debugType;
setState( ClipWorkflow::Paused );
m_beginPausePts = mdate();
// qDebug() << "got pause pts:" << m_beginPausePts;
if ( debugType == 1)
qDebug() << "got pause pts:" << m_beginPausePts;
}
void ClipWorkflow::mediaPlayerUnpaused()
{
qWarning() << "Media player unpaused. Go back to rendering. Type:" << debugType;
if ( debugType == 1)
qWarning() << "Media player unpaused. Go back to rendering. Type:" << debugType;
setState( ClipWorkflow::Rendering );
m_pauseDuration = mdate() - m_beginPausePts;
if ( debugType == 1)
qDebug() << "pause duration:" << m_pauseDuration;
}
......@@ -35,6 +35,9 @@ class StackedBuffer
m_mustRelease( mustBeReleased )
{
}
virtual ~StackedBuffer()
{
}
/// \warning Calling this method will definitely invalidate the pointer;
virtual void release() = 0;
......
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