From 6c02555397ca599a7ec9ea781e492631ecf1c7f2 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 15 Apr 2020 17:03:37 +0200 Subject: player: slightly improve use of secondary track selection limits Apparently, this was a bit of a mess, which caused the bug fixed by commit ec7f2388af2df. Try to improve this, and only use track selection entries that exist. --- player/sub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'player/sub.c') diff --git a/player/sub.c b/player/sub.c index 599430ac21..a40a6d5e9d 100644 --- a/player/sub.c +++ b/player/sub.c @@ -39,7 +39,7 @@ // 0: primary sub, 1: secondary sub, -1: not selected static int get_order(struct MPContext *mpctx, struct track *track) { - for (int n = 0; n < NUM_PTRACKS; n++) { + for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) { if (mpctx->current_track[n][STREAM_SUB] == track) return n; } @@ -129,7 +129,7 @@ static bool update_subtitle(struct MPContext *mpctx, double video_pts, bool update_subtitles(struct MPContext *mpctx, double video_pts) { bool ok = true; - for (int n = 0; n < NUM_PTRACKS; n++) + for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) ok &= update_subtitle(mpctx, video_pts, mpctx->current_track[n][STREAM_SUB]); return ok; } @@ -201,6 +201,6 @@ void reinit_sub(struct MPContext *mpctx, struct track *track) void reinit_sub_all(struct MPContext *mpctx) { - for (int n = 0; n < NUM_PTRACKS; n++) + for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) reinit_sub(mpctx, mpctx->current_track[n][STREAM_SUB]); } -- cgit v1.2.3