mirror of
https://github.com/airwindows/airwindows.git
synced 2026-05-15 06:05:55 -06:00
[GH-ISSUE #35] rand() realtime safety on macOS and Linux #28
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/airwindows#28
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @x42 on GitHub (Dec 7, 2021).
Original GitHub issue: https://github.com/airwindows/airwindows/issues/35
On unices (Linux and macOS) the call to
rand()takes a lock (preserve global random seed) and is hence not realtime-safe.This also results in a significant DSP load increase, if multiple airwindows plugins are used on those systems.
On Windows this is less of an issue since
rand()uses a thread-local variable by default.I suggest to have a look at https://www.pcg-random.org/
You may also prefer this to the 6 calls on Windows to work around their 15 bits limitation. PCG provides excellent 32bit randomness and is even more efficient compared to rand().
A proof-of-concept patching one plugin is shown at #31 - this will have to be copied to other plugins as well.
Direct diff of that pull-request is available via
https://patch-diff.githubusercontent.com/raw/airwindows/airwindows/pull/31.patch
https://patch-diff.githubusercontent.com/raw/airwindows/airwindows/pull/31.diff
@mxmilkiib commented on GitHub (Dec 7, 2021):
How does one access .patch and .diff files via the github interface?
@x42 commented on GitHub (Dec 7, 2021):
Go to a pull-request e.g.
https://github.com/airwindows/airwindows/pull/31and then add.patchor.diffsuffix to the URL. e.g.https://github.com/airwindows/airwindows/pull/31.patchorhttps://github.com/airwindows/airwindows/pull/31.diffThe former is a complete git patch series (individual commits with commit messages), while the latter produces a combined flat change-set. Both can be applied with the
patchcommandline util. The former can also be used withgit amorgit apply.PS. you can also directly apply it:
@faithanalog commented on GitHub (Nov 4, 2024):
I believe this is fixed since
54fd8c7a18.It looks like TapeDust is the only plugin that calls
rand()in its process function today.