From 1ba7b1ddfd66e1ec98e4c47a79c3facbd84a7495 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 15 Oct 2005 16:58:31 +0000 Subject: Fix MIDI music not pausing when using SDL_mixer's native MIDI playback. The SDL_mixer native MIDI code does not pause music properly - use a workaround of setting the volume to 0. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 196 --- NEWS | 2 ++ src/i_sound.c | 53 ++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/NEWS b/NEWS index d7e1d769..2b274b43 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,8 @@ * Crash when switching applications while running fullscreen * Lost soul bounce logic (do not bounce in Registered/Shareware) * Mouse buttons mapped incorrectly (button 1 is right, 2 is middle) + * Music not pausing when game is paused, when using SDL_mixer's + native MIDI playback. 0.1.0 (2005-10-09): Dehacked support diff --git a/src/i_sound.c b/src/i_sound.c index 18be082f..0c93f540 100644 --- a/src/i_sound.c +++ b/src/i_sound.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: i_sound.c 152 2005-10-02 20:23:04Z fraggle $ +// $Id: i_sound.c 196 2005-10-15 16:58:31Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -22,6 +22,11 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.21 2005/10/15 16:58:31 fraggle +// Fix MIDI music not pausing when using SDL_mixer's native MIDI playback. +// The SDL_mixer native MIDI code does not pause music properly - use +// a workaround of setting the volume to 0. +// // Revision 1.20 2005/10/02 20:23:04 fraggle // Guard against music lumps containing non-MUS data, document in bugs list // @@ -96,7 +101,7 @@ //----------------------------------------------------------------------------- static const char -rcsid[] = "$Id: i_sound.c 152 2005-10-02 20:23:04Z fraggle $"; +rcsid[] = "$Id: i_sound.c 196 2005-10-15 16:58:31Z fraggle $"; #include #include @@ -270,15 +275,6 @@ void I_SetSfxVolume(int volume) snd_SfxVolume = volume; } -// MUSIC API - dummy. Some code from DOS version. -void I_SetMusicVolume(int volume) -{ - // Internal state variable. - snd_MusicVolume = volume; - - Mix_VolumeMusic((volume * MIX_MAX_VOLUME) / 15); -} - // // Retrieve the raw data lump index @@ -505,6 +501,33 @@ void I_ShutdownMusic(void) static int looping=0; static int musicdies=-1; +static boolean musicpaused = false; + +// +// SDL_mixer's native MIDI music playing does not pause properly. +// As a workaround, set the volume to 0 when paused. +// + +static void UpdateMusicVolume(void) +{ + int vol; + + if (musicpaused) + vol = 0; + else + vol = (snd_MusicVolume * MIX_MAX_VOLUME) / 15; + + Mix_VolumeMusic(vol); +} + +// MUSIC API - dummy. Some code from DOS version. +void I_SetMusicVolume(int volume) +{ + // Internal state variable. + snd_MusicVolume = volume; + + UpdateMusicVolume(); +} void I_PlaySong(void *handle, int looping) { @@ -530,7 +553,9 @@ void I_PauseSong (void *handle) if (!music_initialised) return; - Mix_PauseMusic(); + musicpaused = true; + + UpdateMusicVolume(); } void I_ResumeSong (void *handle) @@ -538,7 +563,9 @@ void I_ResumeSong (void *handle) if (!music_initialised) return; - Mix_ResumeMusic(); + musicpaused = false; + + UpdateMusicVolume(); } void I_StopSong(void *handle) -- cgit v1.2.3