Skip to content

Commit

Permalink
audio: adjust queued_aframe start_time when unpausing
Browse files Browse the repository at this point in the history
  • Loading branch information
ruihe774 committed Oct 19, 2024
1 parent 24e9867 commit d4f564e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion audio/out/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,14 @@ void ao_set_paused(struct ao *ao, bool paused, bool eof)
ao->driver->set_pause(ao, true);
p->queued_time_ns = p->end_time_ns - mp_time_ns();
} else {
p->end_time_ns = p->queued_time_ns + mp_time_ns();
int64_t new_end_time_ns = p->queued_time_ns + mp_time_ns();
double time_adjustment = MP_TIME_NS_TO_S(new_end_time_ns - p->end_time_ns);
p->end_time_ns = new_end_time_ns;

for (int i = 0; i < p->num_queued_aframes; i++) {
p->queued_aframes[i].start_time += time_adjustment;
}

ao->driver->set_pause(ao, false);
}
} else {
Expand Down

0 comments on commit d4f564e

Please sign in to comment.