Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make PulseAudio return accurate latency information #53547

Closed
wants to merge 1 commit into from

Conversation

EIREXE
Copy link
Contributor

@EIREXE EIREXE commented Oct 7, 2021

This seems to be the most reasonable approach, the old approach gave wildly different values per startup, see the stepmania source code for reference I used, they don't seem to do any latency compensation at all, but I tested with a latency testing tool and the approach I used seems to be the correct one:
https://github.com/stepmania/stepmania/blob/984dc8668f1fedacf553f279a828acdebffc5625/src/arch/Sound/RageSoundDriver_PulseAudio.cpp#L178

@EIREXE EIREXE requested a review from a team as a code owner October 7, 2021 19:00
@Calinou Calinou added this to the 4.0 milestone Oct 7, 2021
@Calinou Calinou added the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Oct 7, 2021
@akien-mga akien-mga modified the milestones: 4.0, 4.1 Feb 12, 2023
@MJacred
Copy link
Contributor

MJacred commented May 17, 2023

Hm… like @ellenhp said here #45152 (comment), it's better to get the latency during mixing

Don't forget: PulseAudio is quite particular about its latency, so using pa_stream_get_latency is kind of must:

If PA_STREAM_ADJUST_LATENCY is set, then the tlength/fragsize parameters of the pa_buffer_attr structure will be interpreted slightly differently than otherwise when passed to pa_stream_connect_record() and pa_stream_connect_playback(): the overall latency that is comprised of both the server side playback buffer length, the hardware playback buffer length and additional latencies will be adjusted in a way that it matches tlength resp. fragsize.
source: https://freedesktop.org/software/pulseaudio/doxygen/streams.html

IMO that PR is the better and more accurate approach

@EIREXE
Copy link
Contributor Author

EIREXE commented May 18, 2023

Hm… like @ellenhp said here #45152 (comment), it's better to get the latency during mixing

Don't forget: PulseAudio is quite particular about its latency, so using pa_stream_get_latency is kind of must:

If PA_STREAM_ADJUST_LATENCY is set, then the tlength/fragsize parameters of the pa_buffer_attr structure will be interpreted slightly differently than otherwise when passed to pa_stream_connect_record() and pa_stream_connect_playback(): the overall latency that is comprised of both the server side playback buffer length, the hardware playback buffer length and additional latencies will be adjusted in a way that it matches tlength resp. fragsize.
source: https://freedesktop.org/software/pulseaudio/doxygen/streams.html

IMO that PR is the better and more accurate approach

Yeah this PR isn't very good, I suggest anyone making a rhythm game in godot to use a custom audio solution, like shinobu

@EIREXE EIREXE closed this May 18, 2023
@Calinou Calinou added archived and removed cherrypick:3.x Considered for cherry-picking into a future 3.x release labels May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants