Don't allow image subtitle store to get too big.
authorCarl Hetherington <cth@carlh.net>
Wed, 13 May 2015 09:23:44 +0000 (10:23 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 13 May 2015 09:23:44 +0000 (10:23 +0100)
src/lib/subtitle_decoder.cc

index edb291ab8dc65924c1f314a944fff21b0e1fd825..2efe9afb692bdebcf3b4a3d8e44c7e655a3f02c9 100644 (file)
@@ -82,7 +82,22 @@ SubtitleDecoder::get (list<T> const & subs, list<ContentTimePeriod> const & sp,
                }
        }
 
-       /* XXX: should clear out _decoded_* at some point */
+       /* Discard anything in _decoded_image_subtitles that is outside 5 seconds either side of period */
+       
+       list<ContentImageSubtitle>::iterator i = _decoded_image_subtitles.begin();
+       while (i != _decoded_image_subtitles.end()) {
+               list<ContentImageSubtitle>::iterator tmp = i;
+               ++tmp;
+
+               if (
+                       i->period().to < (period.from - ContentTime::from_seconds (5)) ||
+                       i->period().from > (period.to + ContentTime::from_seconds (5))
+                       ) {
+                       _decoded_image_subtitles.erase (i);
+               }
+
+               i = tmp;
+       }
 
        return out;
 }