[vlc-commits] demux:mkv: move the code to check if a matroska_stream_c is used inside matroska_stream_c

Steve Lhomme git at videolan.org
Thu Jan 25 12:54:22 CET 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Jan 25 11:46:18 2018 +0100| [72f0a5b799c0dab92cb6550fb5c74b452ec773ef] | committer: Steve Lhomme

demux:mkv: move the code to check if a matroska_stream_c is used inside matroska_stream_c

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

 modules/demux/mkv/demux.cpp | 11 +----------
 modules/demux/mkv/mkv.cpp   | 10 ++++++++++
 modules/demux/mkv/mkv.hpp   |  2 ++
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/modules/demux/mkv/demux.cpp b/modules/demux/mkv/demux.cpp
index 23f06f55f6..1789706b52 100644
--- a/modules/demux/mkv/demux.cpp
+++ b/modules/demux/mkv/demux.cpp
@@ -707,17 +707,8 @@ void demux_sys_t::FreeUnused()
     size_t i;
     for( i = 0; i < streams.size(); i++ )
     {
-        bool used = false;
         struct matroska_stream_c *p_s = streams[i];
-        for( size_t j = 0; j < p_s->segments.size(); j++ )
-        {
-            if( p_s->segments[j]->b_preloaded )
-            {
-                used = true;
-                break;
-            }
-        }
-        if( !used )
+        if( !p_s->isUsed() )
         {
             streams[i] = NULL;
             delete p_s;
diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index 093113c125..570ad0870f 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -876,3 +876,13 @@ matroska_stream_c::matroska_stream_c( stream_t *s, bool owner )
     :io_callback( new vlc_stream_io_callback( s, owner ) )
     ,estream( EbmlStream( *io_callback ) )
 {}
+
+bool matroska_stream_c::isUsed() const
+{
+    for( size_t j = 0; j < segments.size(); j++ )
+    {
+        if( segments[j]->b_preloaded )
+            return true;
+    }
+    return false;
+}
diff --git a/modules/demux/mkv/mkv.hpp b/modules/demux/mkv/mkv.hpp
index 2b04d08066..59adc48eb9 100644
--- a/modules/demux/mkv/mkv.hpp
+++ b/modules/demux/mkv/mkv.hpp
@@ -162,6 +162,8 @@ struct matroska_stream_c
         delete io_callback;
     }
 
+    bool isUsed() const;
+
     IOCallback         * io_callback;
     EbmlStream         estream;
 



More information about the vlc-commits mailing list