XboxDev / nxdk-sdl

SDL2 (adapted for original Xbox / nxdk toolchain)
Other
20 stars 8 forks source link

SDL Audio driver is unstable and potentially hangs or crashes #26

Open JayFoxRox opened 4 years ago

JayFoxRox commented 4 years ago

Before merging the SDL audio support, we have known about potential issues in the SDL audio portion:

The exact behavior seems to depend on different factors like chosen playback rate / SDL audio format. We'll have to stress-test, review and debug the code.

It's also possible that the issues are unrelated to the audio driver - we have not been able to confirm anything specifically. We just had independent reports of crashes in applications using SDL audio. Any underlying subsystem (SDL logic or xaudio for example) could be responsible.

Unfortunately the SDL audio subsystem has competing backend design philosophies, so it's complicated and hard to compare to other drivers (and there's no good reference driver within SDL itself either). Debugging this might take a while.

I also have to recommend against testing in XQEMU because the QEMU AC97 implementation might cause additional timing or interrupt injection issues.

As a workaround you will have to disable all SDL audio (including SDL mixer) in your application; if you don't do this, there could be potential crashes due to SDL audio.

Ryzee119 commented 3 years ago

I this still an issue? It was rewritten in https://github.com/XboxDev/nxdk-sdl/commit/d5d814ee2b684ee6b39e136db380001817392901 I have been using the sdl audio driver now for a long time and never encounter this issue anymore.

JayFoxRox commented 3 years ago

I this still an issue? It was rewritten in d5d814e

I'm not sure. I don't think it crashes, but it might not be stable either?

I have been using the sdl audio driver now for a long time and never encounter this issue anymore.

That surprises me.

Was the problem from https://github.com/XboxDev/nxdk-sdl/pull/27#issuecomment-635409017 resolved eventually? Potential fixes might have been in SDL or in XAudio - maybe https://github.com/XboxDev/nxdk/pull/364 / https://github.com/XboxDev/nxdk/pull/364#issuecomment-641184491. I remember having lots and lots of trouble with that; I believe I never fully understood it, but suspected that it was related to XAudio sync of digital and analog outputs (= them being driven from the same interrupt)? If I fixed it, I probably discussed it on Discord or in one of the PRs or issues, but I can't be bothered to look through the history right now.

Also, most importantly, https://github.com/XboxDev/nxdk/issues/362 almost definitely still exists, which I consider to be a major issue for stability (it breaks application state across applications / quick-reboot).