1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-17 10:21:11 +00:00

Merge pull request #2440 from jlaumon/sound_crash_fix

Fixed crash with sound disabled (bug #4600)
This commit is contained in:
Andrei Kortunov 2019-07-05 11:43:01 +04:00 committed by GitHub
commit 240f76e822
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View File

@ -23,6 +23,7 @@
Bug #4384: Resist Normal Weapons only checks ammunition for ranged weapons Bug #4384: Resist Normal Weapons only checks ammunition for ranged weapons
Bug #4411: Reloading a saved game while falling prevents damage in some cases Bug #4411: Reloading a saved game while falling prevents damage in some cases
Bug #4540: Rain delay when exiting water Bug #4540: Rain delay when exiting water
Bug #4600: Crash when no sound output is available or --no-sound is used.
Bug #4639: Black screen after completing first mages guild mission + training Bug #4639: Black screen after completing first mages guild mission + training
Bug #4701: PrisonMarker record is not hardcoded like other markers Bug #4701: PrisonMarker record is not hardcoded like other markers
Bug #4703: Editor: it's possible to preview levelled list records Bug #4703: Editor: it's possible to preview levelled list records

View File

@ -983,7 +983,6 @@ void CharacterController::handleTextKey(const std::string &groupname, const std:
if(evt.compare(0, 7, "sound: ") == 0) if(evt.compare(0, 7, "sound: ") == 0)
{ {
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
sndMgr->stopSound3D(mPtr, evt.substr(7));
sndMgr->playSound3D(mPtr, evt.substr(7), 1.0f, 1.0f); sndMgr->playSound3D(mPtr, evt.substr(7), 1.0f, 1.0f);
return; return;
} }
@ -1024,7 +1023,6 @@ void CharacterController::handleTextKey(const std::string &groupname, const std:
} }
else else
{ {
sndMgr->stopSound3D(mPtr, sound);
sndMgr->playSound3D(mPtr, sound, volume, pitch); sndMgr->playSound3D(mPtr, sound, volume, pitch);
} }
} }

View File

@ -747,6 +747,9 @@ namespace MWSound
void SoundManager::stopSound(const std::string& soundId) void SoundManager::stopSound(const std::string& soundId)
{ {
if(!mOutput->isInitialized())
return;
Sound_Buffer *sfx = loadSound(Misc::StringUtils::lowerCase(soundId)); Sound_Buffer *sfx = loadSound(Misc::StringUtils::lowerCase(soundId));
if (!sfx) return; if (!sfx) return;
@ -755,6 +758,9 @@ namespace MWSound
void SoundManager::stopSound3D(const MWWorld::ConstPtr &ptr, const std::string& soundId) void SoundManager::stopSound3D(const MWWorld::ConstPtr &ptr, const std::string& soundId)
{ {
if(!mOutput->isInitialized())
return;
Sound_Buffer *sfx = loadSound(Misc::StringUtils::lowerCase(soundId)); Sound_Buffer *sfx = loadSound(Misc::StringUtils::lowerCase(soundId));
if (!sfx) return; if (!sfx) return;