[vlc-devel] [PATCH 08/11] sout: sdi: add a method to release the decoder

Steve Lhomme robux4 at ycbcr.xyz
Mon Nov 4 13:05:27 CET 2019


We may have to release resources associated to the decoder, like the decoder
device.

We already need to clean some ES formats anyway.
---
 modules/stream_out/sdi/SDIStream.cpp | 22 ++++++++++++----------
 modules/stream_out/sdi/SDIStream.hpp |  1 +
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/modules/stream_out/sdi/SDIStream.cpp b/modules/stream_out/sdi/SDIStream.cpp
index d27a0cd61f0..ef6b10a646d 100644
--- a/modules/stream_out/sdi/SDIStream.cpp
+++ b/modules/stream_out/sdi/SDIStream.cpp
@@ -250,12 +250,7 @@ void AbstractDecodedStream::deinit()
         threadEnd = true;
         vlc_mutex_unlock(&inputLock);
         vlc_join(thread, NULL);
-        struct decoder_owner *p_owner;
-        p_owner = container_of(p_decoder, struct decoder_owner, dec);
-        es_format_Clean(&p_owner->decoder_out);
-        es_format_Clean(&p_owner->last_fmt_update);
-        decoder_Destroy(p_decoder);
-        p_decoder = NULL;
+        ReleaseDecoder();
     }
 }
 
@@ -290,10 +285,7 @@ bool AbstractDecodedStream::init(const es_format_t *p_fmt)
     if(!p_decoder->p_module)
     {
         msg_Err(p_stream, "cannot find %s for %4.4s", category, (char *)&p_fmt->i_codec);
-        es_format_Clean(&p_owner->decoder_out);
-        es_format_Clean(&p_owner->last_fmt_update);
-        decoder_Destroy( p_decoder );
-        p_decoder = NULL;
+        ReleaseDecoder();
         return false;
     }
 
@@ -427,6 +419,16 @@ bool AbstractDecodedStream::ReachedPlaybackTime(vlc_tick_t t)
     return b;
 }
 
+void AbstractDecodedStream::ReleaseDecoder()
+{
+    struct decoder_owner *p_owner;
+    p_owner = container_of(p_decoder, struct decoder_owner, dec);
+    es_format_Clean(&p_owner->decoder_out);
+    es_format_Clean(&p_owner->last_fmt_update);
+    decoder_Destroy( p_decoder );
+    p_decoder = NULL;
+}
+
 void AbstractDecodedStream::setOutputFormat(const es_format_t *p_fmt)
 {
     es_format_Clean(&requestedoutput);
diff --git a/modules/stream_out/sdi/SDIStream.hpp b/modules/stream_out/sdi/SDIStream.hpp
index b65e199ae09..425f2b3e539 100644
--- a/modules/stream_out/sdi/SDIStream.hpp
+++ b/modules/stream_out/sdi/SDIStream.hpp
@@ -138,6 +138,7 @@ namespace sdi_sout
             static void *decoderThreadCallback(void *);
             void decoderThread();
             void deinit();
+            virtual void ReleaseDecoder();
             es_format_t requestedoutput;
             std::queue<block_t *> inputQueue;
             vlc_mutex_t inputLock;
-- 
2.17.1



More information about the vlc-devel mailing list