From 7e690d21278df14b113f3602cbbd43f6214fd614 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 9 Jun 2014 23:13:27 +0100 Subject: Emit the large bits of pointless silence which are the cause of #252 in half-second chunks, which at least fixes the out-of-memory condition. --- ChangeLog | 2 ++ src/lib/ffmpeg_decoder.cc | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index d473393f1..4ad416fcc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2014-06-09 Carl Hetherington + * Work-around out-of-memory crashes with large start trims (#252). + * Version 1.69.24 released. 2014-06-06 Carl Hetherington diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 04dd7fd2d..a51b521d0 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -422,15 +422,18 @@ FFmpegDecoder::decode_audio_packet () if (pts > 0) { /* Emit some silence */ - shared_ptr silence ( - new AudioBuffers ( - _ffmpeg_content->audio_channels(), - pts * _ffmpeg_content->content_audio_frame_rate() - ) - ); + int64_t frames = pts * _ffmpeg_content->content_audio_frame_rate (); + while (frames > 0) { + int64_t const this_time = min (frames, (int64_t) _ffmpeg_content->content_audio_frame_rate() / 2); + + shared_ptr silence ( + new AudioBuffers (_ffmpeg_content->audio_channels(), this_time) + ); - silence->make_silent (); - audio (silence, _audio_position); + silence->make_silent (); + audio (silence, _audio_position); + frames -= this_time; + } } } -- cgit v1.2.3