jack: use 32 bits for frame times

JACK uses 32 bits for frame times so truncate our 64 bits position
to get the wraparounds right.
This commit is contained in:
Wim Taymans 2023-02-16 10:16:36 +01:00
parent 353c1f709d
commit 0511970537

View file

@ -5790,9 +5790,10 @@ jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t fram
if (SPA_UNLIKELY((pos = c->rt.position) == NULL) || c->buffer_frames == 0)
return 0;
uint32_t nf = (uint32_t)pos->clock.position;
uint64_t w = pos->clock.nsec/SPA_NSEC_PER_USEC;
uint64_t nw = pos->clock.next_nsec/SPA_NSEC_PER_USEC;
int64_t df = (uint64_t)frames - pos->clock.position;
int32_t df = frames - nf;
int64_t dp = nw - w;
return w + (int64_t)rint((double) df * (double) dp / c->buffer_frames);
}
@ -5808,11 +5809,12 @@ jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t usec
if (SPA_UNLIKELY((pos = c->rt.position) == NULL))
return 0;
uint32_t nf = (uint32_t)pos->clock.position;
uint64_t w = pos->clock.nsec/SPA_NSEC_PER_USEC;
uint64_t nw = pos->clock.next_nsec/SPA_NSEC_PER_USEC;
int64_t du = usecs - w;
int64_t dp = nw - w;
return pos->clock.position + (int64_t)rint((double)du / (double)dp * c->buffer_frames);
return nf + (int32_t)rint((double)du / (double)dp * c->buffer_frames);
}
SPA_EXPORT