-
Notifications
You must be signed in to change notification settings - Fork 344
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
Fix audio stuttering when first playing a sound #885
base: master
Are you sure you want to change the base?
Conversation
8619c2d
to
2acbcc2
Compare
The sound stuttering was fixed, but something suspicious was noticed in the log
In So, I added a check to prevent init and deinit from being called twice. |
8619c2d
to
2acbcc2
Compare
I would like to make commits and comments step by step, but I'm not very familiar with git and it's not going well. In
|
I think there is room for improvement in the Next, |
Continuing with On Linux, debug messages are output during initialization. (with --debug) On Windows (Vista and later), the current volume value is output to the log every time Calling |
Hm. I'm pretty sure that I looked into AudioManager when the Pi5 came out, as I was having some issues there, and after spending some time here my takeaways were "there's a good reason for this to work the way it does" and "I'm not going to touch it". I did not touch VolumeControl, so I cannot comment on that. I do wonder, however, if we do need to touch VolumeControl - is something not working there? I normally try to follow the "Chesterton's fence" thought process, whereby if I don't really understand why something is the way it is, I don't try to change it. Alas, it was a long time ago, but let me try to shed some more light into some of the things I seem to recall, for you to at least test. First, SDL Audio isn't great - when something takes over the Audio, it'll exclusively own that resource. This means that, if you don't init/deinit things you cannot have theme audio AND video audio coexisting. Audio used to work differently before the Pi5 (I'm assuming related to the latest Raspberry Pi OS, rather than hardware) and on the Pi5, so any meaningful change here would need to be tested on both Pi3/4 and Pi5. Have you checked if you get audio from videos (VLC and OMX Player if on a Pi3/4) and from a theme with your changes? Second, even before all these changes, then, I'd challenge some potentially simpler change since, per your comments:
So the init/deinit in itself cannot be the problem. Did you try just doing a fake init/deinit at the beginning of ES seeing if it changes the first playback, which is effectively what you're trying to address, without trying to change the entire audio stack? Just a thought. I'll be honest, but unless this is thoroughly tested across multiple setups, I will be very hesitant to merge changes to sensitive code that has been around for the better part of 12 years, without any meaningful issue, as this is an area of the code I have (other than my failed experience) no meaningful knowledge of, and I'd have a hard time making sure it keeps working on all types of OS's it does. Hope this helps, and do keep us posted. |
@pjft Thank you for your quick comment. |
By all means, keep exploring this and do try out the suggestion I made first as well, as well as the edge cases I asked about and report back. I agree that the forums can be a good source for testing. Thanks for looking into this. |
Have you ever had a strange first sound (such as moving the cursor) after starting up ES?
It might not be rumbling, it might sound fuzzing, etc.
I wanted to get rid of that stuttering.
A bit of research, I found seemed like
AudioManager
wasn't initialized until the moment just before something was played.AudioManager
is initialized just before the first sound is played. and I assumed this issue was caused by the first sound played in an unstable moment.So I changed it so that initialization takes place before the first sound is played, before the ES main loop.