From 93b1a53c72f1c181439b7dcd43c94d911a2e30ee Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 30 Jun 2007 21:02:58 +0000 Subject: Changed semantics of Mixer::pause*() methods -- if you pause n times, you have to unpause n times before the sound resumes (this means pauseAll works correct in engines which selectively pause/resume single sounds) svn-id: r27798 --- sound/mixer.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sound/mixer.cpp b/sound/mixer.cpp index cc353d58b4..4ca7b4c897 100644 --- a/sound/mixer.cpp +++ b/sound/mixer.cpp @@ -54,7 +54,7 @@ private: bool _permanent; byte _volume; int8 _balance; - bool _paused; + int _pauseLevel; int _id; uint32 _samplesConsumed; uint32 _samplesDecoded; @@ -77,10 +77,15 @@ public: return _input->endOfStream(); } void pause(bool paused) { - _paused = paused; + assert((paused && _pauseLevel >= 0) || (!paused && _pauseLevel)); + + if (paused) + _pauseLevel++; + else + _pauseLevel--; } bool isPaused() { - return _paused; + return _pauseLevel != 0; } void setVolume(const byte volume) { _volume = volume; @@ -375,7 +380,7 @@ int Mixer::getVolumeForSoundType(SoundType type) const { Channel::Channel(Mixer *mixer, Mixer::SoundType type, AudioStream *input, bool autofreeStream, bool reverseStereo, int id, bool permanent) : _type(type), _mixer(mixer), _autofreeStream(autofreeStream), - _volume(Mixer::kMaxChannelVolume), _balance(0), _paused(false), _id(id), _samplesConsumed(0), + _volume(Mixer::kMaxChannelVolume), _balance(0), _pauseLevel(0), _id(id), _samplesConsumed(0), _samplesDecoded(0), _mixerTimeStamp(0), _converter(0), _input(input), _permanent(permanent) { assert(mixer); assert(input); -- cgit v1.2.3