-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
Crash when changing default playback device. #764
Comments
So I could not reproduce it with https://github.com/raysan5/raylib/blob/master/examples/audio/audio_music_stream.c https://github.com/raysan5/raylib/blob/master/src/external/miniaudio.h 2023-11-01_20-52-28.mp4 |
OK, it's definitely suspicious that it works fine with simple_playback_sine. I can see at the time of the crash that Are you compiling raylib from source? If so, there's the commented line In src/raudio.c:
|
and here is the call stack from visuals studio in case it might help:
|
Well this is a start:
Now the question is why is that failing. At a minimum I'll need to review the code to better handle that - obviously when these particular errors are happening it's putting the device into an invalid state. Once that's addressed it might fix the crash, but the actual rerouting functionality still won't work. I still don't understand why you're getting those errors with raylib and not simple_playback_sine though. |
Yeah, its really strange.... It's reproducable on raylib by multiple people though. |
Any updates on this? I need to ship a game using raylib soon, so if you need any help to reproduce it, then I'd gladly help in whatever way I can. |
Can you reproduce it? It's unlikely your users are going to be switching audio context in the middle of games so its going to be a somewhat rare crash. Sucks but works! |
@jestarray I haven't tried reproducing it outside of Raylib, with Raylib it 100% crashes inside miniaudio, even with a tiny program like this:
(above program translated from Odin to C by hand, it might contain errors)
I think it depends on the user. I often start games and realize I had my output set to speakers instead of my headphones or the other way around, and alt-tab out to change it with the game running (which is how I ran into this issue) I don't have time to look into a miniaudio-only repro right now, but maybe in a few weeks. |
An update on how frequent this can happen: Some laptops switch audio device when you plug the headphones in, i.e. they don't do a hardware switch of the audio, they actually instruct windows to switch audio output. So in that case the game will crash because you plug in the headphones when you notice the audio coming out of your laptop speakers. |
Related issue: raysan5/raylib#3743 |
Here's my attempt to figure this out: raysan5/raylib#3743 (comment) |
Thanks for the heads up on the |
Hi, I wrapped that call to CoCreateInstance with CoInitializeEx()/CoUninitialize() like you said. Do you think there may be any other issues because of this? I'm looking into this because I am shipping my game on Steam in 5 days and I would love to not have this crash then. |
What is the status of this issue - is anyone looking into this? Please understand that this issue is causing shipped games to crash for real. People nowadays have bluetooth headphones etc which, believe me or not, they will turn on and off even when a game is launched. |
@jkaup I did this workaround
It hasn't crashed when changing device since that. No idea if it could have any nasty side effects though. My game shipped with the workaround anyways! |
Hi Karl, thanks for your tip! I did the same workaround as well for my game now and it works. However, it would be great to have this solved in the miniaudio library itself, or at least have the workaround "officially" in the miniaudio side and not as separate fixes on each users' forks. |
Thanks for the follow up, I can wait for a miniaudio review or just merge raysan5/raylib#4102 in the meantime, that seems to address the issue. Please, @karl-zylinski could you review that PR? is it the same solution you used? |
@raysan5 it is more or less the same solution, I put in a few comments on that PR |
@karl-zylinski thanks for the review, I'll wait for a while for this issue to be addressed in |
Very sorry for the delay with this one. This should be fixed in the dev branch. If this issue continues feel free to reopen this issue or create a new one. |
raysan5/raylib#3489
CC @jestarray
I've been unable to replicate this. Are you able to try miniaudio's simple_playback_sine example? It's easy to compile - there's no dependencies or anything. It'll just play a sine wave, and it'll attempt to reroute audio when you try to change the default device.
Could you also show me the contents of the
ma_device
object at the time of the crash? There's not quite enough information for me to go on so far.Is this 100% reproducible for you?
The text was updated successfully, but these errors were encountered: