diff options
author | Johannes Schickel | 2010-01-05 18:32:26 +0000 |
---|---|---|
committer | Johannes Schickel | 2010-01-05 18:32:26 +0000 |
commit | 50888f5b65fe4a03eb92b848ec8228f78c5a006a (patch) | |
tree | 55d3cb078ec0dc03295210dffbd8922801c1a7a6 /sound | |
parent | cc87f4a741a2b9d85b31b6bae3617beb1a7da6e9 (diff) | |
download | scummvm-rg350-50888f5b65fe4a03eb92b848ec8228f78c5a006a.tar.gz scummvm-rg350-50888f5b65fe4a03eb92b848ec8228f78c5a006a.tar.bz2 scummvm-rg350-50888f5b65fe4a03eb92b848ec8228f78c5a006a.zip |
- Fix a bug in Channel::pause for recursive pausing.
- Fix bug in Channel:getElapsedTime, when called while the channel is paused.
svn-id: r47029
Diffstat (limited to 'sound')
-rw-r--r-- | sound/mixer.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp index d012ca6f51..933b86e4a9 100644 --- a/sound/mixer.cpp +++ b/sound/mixer.cpp @@ -79,15 +79,19 @@ public: void pause(bool paused) { //assert((paused && _pauseLevel >= 0) || (!paused && _pauseLevel)); - if (paused) + if (paused) { _pauseLevel++; - else if (_pauseLevel > 0) + + if (_pauseLevel == 1) + _pauseStartTime = g_system->getMillis(); + } else if (_pauseLevel > 0) { _pauseLevel--; - if (_pauseLevel > 0) - _pauseStartTime = g_system->getMillis(); - else - _pauseTime += (g_system->getMillis() - _pauseStartTime); + if (!_pauseLevel) { + _pauseTime = (g_system->getMillis() - _pauseStartTime); + _pauseStartTime = 0; + } + } } bool isPaused() { return _pauseLevel != 0; @@ -441,7 +445,6 @@ void Channel::mix(int16 *data, uint len) { _samplesConsumed = _samplesDecoded; _mixerTimeStamp = g_system->getMillis(); _pauseTime = 0; - _samplesDecoded += _converter->flow(*_input, data, len, vol_l, vol_r); } } @@ -451,7 +454,12 @@ uint32 Channel::getElapsedTime() { return 0; const uint32 rate = _mixer->getOutputRate(); - const uint32 delta = g_system->getMillis() - _mixerTimeStamp - _pauseTime; + uint32 delta = 0; + + if (isPaused()) + delta = _pauseStartTime - _mixerTimeStamp; + else + delta = g_system->getMillis() - _mixerTimeStamp - _pauseTime; // Convert the number of samples into a time duration. |