From d42bc731c125170efb1bb7b8c9f990a3e9fa5b57 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 15 Nov 2022 00:44:37 +0100 Subject: Improve flushing behaviour when there is a lot of space to fill (#2364). Previously a call to flush() could result in a lot of audio being emitted from the decoder (if there is a big gap between the end of the audio and the video). This would end up being emitted in one chunk from the player, crashing the audio analyser with an OOM in some cases. --- src/lib/ffmpeg_decoder.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/lib/ffmpeg_decoder.h') diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h index 9de44333c..1e47e2fca 100644 --- a/src/lib/ffmpeg_decoder.h +++ b/src/lib/ffmpeg_decoder.h @@ -58,7 +58,12 @@ public: private: friend struct ::ffmpeg_pts_offset_test; - bool flush (); + enum class FlushResult { + DONE, + AGAIN + }; + + FlushResult flush(); AVSampleFormat audio_sample_format (std::shared_ptr stream) const; int bytes_per_audio_sample (std::shared_ptr stream) const; @@ -77,6 +82,9 @@ private: void maybe_add_subtitle (); + FlushResult flush_codecs(); + FlushResult flush_fill(); + VideoFilterGraphSet _filter_graphs; dcpomatic::ContentTime _pts_offset; @@ -87,4 +95,12 @@ private: std::shared_ptr _black_image; std::map, boost::optional> _next_time; + + enum class FlushState { + CODECS, + AUDIO_DECODER, + FILL, + }; + + FlushState _flush_state = FlushState::CODECS; }; -- cgit v1.2.3