mpv/demux
nanahi 940854c86f demux: allow refresh seek for non-video streams
Since d41f0a54b0, enabling a stream will
no longer perform a refresh seek, to fix issues with switching video
tracks. Additionally, 62e9a0c5f6 also
prevents refresh seek on track switching when it happens right after a
seek.

Unfortunately, when external audio files are loaded, preventing refresh
seeks can cause A-V sync issues. Since external tracks have separate demuxer
instances from the internal tracks, the demuxer instances from both
internal and external tracks are explicitly sought to the same pts when
seeking is performed. When enabling an external audio track for the first
time, the existing logic prevents refresh seek because no packets have ever
been read, so the track ends up not being sought. This means that switching
the track in the middle of playback results in a huge A-V desync.

To make it worse, unlike one demuxer instance with multiple tracks,
tracks from multiple demuxer instances are not synced in any meaningful
way beyond the separate explicit seeking. The only thing which keeps these
tracks synced is the generic A-V sync logic, which is unfit for such large
desync above. This means the audio is at the start position after the track
is switched, behind the video, so the audio is not considered ready, and
audio is continuously filtered sequentially until it is synced to the video.
While this is happening, the audio filtering exhausts all CPU resources.

There is also a case with cache enabled: if a seek causes some new data to
be cached, the demuxer is sought to the end of joined cache range.
If track is switched after this, the existing logic prevents a refresh seek,
so the demuxer is at a wrong position after the track is switched.

Fix this by allowing refresh seek for non-video streams, even when no packets
have been read yet or immediately after a seek.
2024-06-22 18:21:28 +00:00
..
cache.c various: move unistd.h inclusion to common.h 2024-05-06 22:01:17 +02:00
cache.h demux: add a on-disk cache 2019-09-19 20:37:05 +02:00
codec_tags.c various: replace dead links in comments 2024-02-11 04:01:24 +00:00
codec_tags.h Revert "demux: put type2format into codec_tags with helper functions" 2024-02-06 18:08:53 +01:00
cue.c cue: tolerate NBSP as whitespace 2020-02-03 19:13:44 +01:00
cue.h
demux.c demux: allow refresh seek for non-video streams 2024-06-22 18:21:28 +00:00
demux.h demux: keep track of ts information per stream type 2024-05-05 14:11:47 +02:00
demux_cue.c osdep/dirent: add implementation for Windows SDK build 2024-05-06 22:01:17 +02:00
demux_disc.c csputils: replace more primitives with pl_ 2024-01-22 14:54:55 +00:00
demux_edl.c demux_edl: fix infinite loop on empty EDL files 2024-06-18 03:11:14 +02:00
demux_lavf.c various: remove no longer needed availability checks 2024-06-22 16:12:14 +02:00
demux_libarchive.c player: change insert_next to insert_at 2024-02-26 02:03:21 +00:00
demux_mf.c various: add missing checks for directory streams 2024-05-15 22:45:18 +02:00
demux_mkv.c command: add dolby-vision-profile and dolby-vision-level to track-list 2024-05-10 01:26:30 +02:00
demux_mkv_timeline.c osdep/dirent: add implementation for Windows SDK build 2024-05-06 22:01:17 +02:00
demux_null.c demux_null: mark as seekable 2018-01-06 14:42:22 -08:00
demux_playlist.c osdep/dirent: add implementation for Windows SDK build 2024-05-06 22:01:17 +02:00
demux_raw.c various: move unistd.h inclusion to common.h 2024-05-06 22:01:17 +02:00
demux_timeline.c Revert "demux: improve stream selection state" 2023-09-30 09:02:57 -05:00
ebml.c build: remove outdated generated directory 2023-07-31 19:00:06 +00:00
ebml.h demux/packet: add support for ITU T.35 metadata in Matroska 2024-04-29 01:37:02 +02:00
matroska.h
packet.c various: remove no longer needed availability checks 2024-06-22 16:12:14 +02:00
packet.h sub: avoid unneeded calls to is_animated 2024-06-04 12:29:13 +00:00
stheader.h command: add dolby-vision-profile and dolby-vision-level to track-list 2024-05-10 01:26:30 +02:00
timeline.c stream, demux: redo origin policy thing 2019-12-20 13:00:39 +01:00
timeline.h various: add missing include in header flles 2023-09-21 14:40:11 +00:00