From 5a980207377e67b6aa3595d0cde441ae7659f5a6 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 5 Dec 2024 23:36:51 +0100 Subject: Fix doubled subtitles (again). This was re-introduced when 94618a724124cbf5fe9f0b47a3fdce601fcd5581 reverted a previous attempt at a fix. At the time I couldn't understand the doubled-subtitles problem, but it's apparent in the test introduced in the next commit. This is another attempt to fix it by only sending a "stop" for a subtitle if we didn't already stop the subtitle because the next one arrived. --- src/lib/ffmpeg_decoder.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/lib/ffmpeg_decoder.cc') diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 09d1e2786..f57c9efe8 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -243,6 +243,11 @@ FFmpegDecoder::pass () decode_and_process_audio_packet (packet); } + if (_have_current_subtitle && _current_subtitle_to && position() > *_current_subtitle_to) { + only_text()->emit_stop(*_current_subtitle_to); + _have_current_subtitle = false; + } + av_packet_free (&packet); return false; } @@ -697,10 +702,6 @@ FFmpegDecoder::decode_and_process_subtitle_packet (AVPacket* packet) only_text()->emit_bitmap_start(bitmap_text); } - if (_current_subtitle_to) { - only_text()->emit_stop (*_current_subtitle_to); - } - avsubtitle_free (&sub); } -- cgit v1.2.3