From 846cbd5e35f9b12d7f735ee1a62bc6cb7599d873 Mon Sep 17 00:00:00 2001 From: Allanis <allanis@saracraft.net> Date: Thu, 22 May 2014 18:31:41 +0100 Subject: [PATCH] [Change] Slightly cleaner implementation of channel pause/resume. --- src/player.c | 7 ++----- src/sound.c | 22 ++++++++++++++++++++++ src/sound.h | 4 ++++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/player.c b/src/player.c index afd1ca2..c1bfa77 100644 --- a/src/player.c +++ b/src/player.c @@ -5,7 +5,6 @@ */ #include <stdlib.h> -#include "SDL_mixer.h" /** @todo Remove dependency. */ #include "lephisto.h" #include "pilot.h" @@ -2219,8 +2218,7 @@ void player_accelOver(void) { * for pausing/resuming groups in SDL_Mixer. */ void player_soundPause(void) { - if(!Mix_Paused(0)) - Mix_Pause(0); + sound_pauseChannel(0); } /** @@ -2230,8 +2228,7 @@ void player_soundPause(void) { * for pausing/resuming groups in SDL_Mixer. */ void player_soundResume(void) { - if(Mix_Paused(0)) - Mix_Resume(0); + sound_resumeChannel(0); } /** diff --git a/src/sound.c b/src/sound.c index 842c518..d0d7f90 100644 --- a/src/sound.c +++ b/src/sound.c @@ -726,3 +726,25 @@ static alVoice* voice_get(int id) { return NULL; } +/** + * @brief Pause a channel, should be eliminated to pause groups also. + * @param num Channel to pause, not that channel != voice. + */ +void sound_pauseChannel(int num) { + if(sound_disabled) return; + + if(!Mix_Paused(num)) + Mix_Pause(num); +} + +/** + * @brief Resume a channel, should be eliminated to resume groups also. + * @param num Channel to resume, not that channel != voice. + */ +void sound_resumeChannel(int num) { + if(sound_disabled) return; + + if(Mix_Paused(num)) + Mix_Resume(num); +} + diff --git a/src/sound.h b/src/sound.h index 0a32b22..7ed8557 100644 --- a/src/sound.h +++ b/src/sound.h @@ -23,3 +23,7 @@ int sound_createGroup(int tag, int start, int size); int sound_playGroup(int group, int sound, int once); void sound_stopGroup(int group); +/* Not too portable functions that should be eliminated someday. */ +void sound_pauseChannel(int num); +void sound_resumeChannel(int num); +