[vlc-commits] sout: sdi: add a method to release the decoder

Steve Lhomme git at videolan.org
Mon Dec 9 11:51:09 CET 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Jul  9 09:38:23 2019 +0200| [6e6bd2608fbb4faff91b273d5ea2054ac9e23275] | committer: Steve Lhomme

sout: sdi: add a method to release the decoder

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

We already need to clean some ES formats anyway.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6e6bd2608fbb4faff91b273d5ea2054ac9e23275
---

 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 bc835a6596..a93c13d32d 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 b0f507d8a4..b06058d7eb 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;



More information about the vlc-commits mailing list