[vlmc-devel] commit: EffectUser: Add support for adding ClipHelper. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Wed Sep 8 19:45:15 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Wed Sep  8 18:07:14 2010 +0200| [4676be87ca99d5206ddf7a42ba23e270b8629fcf] | committer: Hugo Beauzée-Luyssen 

EffectUser: Add support for adding ClipHelper.

Adding a signal when adding an effect.

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=4676be87ca99d5206ddf7a42ba23e270b8629fcf
---

 src/EffectsEngine/EffectUser.cpp |   31 ++++++++++++++++++++++++-------
 src/EffectsEngine/EffectUser.h   |    3 +++
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/src/EffectsEngine/EffectUser.cpp b/src/EffectsEngine/EffectUser.cpp
index 300b488..acdf154 100644
--- a/src/EffectsEngine/EffectUser.cpp
+++ b/src/EffectsEngine/EffectUser.cpp
@@ -40,6 +40,7 @@ EffectUser::EffectUser() :
 
 EffectUser::~EffectUser()
 {
+    cleanEffects();
     delete m_effectsLock;
 }
 
@@ -48,19 +49,24 @@ EffectUser::addEffect( Effect *effect, qint64 start /*= 0*/, qint64 end /*= -1*/
 {
     //FIXME: Check it the effect type is supported
     EffectInstance  *effectInstance = effect->createInstance();
-    if ( m_isRendering == true )
-        effectInstance->init( m_width, m_height );
     EffectHelper *ret = new EffectHelper( effectInstance, start, end );
+    addEffect( ret );
+    return ret;
+}
 
+void
+EffectUser::addEffect( EffectHelper *effectHelper )
+{
+    if ( m_isRendering == true )
+        effectHelper->effectInstance()->init( m_width, m_height );
     QWriteLocker    lock( m_effectsLock );
-    if ( effect->type() == Effect::Filter )
-        m_filters.push_back( ret );
+    if ( effectHelper->effectInstance()->effect()->type() == Effect::Filter )
+        m_filters.push_back( effectHelper );
     else
-        m_mixers.push_back( ret );
-    return ret;
+        m_mixers.push_back( effectHelper );
+    emit effectAdded( effectHelper );
 }
 
-
 quint32*
 EffectUser::applyFilters( const Workflow::Frame* frame,
                              qint64 currentFrame, double time )
@@ -302,3 +308,14 @@ EffectUser::moveEffect( EffectHelper *helper, qint64 newPos )
     }
     qWarning() << "Can't find effect" << helper->uuid();
 }
+
+void
+EffectUser::cleanEffects()
+{
+    QWriteLocker    lock( m_effectsLock );
+
+    qDeleteAll( m_filters );
+    qDeleteAll( m_mixers );
+    m_filters.clear();
+    m_mixers.clear();
+}
diff --git a/src/EffectsEngine/EffectUser.h b/src/EffectsEngine/EffectUser.h
index f541d62..ba0bc03 100644
--- a/src/EffectsEngine/EffectUser.h
+++ b/src/EffectsEngine/EffectUser.h
@@ -43,12 +43,14 @@ class EffectUser : public QObject
          *  \param      effect  The effect instance. Can be either mixer or filter.
          */
         EffectHelper                    *addEffect( Effect *effect, qint64 start = 0, qint64 end = -1 );
+        void                            addEffect( EffectHelper *effect );
         void                            moveEffect( EffectHelper *helper, qint64 newPos );
         void                            removeEffect( EffectHelper *helper );
         const EffectsEngine::EffectList &effects( Effect::Type type ) const;
         void                            removeEffect( Effect::Type type, quint32 idx );
         void                            swapFilters( quint32 idx, quint32 idx2 );
         quint32                         count( Effect::Type type ) const;
+        void                            cleanEffects();
 
     protected:
         EffectUser();
@@ -81,6 +83,7 @@ class EffectUser : public QObject
         EffectsEngine::EffectList               m_filters;
 
     signals:
+        void                                    effectAdded( EffectHelper *helper );
         void                                    effectMoved( EffectHelper *helper, qint64 newPos );
         void                                    effectRemoved( EffectHelper *helper );
 };



More information about the Vlmc-devel mailing list