Commit 76c37c46 authored by Denis Charmet's avatar Denis Charmet Committed by Jean-Baptiste Kempf

Free unused resources when using linked mkvs

(cherry picked from commit 0fafbb87581a526dcdd7183cd49a472ada2bb8d7)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent c9cb8bce
...@@ -691,6 +691,38 @@ bool demux_sys_t::PreloadLinked() ...@@ -691,6 +691,38 @@ bool demux_sys_t::PreloadLinked()
return true; return true;
} }
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 )
{
streams[i] = NULL;
delete p_s;
}
}
for( i = 0; i < opened_segments.size(); i++)
{
if( !opened_segments[i]->b_preloaded )
{
delete opened_segments[i];
opened_segments[i] = NULL;
}
}
}
virtual_segment_c *demux_sys_t::VirtualFromSegments( std::vector<matroska_segment_c*> *p_segments ) const virtual_segment_c *demux_sys_t::VirtualFromSegments( std::vector<matroska_segment_c*> *p_segments ) const
{ {
if ( p_segments->empty() ) if ( p_segments->empty() )
......
...@@ -382,6 +382,7 @@ public: ...@@ -382,6 +382,7 @@ public:
void PreloadFamily( const matroska_segment_c & of_segment ); void PreloadFamily( const matroska_segment_c & of_segment );
bool PreloadLinked(); bool PreloadLinked();
void FreeUnused();
bool PreparePlayback( virtual_segment_c *p_new_segment ); bool PreparePlayback( virtual_segment_c *p_new_segment );
matroska_stream_c *AnalyseAllSegmentsFound( demux_t *p_demux, EbmlStream *p_estream, bool b_initial = false ); matroska_stream_c *AnalyseAllSegmentsFound( demux_t *p_demux, EbmlStream *p_estream, bool b_initial = false );
void JumpTo( virtual_segment_c & p_segment, virtual_chapter_c * p_chapter ); void JumpTo( virtual_segment_c & p_segment, virtual_chapter_c * p_chapter );
......
...@@ -246,6 +246,8 @@ static int Open( vlc_object_t * p_this ) ...@@ -246,6 +246,8 @@ static int Open( vlc_object_t * p_this )
goto error; goto error;
} }
p_sys->FreeUnused();
p_sys->InitUi(); p_sys->InitUi();
return VLC_SUCCESS; return VLC_SUCCESS;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment