[vlmc-devel] MLTFilter: Use unique_ptr to manage its connected Mlt::Producer

Yikai Lu git at videolan.org
Wed Jun 29 08:20:13 CEST 2016


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Wed Jun 29 15:04:05 2016 +0900| [e0b7b97f0f26fa2951223c0c02f03d2ccba4201b] | committer: Yikai Lu

MLTFilter: Use unique_ptr to manage its connected Mlt::Producer

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

 src/Backend/MLT/MLTFilter.cpp | 7 +++----
 src/Backend/MLT/MLTFilter.h   | 2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/Backend/MLT/MLTFilter.cpp b/src/Backend/MLT/MLTFilter.cpp
index 91870f9..7e57b6a 100644
--- a/src/Backend/MLT/MLTFilter.cpp
+++ b/src/Backend/MLT/MLTFilter.cpp
@@ -155,7 +155,6 @@ MLTFilterInfo::setProperties( Mlt::Properties* properties )
 }
 
 MLTFilter::MLTFilter( Backend::IProfile& profile, const char* id )
-    : m_connectedProducer( nullptr )
 {
     MLTProfile& mltProfile = static_cast<MLTProfile&>( profile );
     m_filter = new Mlt::Filter( *mltProfile.m_profile, id );
@@ -173,7 +172,7 @@ MLTFilter::MLTFilter( const char *id )
 MLTFilter::MLTFilter( Mlt::Filter* filter, Mlt::Producer* connectedProducer )
 {
     m_filter = filter;
-    m_connectedProducer = connectedProducer;
+    m_connectedProducer.reset( new Mlt::Producer( connectedProducer->get_producer() ) );
     m_service = filter;
 }
 
@@ -196,7 +195,7 @@ MLTFilter::connect( Backend::IInput& input, int index )
     if ( mltInput == nullptr )
         return true;
 
-    m_connectedProducer = mltInput->m_producer;
+    m_connectedProducer.reset( new Mlt::Producer( mltInput->m_producer->get_producer() ) );
 
     return m_filter->connect( *mltInput->m_producer, index );
 }
@@ -233,7 +232,7 @@ MLTFilter::length() const
 std::shared_ptr<Backend::IInput>
 MLTFilter::input() const
 {
-    return std::make_shared<MLTInput>( m_connectedProducer );
+    return std::make_shared<MLTInput>( new Mlt::Producer( m_connectedProducer->get_producer() ) );
 }
 
 const Backend::IFilterInfo&
diff --git a/src/Backend/MLT/MLTFilter.h b/src/Backend/MLT/MLTFilter.h
index 9ab8b66..489bad5 100644
--- a/src/Backend/MLT/MLTFilter.h
+++ b/src/Backend/MLT/MLTFilter.h
@@ -108,7 +108,7 @@ namespace MLT
 
     private:
         Mlt::Filter*        m_filter;
-        Mlt::Producer*      m_connectedProducer;
+        std::unique_ptr<Mlt::Producer>      m_connectedProducer;
 
     friend class MLTMultiTrack;
     friend class MLTInput;



More information about the Vlmc-devel mailing list