mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
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:
parent
353c1f709d
commit
0511970537
1 changed files with 4 additions and 2 deletions
|
|
@ -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)
|
if (SPA_UNLIKELY((pos = c->rt.position) == NULL) || c->buffer_frames == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
uint32_t nf = (uint32_t)pos->clock.position;
|
||||||
uint64_t w = pos->clock.nsec/SPA_NSEC_PER_USEC;
|
uint64_t w = pos->clock.nsec/SPA_NSEC_PER_USEC;
|
||||||
uint64_t nw = pos->clock.next_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;
|
int64_t dp = nw - w;
|
||||||
return w + (int64_t)rint((double) df * (double) dp / c->buffer_frames);
|
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))
|
if (SPA_UNLIKELY((pos = c->rt.position) == NULL))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
uint32_t nf = (uint32_t)pos->clock.position;
|
||||||
uint64_t w = pos->clock.nsec/SPA_NSEC_PER_USEC;
|
uint64_t w = pos->clock.nsec/SPA_NSEC_PER_USEC;
|
||||||
uint64_t nw = pos->clock.next_nsec/SPA_NSEC_PER_USEC;
|
uint64_t nw = pos->clock.next_nsec/SPA_NSEC_PER_USEC;
|
||||||
int64_t du = usecs - w;
|
int64_t du = usecs - w;
|
||||||
int64_t dp = nw - 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
|
SPA_EXPORT
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue