| Summary: | Mix_HaltMusic does not call Music Finish Hook [patch] | ||
|---|---|---|---|
| Product: | SDL_mixer | Reporter: | Gabriel Jacobo <gabomdq> |
| Component: | misc | Assignee: | Gabriel Jacobo <gabomdq> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | jorgen |
| Version: | unspecified | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Attachments: | Call Music Finish Hook from Mix_HaltMusic | ||
This is hg changeset a4e9c53d9c30 for the 1.2 branch, and 131d1de92d4d for the default branch now, thanks! --ryan. This was intentionally not done back in the day, because it caused problems in Heroes III. Not that it matters now, just FYI. :) This change broke documented functionality: https://hg.libsdl.org/SDL_mixer/file/95e548111cc3/SDL_mixer.h#l210 "This callback is only called if the music finishes naturally." Since there's no way to figure out if this call came from a Mix_HaltMusic call or a natural finish, the calling application now needs to set some global state before calling Mix_HaltMusic to be able to differentiate. >:| I don't know if it's worth reverting, since this change was made over a year ago, but if nothing else the comments in SDL_mixer.h should be updated to reflect the changed functionality. Good point. Gabriel, what was the motivation for this change? The motivation is stated in my first comment on this bug, the doc for Mix_HaltMusic said it will call the callback, and it wasn't doing that. So, there's a conflict in the documentation :) I think it's best to leave it as is now, if you don't get a callback at all, the user can not work around this limitation without modifying the library code. However, if you do issue the callback and for some reason care about whether it was a manual stop or a "natural" stop, you can keep track of that with your own flag. The docs will have to be fixed whatever alternative you end up choosing. I don't see where in the comments for Mix_HaltMusic it states that it'll call the hook, because it doesn't *have* any comments. The docs specify that behavior, but I have no idea where the docs are generated from: http://jcatki.no-ip.org:8080/SDL_mixer/SDL_mixer.html#SEC67 While ideally I would've seen us revert this change, since it changes functionality, it has been this way for over a year now, and changing behavior again is worse. Like you point out, at least there's a way to work around to get the old behavior with the new behavior. Here's my comment update: https://hg.libsdl.org/SDL_mixer/rev/99007f264b9c |
Created attachment 959 [details] Call Music Finish Hook from Mix_HaltMusic The hook set up with Mix_HookMusicFinished is not being called when you issue a Mix_HaltMusic, though it should according to the documentation: "int Mix_HaltMusic() Halt playback of music. This interrupts music fader effects. Any callback set by Mix_HookMusicFinished will be called when the music stops."