diff options
author | Simon Howard | 2005-10-15 16:58:31 +0000 |
---|---|---|
committer | Simon Howard | 2005-10-15 16:58:31 +0000 |
commit | 1ba7b1ddfd66e1ec98e4c47a79c3facbd84a7495 (patch) | |
tree | dd1991d59b1ecbfc6b5cf7f86ac1e7a3196a40aa | |
parent | 02a491c087794f1e170adc3eadcc9375c8d7be29 (diff) | |
download | chocolate-doom-1ba7b1ddfd66e1ec98e4c47a79c3facbd84a7495.tar.gz chocolate-doom-1ba7b1ddfd66e1ec98e4c47a79c3facbd84a7495.tar.bz2 chocolate-doom-1ba7b1ddfd66e1ec98e4c47a79c3facbd84a7495.zip |
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
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | src/i_sound.c | 53 |
2 files changed, 42 insertions, 13 deletions
@@ -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 <stdio.h> #include <stdlib.h> @@ -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) |