[Scummvm-git-logs] scummvm master -> 7e04f3d9399bf7e7f0b3ef2b5d9150afefe4d65b
sev-
sev at scummvm.org
Wed Aug 25 16:47:31 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
7e04f3d939 SWORD25: Play no music if no sound device selected. Bugreport #11716
Commit: 7e04f3d9399bf7e7f0b3ef2b5d9150afefe4d65b
https://github.com/scummvm/scummvm/commit/7e04f3d9399bf7e7f0b3ef2b5d9150afefe4d65b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-08-25T18:46:07+02:00
Commit Message:
SWORD25: Play no music if no sound device selected. Bugreport #11716
Changed paths:
engines/sword25/sfx/soundengine.cpp
engines/sword25/sfx/soundengine.h
diff --git a/engines/sword25/sfx/soundengine.cpp b/engines/sword25/sfx/soundengine.cpp
index 41edaa5f83..02acf9827b 100644
--- a/engines/sword25/sfx/soundengine.cpp
+++ b/engines/sword25/sfx/soundengine.cpp
@@ -38,6 +38,7 @@
#include "audio/audiostream.h"
#include "audio/decoders/vorbis.h"
+#include "audio/mididrv.h"
#include "common/system.h"
#include "common/config-manager.h"
@@ -65,6 +66,15 @@ SoundEngine::SoundEngine(Kernel *pKernel) : ResourceService(pKernel) {
_mixer = g_system->getMixer();
_maxHandleId = 1;
+
+ Common::String selDevStr = ConfMan.hasKey("music_driver") ? ConfMan.get("music_driver") : Common::String("auto");
+ MidiDriver::DeviceHandle dev = MidiDriver::getDeviceHandle(selDevStr.empty() ? Common::String("auto") : selDevStr);
+ _noMusic = (MidiDriver::getMusicType(dev) == MT_NULL || MidiDriver::getMusicType(dev) == MT_INVALID);
+
+ if (_noMusic) {
+ warning("AUDIO: MUSIC IS FORCED TO OFF");
+ ConfMan.setInt("music_volume", 0);
+ }
}
bool SoundEngine::init(uint sampleRate, uint channels) {
@@ -79,8 +89,10 @@ void SoundEngine::setVolume(float volume, SOUND_TYPES type) {
switch (type) {
case SoundEngine::MUSIC:
- ConfMan.setInt("music_volume", val);
- _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, val);
+ if (!_noMusic) {
+ ConfMan.setInt("music_volume", val);
+ _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, val);
+ }
break;
case SoundEngine::SPEECH:
ConfMan.setInt("speech_volume", val);
@@ -100,7 +112,7 @@ float SoundEngine::getVolume(SOUND_TYPES type) {
switch (type) {
case SoundEngine::MUSIC:
- val = ConfMan.getInt("music_volume");
+ val = _noMusic ? 0 : ConfMan.getInt("music_volume");
break;
case SoundEngine::SPEECH:
val = ConfMan.getInt("speech_volume");
@@ -203,6 +215,9 @@ bool SoundEngine::playSound(const Common::String &fileName, SOUND_TYPES type, fl
}
uint SoundEngine::playSoundEx(const Common::String &fileName, SOUND_TYPES type, float volume, float pan, bool loop, int loopStart, int loopEnd, uint layer, uint handleId) {
+ if (type == MUSIC && _noMusic)
+ return 0;
+
#ifdef USE_VORBIS
Common::SeekableReadStream *in = Kernel::getInstance()->getPackage()->getStream(fileName);
Audio::SeekableAudioStream *stream = Audio::makeVorbisStream(in, DisposeAfterUse::YES);
diff --git a/engines/sword25/sfx/soundengine.h b/engines/sword25/sfx/soundengine.h
index 07595d860c..0376923784 100644
--- a/engines/sword25/sfx/soundengine.h
+++ b/engines/sword25/sfx/soundengine.h
@@ -261,6 +261,8 @@ private:
SndHandle _handles[SOUND_HANDLES];
uint32 _maxHandleId;
+
+ bool _noMusic;
};
} // End of namespace Sword25
More information about the Scummvm-git-logs
mailing list