-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[SDL_mixer] Fix Mix_PlayChannel audio 'leaking' and fix onended callback to correctly update audio status #22581
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I wonder if we could add test for this? Perhaps updating an existed test_interactive.py test?
Thanks, will look into it. |
@sbc100 please review, thanks! |
060e0a0
to
cd5eba9
Compare
Updated, squashed.
I don't think it's a bug. As far as I understand, the implementation has 2 ways of loading sounds, first is preloaded audio it preloads sounds into audio elements, second option is using webAudio. If webAudio is not available, the implementation will fallback to audio elements anyway. The implementation tries to mimic webAudio in an audio-like way. So it's valid to have 2 cases there. Honestly, I never used 1st case (audio elements). --
Should I do some extra steps to clean workdir? |
Looks like closure is complaining:
Maybe |
…ack to correctly update audio status
Done |
Mix_PlayChannel audio 'leaking'
Hi, I found a bug while using builtin SDL_mixer 1.2.
You can play many sounds on same channel in case if you do not manuall halt it before.
Reagrding to documentation of SDL:
So, when you call
It shoud internally halt the channel. Current emscripten implemntation is wrong, the previously runned chunk on that channel continue to play.
You can easily reporoduce this with code:
If you compile and run it then you will hear infinite looping of music.ogg, and every 5 sec new one is started.
I fixed this by calling Mix_HaltChannel if channel is playing audio.
fix onended callback to correctly update audio status
Found another issue in SDL_mixer implementation. Current implementation does not detect playing status of sounds correctly (
Mix_Playing
,Mix_PlayingMusic
). This happens because in ononended
callback comparsion withthis
works only for case when audio created by cloning audio node, otherwise comparsion should be against audio.webAudioNode.