-
-
Notifications
You must be signed in to change notification settings - Fork 293
Further audio improvements. #664
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…nd buffer and assignment logic Next up, prepare details from graphics.defineEffect()
…from Program Slight redesign of TimeTransform with caching (to synchronize multiple invocations with a frame) and slightly less heavyweight call site
Err, was calling Modulo for sine method, heh That said, time transform seems to work in basic test
Fixed error detection for positive number time transform inputs Relaxed amplitude positivity requirement
Maintenance Revert Test
My mistake adding back changes made
This reverts commit 0b5e1e9.
Notes for Delete(), in case we want a thread-safe version later
… (or nil ref, when not needed) and no ref means a channel is empty (for purposes of stopping) Avoids lots of new and delete More importantly, one notifier with lifetime outside the thread (no unguarded updating of reference counts) No need for loop to delete them (with potential race) since will go away with Lua Array of atomic flags to go with channel-to-callbacks, should avoid remaining race possibilities
Shchvova
approved these changes
Dec 11, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a follow-up to #657, dealing with
audio.onComplete
.@naveen-pcs pointed out on the forum that there were still audio crashes in 3701.
The stack trace has a telltale
~BaseResourceHandle()
. After digging around, it seems theBaseResource
in question was basically a way for the audio task to detect if the underlying Lua state has been invalidated and, if so, do nothing. Unfortunately, when the resource is set up, it updates a shared reference count, but on the audio thread and without any synchronization. Sure enough, that count must get out of whack and lead to something like a double free of the shared memory.The audio thread is started and closed within the Lua state lifetime, and I don't see any way for the tasks to execute outside this range, since the scheduler is similarly contained. What I ended up doing, thus, was to create a single n
PlatformNotifier
belonging to theRuntime
(so the reference count is only touched in the main thread) and sending the tasks through that. (All the accesses are read-only aside from the already-hardenedScheduler
methods.)I'm also now using Lua references rather than memory-allocated objects to track channel usage /
onComplete
callbacks, and sending them on through theScheduler
. This avoids some memory churn and simplifies cleanup.For that matter, the channels-to-callback also now has some synchronization, via a per-channel
atomic_flag
. I forget the exact details at the moment, but the channel management looked shaky in its previous form (there was definite cross-thread touching). I haven't tested if this was relevant to #19.I've currently only commented out the old code, not removed it. On request, I believe I can explain most, if not all, of those race bugs described in the comments, in light of my analysis.
The previous
mutex
implementation in theScheduler
is now also based onatomic
s.Attached is an Android build for testing: Corona.aar.zip (You can unzip this and replace
Corona.aar
in yourNative
directory if you want to test on Android. Might want to save your old one, too.)This is based on this PR and #661.
With this I was able to run the test from #296 on Windows, Mac, and Android without problems such as the loading issues mentioned in Discord nor the Back button bug from #663.