diff --git a/SDL2pp/Mixer.cc b/SDL2pp/Mixer.cc index dc5bdd8..951151e 100644 --- a/SDL2pp/Mixer.cc +++ b/SDL2pp/Mixer.cc @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2015 Dmitry Marakasov + Copyright (C) 2015-2016 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -119,6 +119,10 @@ void Mixer::SetChannelFinishedHandler(ChannelFinishedHandler channel_finished) { Mix_ChannelFinished(channel_finished); } +void Mixer::RemoveChannelFinishedHandler() { + Mix_ChannelFinished(nullptr); +} + int Mixer::IsChannelPlaying(int channel) const { return Mix_Playing(channel); } @@ -228,6 +232,10 @@ void Mixer::SetMusicFinishedHandler(MusicFinishedHandler music_finished) { Mix_HookMusicFinished(music_finished); } +void Mixer::RemoveMusicFinishedHandler() { + Mix_HookMusicFinished(nullptr); +} + void Mixer::SetMusicHook(MusicHook&& hook) { if (!hook) { Mix_HookMusic(nullptr, nullptr); diff --git a/SDL2pp/Mixer.hh b/SDL2pp/Mixer.hh index 61a7dbe..23dc96d 100644 --- a/SDL2pp/Mixer.hh +++ b/SDL2pp/Mixer.hh @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2015 Dmitry Marakasov + Copyright (C) 2015-2016 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -357,6 +357,14 @@ public: //////////////////////////////////////////////////////////// void SetChannelFinishedHandler(ChannelFinishedHandler channel_finished); + //////////////////////////////////////////////////////////// + /// \brief Remove callback for when channel finishes playing + /// + /// \see https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html#SEC37 + /// + //////////////////////////////////////////////////////////// + void RemoveChannelFinishedHandler(); + ///@} ///@{ @@ -686,6 +694,14 @@ public: //////////////////////////////////////////////////////////// void SetMusicFinishedHandler(MusicFinishedHandler music_finished); + //////////////////////////////////////////////////////////// + /// \brief Remove a callback for when music stops + /// + /// \see https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html#SEC69 + /// + //////////////////////////////////////////////////////////// + void RemoveMusicFinishedHandler(); + ///@} ///@{