Skip to content

Commit c5b2e02

Browse files
committed
Fix basis for seek, produce full message on reply
1 parent dfcc290 commit c5b2e02

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

command.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,8 @@ bool command_seek_replay(command_t *cmd, const char *arg)
824824
if (ret)
825825
{
826826
_len = strlcpy(reply, "OK ", sizeof(reply));
827-
sprintf(reply+_len, "%ld", input_st->bsv_movie_state.seek_target_frame);
827+
_len += snprintf(reply+_len, sizeof(reply)-_len,
828+
"%ld", input_st->bsv_movie_state.seek_target_frame);
828829
}
829830
else
830831
_len = strlcpy(reply, "NO", sizeof(reply));

input/bsv/bsvmovie.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,7 +1679,7 @@ bool movie_find_checkpoint_before(bsv_movie_t *movie, int64_t frame, bool consid
16791679
runloop_state_t *runloop_st = runloop_state_get_ptr();
16801680
bool paused = !!(runloop_st->flags & RUNLOOP_FLAG_PAUSED) || consider_paused;
16811681
const int64_t prev_skip_min_distance = 60;
1682-
int64_t target_frame = (int64_t)movie->frame_counter, cur_frame = 0;
1682+
int64_t target_frame = frame, cur_frame = 0;
16831683
bool ret = false;
16841684
int64_t initial_pos, cp_pos=-1, cp_frame=-1;
16851685
uint64_t frame_len;
@@ -1696,10 +1696,11 @@ bool movie_find_checkpoint_before(bsv_movie_t *movie, int64_t frame, bool consid
16961696
break;
16971697
if (tok == REPLAY_TOKEN_CHECKPOINT_FRAME || tok == REPLAY_TOKEN_CHECKPOINT2_FRAME)
16981698
{
1699-
if (!paused && target_frame - cur_frame < prev_skip_min_distance)
1700-
break;
1701-
cp_pos = intfstream_tell(movie->file);
1702-
cp_frame = cur_frame;
1699+
if (target_frame - cur_frame >= prev_skip_min_distance || paused)
1700+
{
1701+
cp_pos = intfstream_tell(movie->file);
1702+
cp_frame = cur_frame;
1703+
}
17031704
}
17041705
cur_frame += 1;
17051706
intfstream_seek(movie->file, frame_len, SEEK_CUR);
@@ -1721,8 +1722,8 @@ bool movie_seek_to_frame(input_driver_state_t *input_st, int64_t frame)
17211722
return false;
17221723
#endif
17231724
if (!movie_find_checkpoint_before(input_st->bsv_movie_state_handle, frame, true,
1724-
&input_st->bsv_movie_state.seek_target_frame,
1725-
&input_st->bsv_movie_state.seek_target_pos))
1725+
&input_st->bsv_movie_state.seek_target_pos,
1726+
&input_st->bsv_movie_state.seek_target_frame))
17261727
return false;
17271728
input_st->bsv_movie_state.flags |= BSV_FLAG_MOVIE_SEEK_TO_FRAME;
17281729
return true;

runloop.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7292,7 +7292,8 @@ int runloop_iterate(void)
72927292
if (input_st->bsv_movie_state.flags &
72937293
(BSV_FLAG_MOVIE_FORCE_CHECKPOINT |
72947294
BSV_FLAG_MOVIE_PREV_CHECKPOINT |
7295-
BSV_FLAG_MOVIE_NEXT_CHECKPOINT))
7295+
BSV_FLAG_MOVIE_NEXT_CHECKPOINT |
7296+
BSV_FLAG_MOVIE_SEEK_TO_FRAME))
72967297
{
72977298
runloop_st->flags &= ~RUNLOOP_FLAG_PAUSED;
72987299
runloop_st->run_frames_and_pause = 2;

0 commit comments

Comments
 (0)