[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 17:17:23 CET 2018


vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Jan 25 11:46:18 2018 +0100| [bfff23e9bcfdcd27a1ca6aa87a3810a9af7d0dd4] | committer: Jean-Baptiste Kempf

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

(cherry picked from commit 72f0a5b799c0dab92cb6550fb5c74b452ec773ef)

Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 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 a13a0a8d3d..2d58db352a 100644
--- a/modules/demux/mkv/demux.cpp
+++ b/modules/demux/mkv/demux.cpp
@@ -704,17 +704,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 1d57567cc1..e6dd08a795 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -859,3 +859,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