-
-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Paused Cues are Stopped and Paused when a second Cue is played #368
Comments
Having looked at |
That actually might make some sense - we do have notifications and FNA does try to handle them: https://github.com/FNA-XNA/FNA/blob/master/src/Audio/AudioEngine.cs#L374-L422 But it'd be weird to see different objects colliding on these events... it's hard to say. When I sit down to test this the first thing I'll probably do is just breakpoint anywhere that the stop flag is set and see what might have triggered that, after that I'll monitor the events to see if something underneath is requesting a stop the application didn't ask for (Cue instance limits maybe?), from there hopefully I'll have enough to figure out what's up. |
I think I found the issue - what happens on XNA when you call If you're able to change the XACT data, does adding a fade out time for the sound category fix it for FNA? |
I'll need to try getting my XNA build setup working again; I think my VS licence is no longer valid. If you're able to point me towards any way of getting Ye Olde XNA Game Studio working on Windows 11, that'd be really helpful. EDIT - oh, and thanks for looking into this! |
Meant to look into this sooner but other stuff happened, will dump what I was able to find in the meantime: The issue is the fadeout function I wrote, which assumes a tightly-packed stop event when a sound is destroyed (which is what happens when a Cue is destroyed for category limits and has a 0ms fade time):
Part of me wonders if this could be fixed by simply removing the 0ms handler and letting it be in https://github.com/FNA-XNA/FAudio/blob/master/src/FACT_internal.c#L1691 ... so it's one of those areas where it's a 1-frame inaccuracy, but I don't know if the frame step is in AudioEngine or in the XACT thread (both of which have their own update routines... sigh). |
There's a 1-frame timing issue where two sounds in the same category being played consecutively should still have both sounds _technically_ playing, even if the fade time is 0ms. See #368 for details.
Thanks for your continued work, and sorry for not being able to keep up my end of the bargain my testing the XNA implementation. It's been a busy week with Christmas looming, and needing to deal with a tree that blew down! 😆 |
There's a 1-frame timing issue where two sounds in the same category being played consecutively should still have both sounds _technically_ playing, even if the fade time is 0ms. See #368 for details.
Argh - this all got rather complicated! The new change introduces a possible new issue ( I managed to open up the XACT project, and If ChatGPT is correct the FAudio was nearly showing the correct behaviour originally - a paused Cue should contribute towards the limit, so presumably should be stopped and/or destroyed when another Cue from the same category is played. It's arguably a bug (see later!) prior to your PR that it remained in both FAudio appears to behave correctly both before and after the PR if instance limits are not exceeded. FAudio appears to leave the I've tried to summarise my findings below. The states are the values after the second Cue is played, and whether resumption works was tested manually (aurally?).
So, in summary:
I hope that makes sense? One cup of tea was not enough to get through this 😁 I've pushed a commit to the repro-repo that might make investigating the indefinite EpilogueI feel a bit bad for taking up your time on what's basically an edge case - how FAudio should behave when a fool forgets that he's got instance limits set and chooses to exceed them. I've got my XNA 4.0 build setup working again now, so if it would be helpful for the project I could put some time into figuring out the reference implementation's behaviour in various scenarios? |
Found the issue with the post-PR behavior, the engine wasn't updating the Cue because it was Paused, which is normally fine but the Stopping state should override that. Updated binaries will be here: https://github.com/FNA-XNA/FAudio/actions/runs/12653809981 |
Thanks! I just tried the latest build, and assuming I've not made any silly mistakes, this goes back to the original issue of the Cue ending up both Paused and Stopped. |
Was missing a bitflag in DestroySound, next batch of builds: https://github.com/FNA-XNA/FAudio/actions/runs/12655539462 |
Splendid - with that latest build when the Cue is paused Please let me know if I can provide any value by exploring the XNA 4.0 behaviour for you. |
That was good timing actually, I dug up my VS2010 VM and can confirm that the behavior matches now! |
There's a 1-frame timing issue where two sounds in the same category being played consecutively should still have both sounds _technically_ playing, even if the fade time is 0ms. See #368 for details.
Further to the thread on Discord, it seems that playing a Cue after previously pausing another one makes the paused cue simultaneously enter both a paused and stopped state. While I can't reproduce the expected behaviour any more due to a lack of access to XNA, the game I wrote back in 2010 depended on this behaviour to prevent players going insane from listening to the first few bars of the overworld theme repeatedly 😁
Versions
Observed behaviour
Cue
instances,a
andb
a.Play()
a.Pause()
b.Play()
a.IsPaused && a.IsStopped == true
Expected behaviour
a.Play()
a.Pause()
b.Play()
a.IsPaused && !a.IsStopped
...then for bonus points:
b.Pause()
a.Resume()
a
starts playing from the point at which it was previously pausedRepro steps
I made a repro game that depends on Git LFS, a local checkout of FNA, and FNA libraries to be manually copied in that throws an exception if the (suspected) bug is present.
Other possible explanations
The text was updated successfully, but these errors were encountered: