Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes a couple issues I found with looping and stepping #61

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions replay-source.c
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,13 @@ replay_restart_at_begin(struct replay_source *c, const uint64_t os_timestamp)
c->start_timestamp = os_timestamp;
c->pause_timestamp = c->play ? 0 : os_timestamp;
c->audio_frame_position = 0;
const int64_t duration =
(int64_t)(((int64_t)c->current_replay.last_frame_timestamp -
(int64_t)c->current_replay.first_frame_timestamp) *
100.0 / c->speed_percent);
if (c->backward) {
c->start_timestamp -= duration;
}
struct obs_source_frame *frame =
c->current_replay.video_frames[c->video_frame_position];
if (c->current_replay.trim_front != 0) {
Expand Down Expand Up @@ -1615,7 +1622,10 @@ replay_restart_at_end(struct replay_source *c, const uint64_t os_timestamp)
(int64_t)(((int64_t)c->current_replay.last_frame_timestamp -
(int64_t)c->current_replay.first_frame_timestamp) *
100.0 / c->speed_percent);
c->start_timestamp = os_timestamp - duration;
c->start_timestamp = os_timestamp;
if (!c->backward) {
c->start_timestamp -= duration;
}
c->pause_timestamp = c->play ? 0 : os_timestamp;
c->restart = false;
if (c->current_replay.trim_end != 0) {
Expand Down Expand Up @@ -1710,22 +1720,7 @@ void replay_step_frames(void *data, bool pressed, bool forward,
if (c->backward) {
time_diff *= -1;
}
if (c->play) {
c->play = false;
c->pause_timestamp = os_timestamp;
obs_source_signal(c->source, "media_pause");
} else if (time_diff != 0) {
if (c->pause_timestamp == 0) {
c->start_timestamp += time_diff;
c->pause_timestamp = os_timestamp;
} else if (c->pause_timestamp + time_diff <=
c->start_timestamp) {
c->start_timestamp += time_diff;
} else {
c->pause_timestamp += time_diff;
}
}

c->start_timestamp -= time_diff;
c->video_frame_position = next_pos;
}

Expand Down Expand Up @@ -3292,7 +3287,7 @@ static void replay_source_tick(void *data, float seconds)
}

const int64_t video_duration =
os_timestamp -
(int64_t)os_timestamp -
(int64_t)context->start_timestamp;
//TODO audio backwards
int64_t source_duration =
Expand Down
Loading