diff options
author | Mike Will <myQwil@gmail.com> | 2023-09-27 08:00:14 -0400 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-09-29 20:25:50 +0000 |
commit | 233f1e46f67fef71d7a270f798f6a4e3198a1606 (patch) | |
tree | 5e07fe6b8cc68cf7fdc08f573f6999a5f9a1a790 /player/core.h | |
parent | 27ef1725e7724f4b6899e3992ac3a884db9fbe13 (diff) | |
download | mpv-233f1e46f67fef71d7a270f798f6a4e3198a1606.tar.bz2 mpv-233f1e46f67fef71d7a270f798f6a4e3198a1606.tar.xz |
playloop: make chapter property more accurate when seeking chapters
When seeking chapters, `last_chapter_seek` acts as a projection of
what the current chapter will be once mpv has a chance to seek to it.
This allows for more accurate results from the `chapter` property.
It works by comparing the projection to the actual current chapter
and returning the larger of the two indexes, but this only works when
seeking forward.
If we want it to work for both forward and backward chapter seeking,
we can instead use a boolean called `last_chapter_flag`, which gets
switched on when a chapter seek request is made, and then
switched off when the seek has been performed.
We should also check to ensure that we don't allow the chapter index
to be set to -1 unless there is a span of time between the very
beginning of the track and the start of the first chapter.
Since the new approach to resetting `last_chapter_seek` no longer
depends on `last_chapter_pts`, that member variable can be removed.
Diffstat (limited to 'player/core.h')
-rw-r--r-- | player/core.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/player/core.h b/player/core.h index c8c6ee850b..b9710f61af 100644 --- a/player/core.h +++ b/player/core.h @@ -70,6 +70,7 @@ enum seek_type { MPSEEK_ABSOLUTE, MPSEEK_FACTOR, MPSEEK_BACKSTEP, + MPSEEK_CHAPTER, }; enum seek_precision { @@ -400,7 +401,7 @@ typedef struct MPContext { * the user wanted to go to, even if we aren't exactly within the * boundaries of that chapter due to an inaccurate seek. */ int last_chapter_seek; - double last_chapter_pts; + bool last_chapter_flag; bool paused; // internal pause state bool playback_active; // not paused, restarting, loading, unloading |