diff options
author | Dudemanguy <random342@airmail.cc> | 2023-09-27 21:52:44 -0500 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-09-27 22:38:13 -0500 |
commit | f40bbfec4fcd2d9a787a4d98ec7698a646e5607e (patch) | |
tree | 5fcf3c8c80548e578d6cc6f730c5cc5f33ea6e85 /sub/dec_sub.c | |
parent | 09b04fbf0940151f5856aa4396f9b467622371a3 (diff) | |
download | mpv-f40bbfec4fcd2d9a787a4d98ec7698a646e5607e.tar.bz2 mpv-f40bbfec4fcd2d9a787a4d98ec7698a646e5607e.tar.xz |
demux: improve stream selection state
This replaces the previous commit and makes more sense. The internal
demux marked tracks as eager depending on their type and for subtitles
it would always lazily read them unless there happened to be no
available av stream. However, we want the sub stream to be eager if the
player is paused. The existing subtitle is still preserved on the
screen, but if the user changes tracks that's when the problem occurs.
So to handle this case, propagate the mpctx->paused down to the stream
selection logic. This modifies both demuxer_refresh_track and
demuxer_select_track to take that boolean value. A few other parts of
the player use this, but we can just assume false there (no change in
behavior from before) since they should never be related to subtitles.
The core player code is aware of its own state naturally, and can always
pass the appropriate value so go ahead and do so. When we change the
pause state, a refresh seek is done on all existing subtitle tracks to
make sure their eager state is the appropriate value (i.e. so it's not
still set to eager after a pause and a track switch). Slightly invasive
change, but it works with the existing logic instead of going around it
so ultimately it should be a better approach. We can additionally remove
the old force boolean from sub_read_packets since it is no longer
needed.
Diffstat (limited to 'sub/dec_sub.c')
-rw-r--r-- | sub/dec_sub.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sub/dec_sub.c b/sub/dec_sub.c index dc26aa027e..84c6b7bfbe 100644 --- a/sub/dec_sub.c +++ b/sub/dec_sub.c @@ -269,7 +269,7 @@ static bool is_new_segment(struct dec_sub *sub, struct demux_packet *p) // Read packets from the demuxer stream passed to sub_create(). Return true if // enough packets were read, false if the player should wait until the demuxer // signals new packets available (and then should retry). -bool sub_read_packets(struct dec_sub *sub, double video_pts, bool force) +bool sub_read_packets(struct dec_sub *sub, double video_pts) { bool r = true; pthread_mutex_lock(&sub->lock); @@ -291,7 +291,7 @@ bool sub_read_packets(struct dec_sub *sub, double video_pts, bool force) break; // (Use this mechanism only if sub_delay matters to avoid corner cases.) - double min_pts = sub->opts->sub_delay < 0 || force ? video_pts : MP_NOPTS_VALUE; + double min_pts = sub->opts->sub_delay < 0 ? video_pts : MP_NOPTS_VALUE; struct demux_packet *pkt; int st = demux_read_packet_async_until(sub->sh, min_pts, &pkt); |