Fix doubled subtitles (again).
authorCarl Hetherington <cth@carlh.net>
Thu, 5 Dec 2024 22:36:51 +0000 (23:36 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 9 Dec 2024 00:40:29 +0000 (01:40 +0100)
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

index 09d1e2786617dc9be1b8e52fdce60e242447223d..f57c9efe848502293f028e73a652058b27c72f9f 100644 (file)
@@ -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);
 }