summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2005-10-15 16:58:31 +0000
committerSimon Howard2005-10-15 16:58:31 +0000
commit1ba7b1ddfd66e1ec98e4c47a79c3facbd84a7495 (patch)
treedd1991d59b1ecbfc6b5cf7f86ac1e7a3196a40aa /src
parent02a491c087794f1e170adc3eadcc9375c8d7be29 (diff)
downloadchocolate-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
Diffstat (limited to 'src')
-rw-r--r--src/i_sound.c53
1 files changed, 40 insertions, 13 deletions
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)