[vlmc-devel] EffectHelper: Always detach when setting target

Yikai Lu git at videolan.org
Wed Jun 29 09:28:29 CEST 2016


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Wed Jun 29 16:27:01 2016 +0900| [e7c094ff0b6224440a5d084042499c34c632a035] | committer: Yikai Lu

EffectHelper: Always detach when setting target

> https://code.videolan.org/videolan/vlmc/commit/e7c094ff0b6224440a5d084042499c34c632a035
---

 src/Backend/IFilter.h              | 1 +
 src/Backend/MLT/MLTFilter.cpp      | 9 +++++++++
 src/Backend/MLT/MLTFilter.h        | 1 +
 src/EffectsEngine/EffectHelper.cpp | 1 +
 4 files changed, 12 insertions(+)

diff --git a/src/Backend/IFilter.h b/src/Backend/IFilter.h
index dad55c6..19b3573 100644
--- a/src/Backend/IFilter.h
+++ b/src/Backend/IFilter.h
@@ -70,6 +70,7 @@ namespace Backend
         virtual int64_t         begin() const = 0;
         virtual int64_t         end() const = 0;
         virtual int64_t         length() const = 0;
+        virtual void            detach() = 0;
 
         virtual std::shared_ptr<IInput> input() const = 0;
 
diff --git a/src/Backend/MLT/MLTFilter.cpp b/src/Backend/MLT/MLTFilter.cpp
index 7e57b6a..f889ef4 100644
--- a/src/Backend/MLT/MLTFilter.cpp
+++ b/src/Backend/MLT/MLTFilter.cpp
@@ -229,6 +229,15 @@ MLTFilter::length() const
     return length ? length : MLTInput::Unlimited;
 }
 
+void
+MLTFilter::detach()
+{
+    if ( m_connectedProducer.get() == nullptr )
+        return;
+    m_connectedProducer->detach( *m_filter );
+    m_connectedProducer.reset( nullptr );
+}
+
 std::shared_ptr<Backend::IInput>
 MLTFilter::input() const
 {
diff --git a/src/Backend/MLT/MLTFilter.h b/src/Backend/MLT/MLTFilter.h
index 489bad5..73ab8d1 100644
--- a/src/Backend/MLT/MLTFilter.h
+++ b/src/Backend/MLT/MLTFilter.h
@@ -101,6 +101,7 @@ namespace MLT
         virtual int64_t begin() const override;
         virtual int64_t end() const override;
         virtual int64_t length() const override;
+        virtual void    detach() override;
 
         virtual std::shared_ptr<IInput> input() const override;
 
diff --git a/src/EffectsEngine/EffectHelper.cpp b/src/EffectsEngine/EffectHelper.cpp
index d557a98..01829ed 100644
--- a/src/EffectsEngine/EffectHelper.cpp
+++ b/src/EffectsEngine/EffectHelper.cpp
@@ -265,6 +265,7 @@ EffectHelper::isValid() const
 void
 EffectHelper::setTarget( Backend::IInput* input )
 {
+    m_filter->detach();
     input->attach( *m_filter );
 }
 



More information about the Vlmc-devel mailing list