| Summary: | Mix_HaltMusic doesn't call music finished hook | ||
|---|---|---|---|
| Product: | SDL_mixer | Reporter: | Alex <alex.d> |
| Component: | misc | Assignee: | Sam Lantinga <slouken> |
| Status: | ASSIGNED --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | API change | ||
| Priority: | P2 | CC: | icculus, sdl |
| Version: | 1.2.8 | ||
| Hardware: | x86 | ||
| OS: | Linux | ||
| Attachments: |
Patch to add this behaviour.
Patch to call music callback anytime music is stopped |
||
|
Description
Alex
2008-02-13 06:34:47 UTC
Ryan, can you evaluate this? Thanks! The docs for Mix_HookMusicFinished() say: "This callback is only called if the music finishes naturally." So, it might break existing programs if we change it to run the callback during Mix_HaltMusic(). Tossing bug to Sam to decide if that's okay. --ryan. Created attachment 401 [details]
Patch to add this behaviour.
This patch will add the behaviour requested here, if you think it's safe to do so.
--ryan.
Honestly, I'm sort of thinking we should do this and see what breaks. --ryan. Okay, I remember we added this for Heroes 3, so we should probably check to see if that breaks. ;) I looked into this more closely, and this is a sensible but dangerous change to make. The right thing to do here is to have both the channel and music callbacks always called when a channel or music stops for any reason, but it should be passed a reason why the sound stopped. The typical use of the music stopped callback is to pick another song to play. The assumption is that if you're explicitly halting the music that you have some other action that you are in control of that you want to take place. If we change this behavior, then suddenly applications will be getting a finished callback when they don't expect it, and this could cause anything from application bugs to crashes. So, I'm punting this until we do an SDL_mixer API revamp. Created attachment 409 [details]
Patch to call music callback anytime music is stopped
This is a more comprehensive patch that calls the finished hook anytime music stops playing. If this were applied, we'd also want to change the hook function to take a reason as a parameter, and update the channel finished hook to do the same thing.
Waking up a hibernating bug here... If the behaviour of the lib is not changed as discussed in this bug (i.e. the attached patch won't be applied) would it be appropriate to fix the documentation to reflect the reality? It currently claims that the music finished callback would be called when Mix_HaltMusic() is called but that doesn't happen. I just spent quite an amount of time believing the documentation and wondering why my callback doesn't get called. I might not be the only one wasting time this way... (In reply to comment #11) > If the behaviour of the lib is not changed as discussed in this bug (i.e. the > attached patch won't be applied) would it be appropriate to fix the > documentation to reflect the reality? It currently claims that the music > finished callback would be called when Mix_HaltMusic() is called but that > doesn't happen. Where does it say this? --ryan. (In reply to comment #12) > (In reply to comment #11) > > If the behaviour of the lib is not changed as discussed in this bug (i.e. the > > attached patch won't be applied) would it be appropriate to fix the > > documentation to reflect the reality? It currently claims that the music > > finished callback would be called when Mix_HaltMusic() is called but that > > doesn't happen. > > Where does it say this? In http://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html#SEC67 [--] Any callback set by Mix_HookMusicFinished will be called when the music stops. [--] And in http://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html#SEC69 [--] This sets up a function to be called when music playback is halted. Any time music stops, the music_finished function will be called. [--] Sam, can we update those docs? --ryan. |