[vlmc-devel] commit: TracksHandler: Simplifying and fixing the track end detection. ( Hugo Beauzée-Luyssen )
git at videolan.org
git at videolan.org
Sun Aug 15 21:12:36 CEST 2010
vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sun Aug 15 23:12:20 2010 +0200| [5dd47b69d1aee96efcad9e96f770f90d486e93d7] | committer: Hugo Beauzée-Luyssen
TracksHandler: Simplifying and fixing the track end detection.
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=5dd47b69d1aee96efcad9e96f770f90d486e93d7
---
src/Workflow/TrackHandler.cpp | 13 ++++++-------
src/Workflow/TrackHandler.h | 6 +-----
src/Workflow/TrackWorkflow.cpp | 7 -------
src/Workflow/TrackWorkflow.h | 3 ---
4 files changed, 7 insertions(+), 22 deletions(-)
diff --git a/src/Workflow/TrackHandler.cpp b/src/Workflow/TrackHandler.cpp
index 29b7d99..329387a 100644
--- a/src/Workflow/TrackHandler.cpp
+++ b/src/Workflow/TrackHandler.cpp
@@ -29,7 +29,6 @@
TrackHandler::TrackHandler( unsigned int nbTracks, MainWorkflow::TrackType trackType ) :
m_trackCount( nbTracks ),
- m_nbRenderingTracks( 0 ),
m_trackType( trackType ),
m_length( 0 )
{
@@ -37,7 +36,6 @@ TrackHandler::TrackHandler( unsigned int nbTracks, MainWorkflow::TrackType track
for ( unsigned int i = 0; i < nbTracks; ++i )
{
m_tracks[i].setPtr( new TrackWorkflow( trackType ) );
- connect( m_tracks[i], SIGNAL( trackEndReached() ), this, SLOT( trackEndReached() ), Qt::DirectConnection );
}
}
@@ -78,7 +76,6 @@ TrackHandler::startRender()
{
for ( unsigned int i = 0; i < m_trackCount; ++i )
{
- m_nbRenderingTracks.fetchAndAddAcquire( 1 );
m_tracks[i]->preload();
}
}
@@ -106,10 +103,13 @@ TrackHandler::getLength() const
void*
TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
{
+ bool validTrack = false;
+
for ( int i = m_trackCount - 1; i >= 0; --i )
{
if ( m_tracks[i].activated() == false || m_tracks[i]->hasFrameToRender( currentFrame ) )
continue ;
+ validTrack = true;
if ( m_trackType == MainWorkflow::VideoTrack )
{
void* ret = m_tracks[i]->getOutput( currentFrame, subFrame, paused );
@@ -132,6 +132,8 @@ TrackHandler::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
return stackedBuffer->get();
}
}
+ if ( validTrack == false )
+ allTracksEnded();
return NULL;
}
@@ -216,11 +218,8 @@ TrackHandler::endIsReached() const
}
void
-TrackHandler::trackEndReached()
+TrackHandler::allTracksEnded()
{
- qDebug() << "deactivated track. remaining:" << m_nbRenderingTracks - 1;
- if ( m_nbRenderingTracks.fetchAndAddAcquire( -1 ) != 1 )
- return ;
m_endReached = true;
emit tracksEndReached();
}
diff --git a/src/Workflow/TrackHandler.h b/src/Workflow/TrackHandler.h
index 7b6d5a6..b2c585e 100644
--- a/src/Workflow/TrackHandler.h
+++ b/src/Workflow/TrackHandler.h
@@ -105,20 +105,16 @@ class TrackHandler : public QObject
private:
void computeLength();
+ void allTracksEnded();
private:
Toggleable<TrackWorkflow*>* m_tracks;
unsigned int m_trackCount;
- QAtomicInt m_nbRenderingTracks;
MainWorkflow::TrackType m_trackType;
qint64 m_length;
unsigned int m_highestTrackNumber;
bool m_endReached;
-
- private slots:
- void trackEndReached();
-
signals:
void tracksEndReached();
};
diff --git a/src/Workflow/TrackWorkflow.cpp b/src/Workflow/TrackWorkflow.cpp
index ec3645a..e4ea414 100644
--- a/src/Workflow/TrackWorkflow.cpp
+++ b/src/Workflow/TrackWorkflow.cpp
@@ -293,11 +293,6 @@ TrackWorkflow::getOutput( qint64 currentFrame, qint64 subFrame, bool paused )
if ( m_lastFrame == -1 )
m_lastFrame = currentFrame;
- if ( hasFrameToRender( currentFrame ) == true )
- {
- emit trackEndReached();
- //We continue, as there can be ClipWorkflow that requires to be stopped.
- }
{
QMutexLocker lock2( m_renderOneFrameMutex );
if ( m_renderOneFrame == true )
@@ -388,8 +383,6 @@ Clip* TrackWorkflow::removeClip( const QUuid& id )
computeLength();
cw->disconnect();
delete cw;
- if ( m_length == 0 )
- emit trackEndReached();
return clip;
}
++it;
diff --git a/src/Workflow/TrackWorkflow.h b/src/Workflow/TrackWorkflow.h
index e1b1a08..9ce94fe 100644
--- a/src/Workflow/TrackWorkflow.h
+++ b/src/Workflow/TrackWorkflow.h
@@ -119,9 +119,6 @@ class TrackWorkflow : public QObject
qint64 m_lastFrame;
StackedBuffer<Workflow::Frame*>* m_videoStackedBuffer;
StackedBuffer<Workflow::AudioSample*>* m_audioStackedBuffer;
-
- signals:
- void trackEndReached();
};
#endif // TRACKWORKFLOW_H
More information about the Vlmc-devel
mailing list