Skip to content

Commit

Permalink
Fix audio leaking in builtin SDL_mixer
Browse files Browse the repository at this point in the history
  • Loading branch information
caiiiycuk authored Sep 18, 2024
1 parent bf910d6 commit 8000d7f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/library_sdl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2817,6 +2817,7 @@ var LibrarySDL = {
Mix_ReserveChannels: (num) => {
SDL.channelMinimumNumber = num;
},
Mix_PlayChannelTimed__deps: ['Mix_HaltChannel'],
Mix_PlayChannelTimed__proxy: 'sync',
Mix_PlayChannelTimed: (channel, id, loops, ticks) => {
// TODO: handle fixed amount of N loops. Currently loops either 0 or infinite times.
Expand Down Expand Up @@ -2863,6 +2864,9 @@ var LibrarySDL = {
if (channelInfo.audio == this) { channelInfo.audio.paused = true; channelInfo.audio = null; }
if (SDL.channelFinished) {{{ makeDynCall('vi', 'SDL.channelFinished') }}}(channel);
}
if (channelInfo.audio) {
_Mix_HaltChannel(channel);
}
channelInfo.audio = audio;
// TODO: handle N loops. Behavior matches Mix_PlayMusic
audio.loop = loops != 0;
Expand Down

0 comments on commit 8000d7f

Please sign in to comment.