summaryrefslogtreecommitdiffstats
path: root/player/sub.c
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-08-09 16:39:58 -0500
committerDudemanguy <random342@airmail.cc>2023-08-11 22:28:50 +0000
commita323dfae426e43451f4d3e08a9a63cb7d1c1ace9 (patch)
treea306f33c69c47bc4589b11a3d5831ff05ef80def /player/sub.c
parent9ff2caff9875fa761b19edccd4ecdf84937d451f (diff)
downloadmpv-a323dfae426e43451f4d3e08a9a63cb7d1c1ace9.tar.bz2
mpv-a323dfae426e43451f4d3e08a9a63cb7d1c1ace9.tar.xz
sub: fix switching tracks while paused
Internal subtitles were not shown when switching between tracks while mpv was paused. The reason for this is simply because the demuxer data isn't available yet when the track switch happens. Fixing it is basically just retrying until the packet is actually available when the player is paused. Fixes #8311.
Diffstat (limited to 'player/sub.c')
-rw-r--r--player/sub.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/player/sub.c b/player/sub.c
index e1df0a7386..7dd1f2ccb6 100644
--- a/player/sub.c
+++ b/player/sub.c
@@ -100,7 +100,7 @@ static bool update_subtitle(struct MPContext *mpctx, double video_pts,
sub_preload(dec_sub);
}
- if (!sub_read_packets(dec_sub, video_pts))
+ if (!sub_read_packets(dec_sub, video_pts, mpctx->paused))
return false;
// Handle displaying subtitles on terminal; never done for secondary subs
@@ -201,8 +201,10 @@ void reinit_sub(struct MPContext *mpctx, struct track *track)
osd_set_sub(mpctx->osd, order, track->d_sub);
sub_control(track->d_sub, SD_CTRL_SET_TOP, &order);
+ // When paused we have to wait for packets to be available.
+ // So just retry until we get a packet in this case.
if (mpctx->playback_initialized)
- update_subtitles(mpctx, mpctx->playback_pts);
+ while (!update_subtitles(mpctx, mpctx->playback_pts) && mpctx->paused);
}
void reinit_sub_all(struct MPContext *mpctx)