Commit 536c901a authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Some bugs are gone, some other stay...

Right now, it's blocked by a frameChanged // cursorPositionChanged signal problem
parent e885c11b
...@@ -28,7 +28,7 @@ Instance::Instance() ...@@ -28,7 +28,7 @@ Instance::Instance()
{ {
char const *argv[] = char const *argv[] =
{ {
"-vvvvv", // "-vvvvv",
"--no-skip-frames", "--no-skip-frames",
// "--intf", "dummy", // "--intf", "dummy",
"--text-renderer", "dummy", "--text-renderer", "dummy",
......
...@@ -34,16 +34,7 @@ MediaPlayer::MediaPlayer() : m_media( NULL ) ...@@ -34,16 +34,7 @@ MediaPlayer::MediaPlayer() : m_media( NULL )
// Initialize the event manager // Initialize the event manager
p_em = libvlc_media_player_event_manager( m_internalPtr, m_ex ); p_em = libvlc_media_player_event_manager( m_internalPtr, m_ex );
registerEvents();
// Register the callback
libvlc_event_attach( p_em, libvlc_MediaPlayerSnapshotTaken, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerTimeChanged, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerPlaying, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerPaused, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerStopped, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerEndReached, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerPositionChanged, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerLengthChanged, callbacks,this,m_ex );
} }
MediaPlayer::MediaPlayer( Media* media ) : m_media( media ) MediaPlayer::MediaPlayer( Media* media ) : m_media( media )
...@@ -53,15 +44,7 @@ MediaPlayer::MediaPlayer( Media* media ) : m_media( media ) ...@@ -53,15 +44,7 @@ MediaPlayer::MediaPlayer( Media* media ) : m_media( media )
// Initialize the event manager // Initialize the event manager
p_em = libvlc_media_player_event_manager( m_internalPtr, m_ex ); p_em = libvlc_media_player_event_manager( m_internalPtr, m_ex );
registerEvents();
// Register the callback
libvlc_event_attach( p_em, libvlc_MediaPlayerSnapshotTaken, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerTimeChanged, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerPlaying, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerPaused, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerStopped, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerEndReached, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerPositionChanged, callbacks, this, m_ex );
} }
MediaPlayer::~MediaPlayer() MediaPlayer::~MediaPlayer()
...@@ -76,6 +59,23 @@ MediaPlayer::~MediaPlayer() ...@@ -76,6 +59,23 @@ MediaPlayer::~MediaPlayer()
libvlc_media_player_release( m_internalPtr ); libvlc_media_player_release( m_internalPtr );
} }
void
MediaPlayer::registerEvents()
{
// Register the callback
libvlc_event_attach( p_em, libvlc_MediaPlayerSnapshotTaken, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerTimeChanged, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerPlaying, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerPaused, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerStopped, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerEndReached, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerPositionChanged, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerLengthChanged, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerEncounteredError,callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerPausableChanged, callbacks, this, m_ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerSeekableChanged, callbacks, this, m_ex );
}
/** /**
* Event dispatcher. * Event dispatcher.
*/ */
...@@ -111,6 +111,10 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev ...@@ -111,6 +111,10 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev
case libvlc_MediaPlayerSnapshotTaken: case libvlc_MediaPlayerSnapshotTaken:
self->emit snapshotTaken(); self->emit snapshotTaken();
break; break;
case libvlc_MediaPlayerEncounteredError:
qDebug() << "libvlc_MediaPlayerEncounteredError received."
<< "This is not looking good...";
break ;
case libvlc_MediaPlayerSeekableChanged: case libvlc_MediaPlayerSeekableChanged:
case libvlc_MediaPlayerPausableChanged: case libvlc_MediaPlayerPausableChanged:
case libvlc_MediaPlayerTitleChanged: case libvlc_MediaPlayerTitleChanged:
...@@ -119,9 +123,8 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev ...@@ -119,9 +123,8 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev
case libvlc_MediaPlayerBuffering: case libvlc_MediaPlayerBuffering:
case libvlc_MediaPlayerForward: case libvlc_MediaPlayerForward:
case libvlc_MediaPlayerBackward: case libvlc_MediaPlayerBackward:
case libvlc_MediaPlayerEncounteredError:
default: default:
qDebug() << "Unknown mediaPlayerEvent: " << event->type; // qDebug() << "Unknown mediaPlayerEvent: " << event->type;
break; break;
} }
} }
...@@ -153,6 +156,7 @@ qint64 MediaPlayer::getTime() ...@@ -153,6 +156,7 @@ qint64 MediaPlayer::getTime()
void MediaPlayer::setTime( qint64 time ) void MediaPlayer::setTime( qint64 time )
{ {
qDebug() << this << "MediaPlayer::setTime: setting time to" << time;
libvlc_media_player_set_time( m_internalPtr, time, m_ex ); libvlc_media_player_set_time( m_internalPtr, time, m_ex );
CheckVlcppException( m_ex ); CheckVlcppException( m_ex );
} }
......
...@@ -65,6 +65,7 @@ namespace LibVLCpp ...@@ -65,6 +65,7 @@ namespace LibVLCpp
private: private:
static void callbacks( const libvlc_event_t* event, void* self ); static void callbacks( const libvlc_event_t* event, void* self );
void registerEvents();
Exception m_ex; Exception m_ex;
libvlc_event_manager_t* p_em; libvlc_event_manager_t* p_em;
......
...@@ -93,7 +93,7 @@ void MetaDataWorker::computeAudioMetaData() ...@@ -93,7 +93,7 @@ void MetaDataWorker::computeAudioMetaData()
m_media->getVLCMedia()->addOption( ":sout-transcode-acodec=s16l" ); m_media->getVLCMedia()->addOption( ":sout-transcode-acodec=s16l" );
m_media->getVLCMedia()->addOption( ":no-sout-smem-time-sync" ); m_media->getVLCMedia()->addOption( ":no-sout-smem-time-sync" );
m_media->getVLCMedia()->addOption( ":no-sout-keep" ); m_media->getVLCMedia()->addOption( ":no-sout-keep" );
// connect( m_mediaPlayer, SIGNAL( endReached() ), this, SLOT( generateAudioSpectrum() ), Qt::QueuedConnection ); connect( m_mediaPlayer, SIGNAL( endReached() ), this, SLOT( generateAudioSpectrum() ), Qt::QueuedConnection );
} }
void MetaDataWorker::getMetaData() void MetaDataWorker::getMetaData()
......
...@@ -63,7 +63,7 @@ void WorkflowRenderer::initializeRenderer() ...@@ -63,7 +63,7 @@ void WorkflowRenderer::initializeRenderer()
sprintf( videoString, "width=%i:height=%i:dar=%s:fps=%s:data=%lld:codec=%s:cat=2:caching=0", 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", sprintf( audioParameters, "data=%lld:cat=1:codec=s16l:samplerate=%u:channels=%u:caching=0",
(qint64)m_audioEsHandler, m_rate, m_nbChannels ); (qint64)m_audioEsHandler, m_rate, m_nbChannels );
strcpy( inputSlave, ":input-slave=imem://" ); strcpy( inputSlave, ":input-slave=imem://" );
strcat( inputSlave, audioParameters ); strcat( inputSlave, audioParameters );
...@@ -130,7 +130,7 @@ int WorkflowRenderer::lockVideo( WorkflowRenderer* self, int64_t *pts, size_ ...@@ -130,7 +130,7 @@ int WorkflowRenderer::lockVideo( WorkflowRenderer* self, int64_t *pts, size_
ptsDiff = (*(ret->video))->ptsDiff; ptsDiff = (*(ret->video))->ptsDiff;
} }
self->m_pts = *pts = ptsDiff + self->m_pts; self->m_pts = *pts = ptsDiff + self->m_pts;
//qDebug() << "Video pts" << self->m_pts << "diff" << ptsDiff; // qDebug() << "Video pts" << self->m_pts << "diff" << ptsDiff;
//*pts = qRound64( (float)( self->m_pts * 1000000.0f ) / self->m_outputFps ); //*pts = qRound64( (float)( self->m_pts * 1000000.0f ) / self->m_outputFps );
//++self->m_pts; //++self->m_pts;
*buffer = self->m_renderVideoFrame; *buffer = self->m_renderVideoFrame;
...@@ -167,7 +167,7 @@ int WorkflowRenderer::lockAudio( WorkflowRenderer* self, int64_t *pts, size ...@@ -167,7 +167,7 @@ int WorkflowRenderer::lockAudio( WorkflowRenderer* self, int64_t *pts, size
ptsDiff = self->m_pts - self->m_audioPts; ptsDiff = self->m_pts - self->m_audioPts;
} }
self->m_audioPts = *pts = self->m_audioPts + ptsDiff; self->m_audioPts = *pts = self->m_audioPts + ptsDiff;
//qDebug() << "Audio pts" << self->m_audioPts << "diff" << ptsDiff; // qDebug() << "Audio pts" << self->m_audioPts << "diff" << ptsDiff;
//*pts = self->m_audioPts * 1000000.0f / self->m_rate; //*pts = self->m_audioPts * 1000000.0f / self->m_rate;
//self->m_audioPts += nbSample * self->m_nbChannels; //self->m_audioPts += nbSample * self->m_nbChannels;
return 0; return 0;
......
...@@ -32,6 +32,7 @@ AudioClipWorkflow::AudioClipWorkflow( Clip* clip ) : ...@@ -32,6 +32,7 @@ AudioClipWorkflow::AudioClipWorkflow( Clip* clip ) :
AudioSample* as = new AudioSample; AudioSample* as = new AudioSample;
as->buff = NULL; as->buff = NULL;
m_availableBuffers.push_back( as ); m_availableBuffers.push_back( as );
as->debugId = i;
} }
debugType = 1; debugType = 1;
} }
...@@ -60,9 +61,12 @@ void* AudioClipWorkflow::getOutput( ClipWorkflow::GetMode mode ) ...@@ -60,9 +61,12 @@ void* AudioClipWorkflow::getOutput( ClipWorkflow::GetMode mode )
QMutexLocker lock2( m_computedBuffersMutex ); QMutexLocker lock2( m_computedBuffersMutex );
preGetOutput(); preGetOutput();
// qWarning() << "Audio. Available:" << m_availableBuffers.count() << "Computed:" << m_computedBuffers.count(); qWarning() << "Audio. Available:" << m_availableBuffers.count() << "Computed:" << m_computedBuffers.count();
if ( isEndReached() == true ) if ( isEndReached() == true )
{
qDebug() << "End is reached";
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<AudioSample*>* buff = new StackedBuffer(
...@@ -73,7 +77,8 @@ void* AudioClipWorkflow::getOutput( ClipWorkflow::GetMode mode ) ...@@ -73,7 +77,8 @@ void* AudioClipWorkflow::getOutput( ClipWorkflow::GetMode mode )
void AudioClipWorkflow::initVlcOutput() void AudioClipWorkflow::initVlcOutput()
{ {
m_vlcMedia->addOption( ":verbose 3" ); // m_vlcMedia->addOption( ":verbose 3" );
// m_vlcMedia->addOption( ":vvv" );
m_vlcMedia->addOption( ":no-sout-video" ); m_vlcMedia->addOption( ":no-sout-video" );
m_vlcMedia->addOption( ":no-video" ); m_vlcMedia->addOption( ":no-video" );
m_vlcMedia->addOption( ":sout=#transcode{}:smem" ); m_vlcMedia->addOption( ":sout=#transcode{}:smem" );
...@@ -91,6 +96,7 @@ AudioClipWorkflow::AudioSample* AudioClipWorkflow::createBuffer( size_t size ...@@ -91,6 +96,7 @@ AudioClipWorkflow::AudioSample* AudioClipWorkflow::createBuffer( size_t size
AudioSample* as = new AudioSample; AudioSample* as = new AudioSample;
as->buff = new uchar[size]; as->buff = new uchar[size];
as->size = size; as->size = size;
as->debugId = -1;
return as; return as;
} }
......
...@@ -74,7 +74,7 @@ class AudioClipWorkflow : public ClipWorkflow ...@@ -74,7 +74,7 @@ class AudioClipWorkflow : public ClipWorkflow
unsigned int size, qint64 pts ); unsigned int size, qint64 pts );
//FIXME: this is totally random powered ! Please adjust with a value that does make sense... //FIXME: this is totally random powered ! Please adjust with a value that does make sense...
static const uint32_t nbBuffers = 256; static const uint32_t nbBuffers = 1024;
}; };
#endif // AUDIOCLIPWORKFLOW_H #endif // AUDIOCLIPWORKFLOW_H
...@@ -150,6 +150,7 @@ void ClipWorkflow::stop() ...@@ -150,6 +150,7 @@ void ClipWorkflow::stop()
void ClipWorkflow::setTime( qint64 time ) void ClipWorkflow::setTime( qint64 time )
{ {
qDebug() << "setting clipworkflow time to:" << time;
m_mediaPlayer->setTime( time ); m_mediaPlayer->setTime( time );
flushComputedBuffers(); flushComputedBuffers();
} }
...@@ -199,10 +200,10 @@ void ClipWorkflow::preGetOutput() ...@@ -199,10 +200,10 @@ void ClipWorkflow::preGetOutput()
//Computed buffer mutex is already locked by underlying clipworkflow getoutput method //Computed buffer mutex is already locked by underlying clipworkflow getoutput method
if ( getNbComputedBuffers() == 0 ) if ( getNbComputedBuffers() == 0 )
{ {
// qWarning() << "Waiting for buffer to be fed"; qWarning() << "Waiting for buffer to be fed";
m_renderLock->unlock(); m_renderLock->unlock();
m_computedBuffersMutex->unlock(); m_computedBuffersMutex->unlock();
// qDebug() << "Unlocked render lock, entering cond wait"; qDebug() << "Unlocked render lock, entering cond wait";
m_feedingCondWait->waitLocked(); m_feedingCondWait->waitLocked();
m_computedBuffersMutex->lock(); m_computedBuffersMutex->lock();
m_renderLock->lock(); m_renderLock->lock();
...@@ -212,6 +213,8 @@ void ClipWorkflow::preGetOutput() ...@@ -212,6 +213,8 @@ void ClipWorkflow::preGetOutput()
void ClipWorkflow::postGetOutput() void ClipWorkflow::postGetOutput()
{ {
//If we're running out of computed buffers, refill our stack. //If we're running out of computed buffers, refill our stack.
if ( debugType == 1 )
qDebug() << "AudioClipWorkflow::postGetOutput";
if ( getNbComputedBuffers() < getMaxComputedBuffers() / 3 ) if ( getNbComputedBuffers() < getMaxComputedBuffers() / 3 )
{ {
QWriteLocker lock( m_stateLock ); QWriteLocker lock( m_stateLock );
...@@ -222,8 +225,8 @@ void ClipWorkflow::postGetOutput() ...@@ -222,8 +225,8 @@ void ClipWorkflow::postGetOutput()
// This will act like an "unpause"; // This will act like an "unpause";
m_mediaPlayer->pause(); m_mediaPlayer->pause();
} }
// else else
// qCritical() << "Running out of computed buffers !"; qCritical() << "Running out of computed buffers !";
} }
} }
...@@ -233,7 +236,7 @@ void ClipWorkflow::commonUnlock() ...@@ -233,7 +236,7 @@ void ClipWorkflow::commonUnlock()
//no one is available : we would spawn a new buffer, thus modifying the number of available buffers //no one is available : we would spawn a new buffer, thus modifying the number of available buffers
if ( getNbComputedBuffers() == getMaxComputedBuffers() ) if ( getNbComputedBuffers() == getMaxComputedBuffers() )
{ {
qWarning() << "Pausing clip workflow. Type:" << debugType; // qWarning() << "Pausing clip workflow. Type:" << debugType;
setState( ClipWorkflow::PauseRequired ); setState( ClipWorkflow::PauseRequired );
m_mediaPlayer->pause(); m_mediaPlayer->pause();
} }
...@@ -249,23 +252,38 @@ void ClipWorkflow::commonUnlock() ...@@ -249,23 +252,38 @@ void ClipWorkflow::commonUnlock()
void ClipWorkflow::computePtsDiff( qint64 pts ) void ClipWorkflow::computePtsDiff( qint64 pts )
{ {
// if ( debugType == 1 )
// {
// qDebug() << "in computePtsDiff, Before << : pts:" << pts << "previousPts:" << m_previousPts
// << "currentPts:" << m_currentPts;
// }
if ( m_previousPts == -1 ) if ( m_previousPts == -1 )
m_previousPts = pts; m_previousPts = pts;
if ( m_currentPts == -1 ) if ( m_currentPts == -1 )
m_currentPts = pts; m_currentPts = pts;
if ( m_pauseDuration != -1 ) if ( m_pauseDuration != -1 )
{ {
// qDebug() << "In pause mode";
m_previousPts = m_currentPts + m_pauseDuration; m_previousPts = m_currentPts + m_pauseDuration;
m_pauseDuration = -1; m_pauseDuration = -1;
} }
else else
m_previousPts = m_currentPts; m_previousPts = m_currentPts;
// if ( debugType == 1 )
// {
// qDebug() << "in computePtsDiff, After >> : pts:" << pts << "previousPts:" << m_previousPts
// << "currentPts:" << m_currentPts;
// }
// if ( debugType == 1 && pts < m_previousPts )
// {
// qCritical() << "New PTS is lower than previous PTS !<<<<<<<<<<<<<<<<<<<<<<<<<<";
// }
m_currentPts = qMax( pts, m_previousPts ); m_currentPts = qMax( pts, m_previousPts );
} }
void ClipWorkflow::mediaPlayerPaused() void ClipWorkflow::mediaPlayerPaused()
{ {
qWarning() << "\n\n\n\nMedia player paused, waiting for buffers to be consumed.Type:" << debugType << "\n\n\n\n"; qWarning() << "\n\nMedia player paused, waiting for buffers to be consumed.Type:" << debugType << "\n\n";
setState( ClipWorkflow::Paused ); setState( ClipWorkflow::Paused );
m_beginPausePts = mdate(); m_beginPausePts = mdate();
// qDebug() << "got pause pts:" << m_beginPausePts; // qDebug() << "got pause pts:" << m_beginPausePts;
......
...@@ -136,8 +136,7 @@ MainWorkflow::getOutput( TrackType trackType ) ...@@ -136,8 +136,7 @@ MainWorkflow::getOutput( TrackType trackType )
{ {
QReadLocker lock2( m_currentFrameLock ); QReadLocker lock2( m_currentFrameLock );
m_tracks[trackType]->getOutput( m_currentFrame[VideoTrack], m_tracks[trackType]->getOutput( m_currentFrame[trackType] );
m_currentFrame[trackType] );
if ( trackType == MainWorkflow::VideoTrack ) if ( trackType == MainWorkflow::VideoTrack )
{ {
m_effectEngine->render(); m_effectEngine->render();
...@@ -264,11 +263,18 @@ MainWorkflow::unmuteTrack( unsigned int trackId, MainWorkflow::TrackType trackTy ...@@ -264,11 +263,18 @@ MainWorkflow::unmuteTrack( unsigned int trackId, MainWorkflow::TrackType trackTy
m_tracks[trackType]->unmuteTrack( trackId ); m_tracks[trackType]->unmuteTrack( trackId );
} }
void toggleBreakPoint()
{
}
void void
MainWorkflow::setCurrentFrame( qint64 currentFrame, MainWorkflow::FrameChangedReason reason ) MainWorkflow::setCurrentFrame( qint64 currentFrame, MainWorkflow::FrameChangedReason reason )
{ {
QWriteLocker lock( m_currentFrameLock ); QWriteLocker lock( m_currentFrameLock );
// if ( m_currentFrame[VideoTrack] == currentFrame )
return ;
toggleBreakPoint();
if ( m_renderStarted == true ) if ( m_renderStarted == true )
{ {
//Since any track can be reactivated, we reactivate all of them, and let them //Since any track can be reactivated, we reactivate all of them, and let them
......
...@@ -103,7 +103,7 @@ TrackHandler::getLength() const ...@@ -103,7 +103,7 @@ TrackHandler::getLength() const
} }
void void
TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame ) TrackHandler::getOutput( qint64 currentFrame )
{ {
m_tmpAudioBuffer = NULL; m_tmpAudioBuffer = NULL;
for ( unsigned int i = 0; i < m_trackCount; ++i ) for ( unsigned int i = 0; i < m_trackCount; ++i )
...@@ -116,7 +116,7 @@ TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame ) ...@@ -116,7 +116,7 @@ TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame )
{ {
StackedBuffer<LightVideoFrame*>* stackedBuffer = StackedBuffer<LightVideoFrame*>* stackedBuffer =
reinterpret_cast<StackedBuffer<LightVideoFrame*>*>( reinterpret_cast<StackedBuffer<LightVideoFrame*>*>(
m_tracks[i]->getOutput( currentFrame, subFrame ) ); m_tracks[i]->getOutput( currentFrame ) );
m_effectEngine->setVideoInput( i + 1, *( stackedBuffer->get() ) ); m_effectEngine->setVideoInput( i + 1, *( stackedBuffer->get() ) );
} }
...@@ -126,7 +126,7 @@ TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame ) ...@@ -126,7 +126,7 @@ TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame )
StackedBuffer<AudioClipWorkflow::AudioSample*>* StackedBuffer<AudioClipWorkflow::AudioSample*>*
stackedBuffer = stackedBuffer =
reinterpret_cast<StackedBuffer<AudioClipWorkflow::AudioSample*>*> ( reinterpret_cast<StackedBuffer<AudioClipWorkflow::AudioSample*>*> (
m_tracks[i]->getOutput( currentFrame, subFrame ) ); m_tracks[i]->getOutput( currentFrame ) );
if ( stackedBuffer != NULL ) if ( stackedBuffer != NULL )
m_tmpAudioBuffer = stackedBuffer->get(); m_tmpAudioBuffer = stackedBuffer->get();
//else if will remain NULL //else if will remain NULL
......
...@@ -49,13 +49,10 @@ class TrackHandler : public QObject ...@@ -49,13 +49,10 @@ class TrackHandler : public QObject
void startRender(); void startRender();
/** /**
* \param currentFrame The current rendering frame (ie the video frame, in all case) * \param currentFrame The current rendering frame (ie the video frame, in all case)
* \param subFrame The underlying system frame. For video TrackWorkflow, it's the same
* as the currentFrame. For an Audio TrackWorkflow, it is the current
* "audio frame"
* \todo This should probably be partialy handled by the trackHandler, as the work * \todo This should probably be partialy handled by the trackHandler, as the work
* is exactly the same for both audio and video trackWorkflow in most of the case... or not. * is exactly the same for both audio and video trackWorkflow in most of the case... or not.
*/ */
void getOutput( qint64 currentFrame, qint64 subFrame ); void getOutput( qint64 currentFrame );
void pause(); void pause();
void unpause(); void unpause();
void activateAll(); void activateAll();
......
...@@ -134,6 +134,7 @@ void* TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame, ...@@ -134,6 +134,7 @@ void* TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
{ {
cw->getStateLock()->lockForRead(); cw->getStateLock()->lockForRead();
qDebug() << "TrackWorkflow::renderClip. currentFrame:" << currentFrame << "trackType:" << m_trackType;
// qDebug() << "Rendering clip" << cw << "state:" << cw->getState() << "Type:" << m_trackType; // qDebug() << "Rendering clip" << cw << "state:" << cw->getState() << "Type:" << m_trackType;
if ( cw->getState() == ClipWorkflow::Rendering || if ( cw->getState() == ClipWorkflow::Rendering ||
cw->getState() == ClipWorkflow::Paused || cw->getState() == ClipWorkflow::Paused ||
...@@ -142,7 +143,10 @@ void* TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame, ...@@ -142,7 +143,10 @@ void* TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
{ {
cw->getStateLock()->unlock(); cw->getStateLock()->unlock();
if ( needRepositioning == true ) if ( needRepositioning == true )
{
qDebug() << "adjusting because of needRepositionning";
adjustClipTime( currentFrame, start, cw ); adjustClipTime( currentFrame, start, cw );
}
return cw->getOutput( ClipWorkflow::Pop ); return cw->getOutput( ClipWorkflow::Pop );
} }
else if ( cw->getState() == ClipWorkflow::Stopped ) else if ( cw->getState() == ClipWorkflow::Stopped )
...@@ -151,6 +155,8 @@ void* TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame, ...@@ -151,6 +155,8 @@ void* TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
cw->initialize(); cw->initialize();
if ( start != currentFrame || cw->getClip()->getBegin() != 0 ) //Clip was not started as its real begining if ( start != currentFrame || cw->getClip()->getBegin() != 0 ) //Clip was not started as its real begining
{ {
qDebug() << "Adjusting clip start. start:" << start << "currentframe:" << currentFrame
<< "clip begin:" << cw->getClip()->getBegin();
adjustClipTime( currentFrame, start, cw ); adjustClipTime( currentFrame, start, cw );
} }
cw->waitForCompleteInit(); cw->waitForCompleteInit();
...@@ -236,7 +242,7 @@ void TrackWorkflow::releasePreviousRender() ...@@ -236,7 +242,7 @@ void TrackWorkflow::releasePreviousRender()
m_videoStackedBuffer->release(); m_videoStackedBuffer->release();
} }
void* TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame ) void* TrackWorkflow::getOutput( qint64 currentFrame )
{ {
releasePreviousRender(); releasePreviousRender();
QReadLocker lock( m_clipsLock ); QReadLocker lock( m_clipsLock );
...@@ -255,13 +261,24 @@ void* TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFra ...@@ -255,13 +261,24 @@ void* TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFra
QMutexLocker lock( m_forceRepositionningMutex ); QMutexLocker lock( m_forceRepositionningMutex );
if ( m_forceRepositionning == true ) if ( m_forceRepositionning == true )
{ {
qDebug() << "Force repositionning is required.";
needRepositioning = true; needRepositioning = true;
m_forceRepositionning = false; m_forceRepositionning = false;
} }
else if ( m_paused == true && subFrame != m_lastFrame ) else if ( m_paused == true && currentFrame != m_lastFrame )
{
needRepositioning = true; needRepositioning = true;
qDebug() << "Paused is true, currentframe != lastframe -> repo";
}
else else
needRepositioning = ( abs( subFrame - m_lastFrame ) > 1 ) ? true : false; {
needRepositioning = ( abs( currentFrame - m_lastFrame ) > 1 ) ? true : false;
if ( needRepositioning == true )
{
qDebug() << "Need repo because more than 1 frame has passed. currentFrame:"
<< currentFrame << "m_lastFrame:" << m_lastFrame;
}
}
} }
while ( it != end ) while ( it != end )
...@@ -289,7 +306,7 @@ void* TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFra ...@@ -289,7 +306,7 @@ void* TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFra
stopClipWorkflow( cw ); stopClipWorkflow( cw );
++it; ++it;
} }
m_lastFrame = subFrame; m_lastFrame = currentFrame;
return ret;