Skip to content

Commit b536b26

Browse files
layercak3dancingmirrors
authored andcommitted
playloop: unset last_chapter_flag when queueing non-chapter seeks
This fixes a race condition where if a non-chapter seek is queued immediately after a chapter seek is queued, the chapter property may become unavailable until a new file is loaded. If multiple seeks are queued within the same playloop iteration, only the last seek is executed. Because the chapter seek is never executed, last_chapter_flag remains set and last_chapter_seek becomes -2, which causes get_current_chapter to return -2, which makes the chapter property unavailable. Unset this (and also last_chapter_seek) immediately rather than wait for seek execution, like chapter seeks set these immediately.
1 parent b9249e0 commit b536b26

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

player/playloop.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,6 @@ static void mp_seek(MPContext *mpctx, struct seek_params seek)
279279
if (unlikely(seek.type == MPSEEK_CHAPTER)) {
280280
mpctx->last_chapter_flag = false;
281281
seek.type = MPSEEK_ABSOLUTE;
282-
} else {
283-
mpctx->last_chapter_seek = -2;
284282
}
285283

286284
bool hr_seek_very_exact = seek.exact == MPSEEK_VERY_EXACT;
@@ -450,6 +448,11 @@ void queue_seek(struct MPContext *mpctx, enum seek_type type, double amount,
450448
if (mpctx->stop_play == AT_END_OF_FILE)
451449
mpctx->stop_play = KEEP_PLAYING;
452450

451+
if (type != MPSEEK_CHAPTER) {
452+
mpctx->last_chapter_flag = false;
453+
mpctx->last_chapter_seek = -2;
454+
}
455+
453456
switch (type) {
454457
case MPSEEK_RELATIVE:
455458
seek->flags |= flags;

0 commit comments

Comments
 (0)