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

WDM/KS OpenStream does not take framesPerUserBuffer into account when computing native buffering #764

Open
RossBencina opened this issue Jan 30, 2023 · 2 comments
Labels
P3 Priority: Normal src-wdmks MS WDM/KS Host API /src/hostapi/wdmks

Comments

@RossBencina
Copy link
Collaborator

Search for framesPerUserBuffer in src/hostapi/wdmks/pa_win_wdmks.c and witness how it is used. In particular it is not used in calculations of stream->render.framesPerBuffer or stream->capture.framesPerBuffer.

In general I would expect native buffering to be configured to be a multiple of the user frames per buffer, where a minimum of 2 indicates double-buffering. The details will always be specific to the particular native API behavior, but the current code doesn't look correct.

One thing to keep in mind is that the user PA callback should always be able to run for near 100% of the duration of the callback buffer, without inducing glitches. Further details are here:

https://github.com/PortAudio/portaudio/wiki/BufferingLatencyAndTimingImplementationGuidelines

See other host APIs for details.

@dechamps
Copy link
Contributor

dechamps commented Jun 9, 2024

In practice, it looks like WDM-KS only takes suggestedLatency into account to calculate the host buffer size:

stream->capture.framesPerBuffer = (unsigned long)((inputParameters->suggestedLatency*sampleRate)+0.0001);

stream->render.framesPerBuffer = (unsigned long)((outputParameters->suggestedLatency*sampleRate)+0.0001);

This is confirmed when looking at the debug output for e.g. a WaveRT device, where the reported Out buffer len is always twice the suggestedLatency, regardless of the user framesPerBuffer.

I agree that this looks wrong - if the user specifies framesPerBuffer, then the host frames per buffer should be a multiple of that.

@RossBencina
Copy link
Collaborator Author

the host frames per buffer should be a multiple of that.

Yes, unless there is a reason that it can not be a multiple (i.e. some low-level driver constraint on hardware buffers). Not sure whether that is applicable in the WDM/KS case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 Priority: Normal src-wdmks MS WDM/KS Host API /src/hostapi/wdmks
Projects
None yet
Development

No branches or pull requests

3 participants