From 0721b87237faa9a1b20d5da30715a6a3d36cab87 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Tue, 15 Oct 2024 10:51:24 -0500 Subject: [PATCH] player: make redraw_sub flag work on a per track basis There can be multiple subtitle tracks (secondary subs) so this logic should be handled separately. --- player/core.h | 6 +++--- player/sub.c | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/player/core.h b/player/core.h index 4ed7872a4f..dce3ce4734 100644 --- a/player/core.h +++ b/player/core.h @@ -141,6 +141,9 @@ struct track { // Current subtitle state (or cached state if selected==false). struct dec_sub *d_sub; + /* Heuristic for potentially redrawing subs. */ + bool redraw_subs; + // Current decoding state (NULL if selected==false) struct mp_decoder_wrapper *dec; @@ -408,9 +411,6 @@ typedef struct MPContext { int last_chapter_seek; bool last_chapter_flag; - /* Heuristic for potentially redrawing subs. */ - bool redraw_subs; - bool paused; // internal pause state bool playback_active; // not paused, restarting, loading, unloading bool in_playloop; diff --git a/player/sub.c b/player/sub.c index c3bb0ee7a5..255c1e565e 100644 --- a/player/sub.c +++ b/player/sub.c @@ -60,8 +60,7 @@ void redraw_subs(struct MPContext *mpctx) if (mpctx->current_track[n][STREAM_SUB] && mpctx->current_track[n][STREAM_SUB]->d_sub) { - mpctx->redraw_subs = true; - break; + mpctx->current_track[n][STREAM_SUB]->redraw_subs = true; } } } @@ -129,9 +128,9 @@ static bool update_subtitle(struct MPContext *mpctx, double video_pts, // Check if we need to update subtitles for these special cases. Always // update on discontinuities like seeking or a new file. - if (sub_updated || mpctx->redraw_subs || osd_pts == MP_NOPTS_VALUE) { + if (sub_updated || track->redraw_subs || osd_pts == MP_NOPTS_VALUE) { // Always force a redecode of all packets if we seek on a still image. - if (mpctx->redraw_subs && still_image) + if (track->redraw_subs && still_image) sub_redecode_cached_packets(dec_sub); // Handle displaying subtitles on terminal; never done for secondary subs @@ -153,7 +152,7 @@ static bool update_subtitle(struct MPContext *mpctx, double video_pts, } } - mpctx->redraw_subs = false; + track->redraw_subs = false; return packets_read; }