Skip to content

Commit 24cea32

Browse files
committed
Add latency to jack position.
Also fixed issue with re-sampler latency calculation, as jack backend the frame latency is returned in stream source samples, unlike wasapi which returns in output samples.
1 parent cb01b08 commit 24cea32

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/cubeb_jack.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ cbjack_get_max_channel_count(cubeb * /*ctx*/, uint32_t * max_channels)
654654
static int
655655
cbjack_get_latency(cubeb_stream * stm, unsigned int * latency)
656656
{
657-
*latency = stm->context->jack_latency + cubeb_resampler_latency(stm->resampler.get());
657+
*latency = stm->context->jack_latency + ceil(cubeb_resampler_latency(stm->resampler.get()) * stm->ratio);
658658
return CUBEB_OK;
659659
}
660660

@@ -947,7 +947,7 @@ cbjack_stream_stop(cubeb_stream * stream)
947947
static int
948948
cbjack_stream_get_position(cubeb_stream * stream, uint64_t * position)
949949
{
950-
*position = stream->position;
950+
*position = stream->position - ceil(cubeb_resampler_latency(stream->resampler.get()) * stream->ratio);
951951
return CUBEB_OK;
952952
}
953953

0 commit comments

Comments
 (0)