summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-03-05 01:33:34 +0000
committerCarl Hetherington <cth@carlh.net>2018-03-05 01:33:46 +0000
commit85cd541c1ec9c9b608d7ec2e4ec3c575166bb863 (patch)
treef42fa4257c2b81f65ad7fe952ff6cbf8a8c564d7
parent1bc66f94a95cc1e7f9538564c9868e34453a4ff2 (diff)
Fix OOM condition when seeking near to the end of long FFmpeg files (#1230).
-rw-r--r--src/lib/ffmpeg_decoder.cc18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index a5b6af7de..ea41acf23 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -138,12 +138,18 @@ FFmpegDecoder::flush ()
BOOST_FOREACH (shared_ptr<FFmpegAudioStream> i, _ffmpeg_content->ffmpeg_audio_streams ()) {
ContentTime a = audio->stream_position(i);
- while (a < full_length) {
- ContentTime to_do = min (full_length - a, ContentTime::from_seconds (0.1));
- shared_ptr<AudioBuffers> silence (new AudioBuffers (i->channels(), to_do.frames_ceil (i->frame_rate())));
- silence->make_silent ();
- audio->emit (i, silence, a);
- a += to_do;
+ /* Unfortunately if a is 0 that really means that we don't know the stream position since
+ there has been no data on it since the last seek. In this case we'll just do nothing
+ here. I'm not sure if that's the right idea.
+ */
+ if (a > ContentTime()) {
+ while (a < full_length) {
+ ContentTime to_do = min (full_length - a, ContentTime::from_seconds (0.1));
+ shared_ptr<AudioBuffers> silence (new AudioBuffers (i->channels(), to_do.frames_ceil (i->frame_rate())));
+ silence->make_silent ();
+ audio->emit (i, silence, a);
+ a += to_do;
+ }
}
}