From 7df66cd6ad65447f7f4db6617470e36c6e9b9bde Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 19 Feb 2020 10:19:59 +0100 Subject: [PATCH] pw-cat: keep our own time Don't try to use the time from the io_position, it is updated in the RT thread and might be slightly wrong for our purposes. --- src/tools/pw-cat.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/tools/pw-cat.c b/src/tools/pw-cat.c index 2f92baec1..5a75eff37 100644 --- a/src/tools/pw-cat.c +++ b/src/tools/pw-cat.c @@ -144,7 +144,7 @@ struct data { struct spa_io_position *position; bool drained; - uint64_t clock_start; + uint64_t clock_time; struct { int fd; @@ -968,11 +968,9 @@ static int midi_play(struct data *d, void *src, unsigned int n_frames) spa_pod_builder_push_sequence(&b, &f, 0); - if (d->clock_start == 0) - d->clock_start = d->position->clock.position; - - first_frame = d->position->clock.position - d->clock_start; + first_frame = d->clock_time; last_frame = first_frame + d->position->clock.duration; + d->clock_time = last_frame; while (1) { uint32_t frame, offset;