-
Notifications
You must be signed in to change notification settings - Fork 76
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
FlexASIO entry points are not thread safe #185
Comments
Implementation note: we'll need to be careful around ASIO callbacks such as |
This was referenced May 25, 2024
Actually I can see some symptoms of this when REW closes FlexASIO:
Fortunately this particular case doesn't seem to cause user-visible issues. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently FlexASIO driver methods are not guaranteed to be thread safe. For example, attempting to call
getLatencies()
andcreateBuffers()
at the same time will trigger undefined behaviour. More worryingly, concurrentcanSampleRate()
calls will result in concurrent PortAudio calls, which is unlikely to end well as PortAudio itself is not thread safe (in fact, it's downright thread-hostile - see #124).The reason why FlexASIO assumes its entry points will not be called concurrently is because I was under the assumption that this would not be allowed under the ASIO SDK, but after a closer examination in the context of eiz/SynchronousAudioRouter#133, it turns out that this is not as clear as I originally assumed - the ASIO SDK expresses no opinion one way or the other. Therefore, the robustness principle would dictate that drivers should be resilient to concurrent calls.
I don't remember seeing a log from any FlexASIO user where the host made concurrent calls, so thankfully this concern seems mostly academic at this point.
One way to fix this could be to wrap all driver calls under a mutex, or maybe we can address #124 at the same time by scheduling all calls into a single dedicated thread.
The text was updated successfully, but these errors were encountered: