mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-23 04:33:09 +00:00
NANCY: Properly pause all scene sounds
Fixed an issue where certain sound channels wouldn't get paused when changing state. Collapsed the pause/unpause functions inside Scene into a single function, and placed it inside SoundManager.
This commit is contained in:
parent
c3e7b418b9
commit
abc4168433
@ -231,7 +231,7 @@ void LoseGame::readData(Common::SeekableReadStream &stream) {
|
||||
}
|
||||
|
||||
void LoseGame::execute() {
|
||||
g_nancy->_sound->stopAndUnloadSpecificSounds();
|
||||
g_nancy->_sound->stopAndUnloadSceneSpecificSounds();
|
||||
NancySceneState.setDestroyOnExit();
|
||||
|
||||
if (!ConfMan.hasKey("original_menus") || ConfMan.getBool("original_menus")) {
|
||||
@ -268,7 +268,7 @@ void WinGame::readData(Common::SeekableReadStream &stream) {
|
||||
}
|
||||
|
||||
void WinGame::execute() {
|
||||
g_nancy->_sound->stopAndUnloadSpecificSounds();
|
||||
g_nancy->_sound->stopAndUnloadSceneSpecificSounds();
|
||||
NancySceneState.setDestroyOnExit();
|
||||
g_nancy->setState(NancyState::kCredits, NancyState::kMainMenu);
|
||||
|
||||
|
@ -583,7 +583,7 @@ void SoundManager::recalculateSoundEffects() {
|
||||
}
|
||||
}
|
||||
|
||||
void SoundManager::stopAndUnloadSpecificSounds() {
|
||||
void SoundManager::stopAndUnloadSceneSpecificSounds() {
|
||||
byte numSSChans = g_nancy->getStaticData().soundChannelInfo.numSceneSpecificChannels;
|
||||
|
||||
if (g_nancy->getGameType() == kGameTypeVampire && Nancy::State::Map::hasInstance()) {
|
||||
@ -601,6 +601,23 @@ void SoundManager::stopAndUnloadSpecificSounds() {
|
||||
stopSound("MSND");
|
||||
}
|
||||
|
||||
void SoundManager::pauseSceneSpecificSounds(bool pause) {
|
||||
byte numSSChans = g_nancy->getStaticData().soundChannelInfo.numSceneSpecificChannels;
|
||||
if (g_nancy->getGameType() == kGameTypeVampire && Nancy::State::Map::hasInstance()) {
|
||||
if (!pause || g_nancy->getState() != NancyState::kMap) {
|
||||
// Stop the map sound in certain scenes
|
||||
uint currentScene = NancySceneState.getSceneInfo().sceneID;
|
||||
if (currentScene == 0 || (currentScene >= 15 && currentScene <= 27)) {
|
||||
g_nancy->_sound->pauseSound(NancyMapState.getSound(), pause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (uint i = 0; i < numSSChans; ++i) {
|
||||
g_nancy->_sound->pauseSound(i, pause);
|
||||
}
|
||||
}
|
||||
|
||||
void SoundManager::initSoundChannels() {
|
||||
const SoundChannelInfo &channelInfo = g_nancy->getStaticData().soundChannelInfo;
|
||||
|
||||
|
@ -117,7 +117,8 @@ public:
|
||||
void recalculateSoundEffects();
|
||||
|
||||
// Used when changing scenes
|
||||
void stopAndUnloadSpecificSounds();
|
||||
void stopAndUnloadSceneSpecificSounds();
|
||||
void pauseSceneSpecificSounds(bool pause);
|
||||
|
||||
static Audio::SeekableAudioStream *makeHISStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 overrideSamplesPerSec = 0);
|
||||
|
||||
|
@ -149,7 +149,7 @@ void Scene::process() {
|
||||
case kStartSound:
|
||||
_state = kRun;
|
||||
if (_sceneState.currentScene.continueSceneSound == kLoadSceneSound) {
|
||||
g_nancy->_sound->stopAndUnloadSpecificSounds();
|
||||
g_nancy->_sound->stopAndUnloadSceneSpecificSounds();
|
||||
g_nancy->_sound->loadSound(_sceneState.summary.sound);
|
||||
g_nancy->_sound->playSound(_sceneState.summary.sound);
|
||||
}
|
||||
@ -180,7 +180,7 @@ void Scene::onStateEnter(const NancyState::NancyState prevState) {
|
||||
if (prevState == NancyState::kPause) {
|
||||
g_nancy->_sound->pauseAllSounds(false);
|
||||
} else {
|
||||
unpauseSceneSpecificSounds();
|
||||
g_nancy->_sound->pauseSceneSpecificSounds(false);
|
||||
}
|
||||
|
||||
g_nancy->_sound->stopSound("MSND");
|
||||
@ -201,7 +201,7 @@ bool Scene::onStateExit(const NancyState::NancyState nextState) {
|
||||
if (nextState == NancyState::kPause) {
|
||||
g_nancy->_sound->pauseAllSounds(true);
|
||||
} else {
|
||||
pauseSceneSpecificSounds();
|
||||
g_nancy->_sound->pauseSceneSpecificSounds(true);
|
||||
}
|
||||
|
||||
_gameStateRequested = NancyState::kNone;
|
||||
@ -234,32 +234,6 @@ void Scene::popScene() {
|
||||
_sceneState.isScenePushed = false;
|
||||
}
|
||||
|
||||
void Scene::pauseSceneSpecificSounds() {
|
||||
if (g_nancy->getGameType() == kGameTypeVampire && Nancy::State::Map::hasInstance() && g_nancy->getState() != NancyState::kMap) {
|
||||
uint currentScene = _sceneState.currentScene.sceneID;
|
||||
if (currentScene == 0 || (currentScene >= 15 && currentScene <= 27)) {
|
||||
g_nancy->_sound->pauseSound(NancyMapState.getSound(), true);
|
||||
}
|
||||
}
|
||||
|
||||
for (uint i = 0; i < 10; ++i) {
|
||||
g_nancy->_sound->pauseSound(i, true);
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::unpauseSceneSpecificSounds() {
|
||||
if (g_nancy->getGameType() == kGameTypeVampire && Nancy::State::Map::hasInstance()) {
|
||||
uint currentScene = _sceneState.currentScene.sceneID;
|
||||
if (currentScene == 0 || (currentScene >= 15 && currentScene <= 27)) {
|
||||
g_nancy->_sound->pauseSound(NancyMapState.getSound(), false);
|
||||
}
|
||||
}
|
||||
|
||||
for (uint i = 0; i < 10; ++i) {
|
||||
g_nancy->_sound->pauseSound(i, false);
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::setPlayerTime(Time time, byte relative) {
|
||||
if (relative == kRelativeClockBump) {
|
||||
// Relative, add the specified time to current playerTime
|
||||
|
@ -125,10 +125,7 @@ public:
|
||||
void changeScene(const SceneChangeDescription &sceneDescription);
|
||||
void pushScene();
|
||||
void popScene();
|
||||
|
||||
void pauseSceneSpecificSounds();
|
||||
void unpauseSceneSpecificSounds();
|
||||
|
||||
|
||||
void setPlayerTime(Time time, byte relative);
|
||||
Time getPlayerTime() const { return _timers.playerTime; }
|
||||
Time getTimerTime() const { return _timers.timerIsActive ? _timers.timerTime : 0; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user