-
Notifications
You must be signed in to change notification settings - Fork 324
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
ALSA: Pa_GetStreamTime() is not advancing for PulseAudio #586
Comments
I think Pulseaudio doesn't return stream timestamps. Was this using the pulse alsa plugin? |
That might be the problem.
I am not explicitly trying to use pulseaudio. I am just using the default device. But I suspect pulseaudio is inserting itself in there. Entering: pactl list I am trying to disable pulseaudio on Ubuntu 18.04 and not having much luck. Any advice? |
Running Note that enumerating the pulse device may cause the hardware device(s) it will use to become busy for a short time. It is the same as a the ALSA dmix plugins this way, for which there is already code in portaudio to alter scanning order. |
Thanks! aplay -l only listed one device. But bin/pa_devs list every device. So this does seem related to pulseaudio. So I updated the bug title. Maybe we should detect pulseaudio and workaround this some way. |
Pretty sure this is a limitation of pulse. I haven't tested pipewire, maybe it fixes it? But I doubt it, at least not yet, pipewire doesn't seem to be working as well as pulse. One could try to timestamp when the stream becomes read/write-able, but I'm guessing that it will be very inaccurate. Or just fabricate timestamps based on nominal rate. Which aren't really timestamps, but would allow code that expects timestamps to work as well as it's going to work when it doesn't have them. More sophisticated would be model the actual rate with a PLL or FLL and attempt to lock that to userspace timestamps, while accounting for the large jitter in those timestamps. |
I wonder whether the callback timestamps are also invalid. It would be fine to use the system monotonic clock to compute stream time and callback timestamps. We do similar things in other host APIs where there is no native stream time support. If someone submitted a patch that provided best-effort timestamps then we would accept it. |
Yes, the callback timestamps are also all zero. Both |
I wonder whether ALSA provides an API call to query whether a particular device provides timestamps? |
Good question. Basic timestamping, which is all PA uses, is supposed to be supported by all ALSA devices. Absent any hardware features, it's done in the core ALSA layers. IMHO, it's a PulseAudio flaw that it doesn't work with the virtual ALSA devices that PulseAudio creates. There is an ALSA function, I don't think it's really necessary to use it. I don't think is any way for a valid timestamp to be zero. So if we get a zero timestamp, and pulse does give us that at least, they don't work, regardless of what |
Describe the bug
Pa_GetStreamTime() always returns zero.
To Reproduce
The patest_sine_time.c test has been updated so it times out.
Use the version in #585
Expected behavior
Plays for a few seconds then repeats.
Actual behavior
Desktop (please complete the following information):
Additional context
It seems to work fine on MacOS.
The text was updated successfully, but these errors were encountered: