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

Windows ASIO output and frameSize conflicts #18

Closed
marcelblum opened this issue Aug 18, 2021 · 4 comments · Fixed by #22
Closed

Windows ASIO output and frameSize conflicts #18

marcelblum opened this issue Aug 18, 2021 · 4 comments · Fixed by #22

Comments

@marcelblum
Copy link
Contributor

ASIO is a strange bird and I've been running into an issue where many devices have control panels in which the user can specify buffer size settings. These settings seem to override any attempt to specify frameSize in RtAudio's openStream(). The problem is if a frameSize is specified in openStream() that is not exactly equal to whatever the user selected in their control panel, then calls to write() fail silently. The frameOutputCallback is never called following the write(), no error is fired, and isStreamOpen and isStreamRunning both return true. So the RtAudio instance is in this weird state where buffers keep piling up in the queue with every call to write() but are never played. There's no way that I can see to detect the user-set buffer size and pick the right magic number for frameSize when instantiating an RtAudio stream. Is there a way to have getDevices() return the device's current preset buffer size? Or perhaps some flag that forces overriding the control panel setting?

Here are 2 examples of the sort of ASIO device control panels I'm referring to:

Untitled

You can see that in the MOTU device panel both sample rate and buffer size are configurable, but interestingly the sampleRate specified in openStream() does override the panel setting (I can see the change reflected in the panel as soon as I open the RtAudio stream).

I guess an ugly workaround would be to brute force it by continuously opening streams and checking if the frameOutputCallback was called, and if not, open a new stream and try again with a different power of 2 value until arriving at the magic number that works, but it would be nice to have a more elegant solution.

@marcelblum
Copy link
Contributor Author

Looking at the source RtAudio docs for openStream I see that it allows passing a value of 0 for bufferFrames:

A value of zero can be specified, in which case the lowest allowable value is determined. The actual value used by the device is returned via the same pointer.

I wonder if for ASIO this gets interpreted as the control panel forced value. I tried passing 0 for frameSize with audify's RtAudio but it does not work as expected and seems to actually open an unusable stream with a 0 buffer size.

@marcelblum
Copy link
Contributor Author

I think the problem starts here, the frameSize value passed to openStream() is used in all subsequent calculations and checks, which if 0 always leads to failed checks/errors thrown by Audify (not by RtAudio!), even though the stream actually does get created successfully with an unknown frameSize:

_frameSize = frameSize;

So there needs to be a way to poll the stream instance for "The actual value used by the device".

@almoghamdani
Copy link
Owner

almoghamdani commented Dec 31, 2021

Fixed in v1.7.1.
Thanks to @marcelblum for the fix.

Please re-open if you're still encountering issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@marcelblum @almoghamdani and others