BURIED: Use separate pause sound functions for pausing the game

This commit is contained in:
Matthew Hoops 2014-05-08 22:46:19 -04:00 committed by Eugene Sandulenko
parent 8f82da6e07
commit 810f006e9a
3 changed files with 19 additions and 3 deletions

View File

@ -449,14 +449,14 @@ uint32 BuriedEngine::computeFileNameResourceID(int timeZone, int environment, in
void BuriedEngine::pauseEngineIntern(bool pause) {
if (pause) {
_sound->stop();
_sound->pause(true);
for (VideoList::iterator it = _videos.begin(); it != _videos.end(); it++)
(*it)->pauseVideo();
_pauseStartTime = g_system->getMillis();
} else {
_sound->restart();
_sound->pause(false);
for (VideoList::iterator it = _videos.begin(); it != _videos.end(); it++)
(*it)->resumeVideo();

View File

@ -76,6 +76,11 @@ void SoundManager::shutDown() {
}
}
void SoundManager::pause(bool shouldPause) {
for (int i = 0; i < kMaxSounds; i++)
_soundData[i]->pause(shouldPause);
}
bool SoundManager::setAmbientSound(const Common::String &fileName, bool fade, byte finalVolumeLevel) {
// Determine which of the two ambient tracks to use
int newAmbientTrack = (_lastAmbient == 0) ? 1 : 0;
@ -748,4 +753,9 @@ bool SoundManager::Sound::stop() {
return true;
}
void SoundManager::Sound::pause(bool shouldPause) {
if (_soundData && _handle)
g_system->getMixer()->pauseHandle(*_handle, shouldPause);
}
} // End of namespace Buried

View File

@ -78,9 +78,14 @@ public:
bool startFootsteps(int footstepsID);
bool stopFootsteps();
// PAUSE FUNCTIONS
// Pause functions
// stop()/restart() do as they say on the tin and aren't true pause functions.
// This is what the original does for pausing, and it needs to be done this way.
// pause() is used for implementing pauseEngineIntern(). Since stop()/restart()
// are not re-entrant, they're not suitable for that purpose.
bool stop();
bool restart();
void pause(bool shouldPause);
// TIMER CALLBACK FUNCTION
void timerCallback();
@ -113,6 +118,7 @@ private:
bool start();
bool isPlaying() const;
bool stop();
void pause(bool shouldPause);
protected:
Audio::RewindableAudioStream *_soundData; // Stream to the data