[Scummvm-cvs-logs] SF.net SVN: scummvm:[47261] scummvm/trunk/engines/sci
waltervn at users.sourceforge.net
waltervn at users.sourceforge.net
Tue Jan 12 01:51:37 CET 2010
Revision: 47261
http://scummvm.svn.sourceforge.net/scummvm/?rev=47261&view=rev
Author: waltervn
Date: 2010-01-12 00:51:37 +0000 (Tue, 12 Jan 2010)
Log Message:
-----------
SCI: Handle master volume inside music drivers
Modified Paths:
--------------
scummvm/trunk/engines/sci/sci.cpp
scummvm/trunk/engines/sci/sci.h
scummvm/trunk/engines/sci/sound/music.cpp
scummvm/trunk/engines/sci/sound/music.h
scummvm/trunk/engines/sci/sound/softseq/adlib.cpp
scummvm/trunk/engines/sci/sound/softseq/amiga.cpp
scummvm/trunk/engines/sci/sound/softseq/pcjr.cpp
scummvm/trunk/engines/sci/sound/soundcmd.cpp
scummvm/trunk/engines/sci/sound/soundcmd.h
Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp 2010-01-12 00:18:40 UTC (rev 47260)
+++ scummvm/trunk/engines/sci/sci.cpp 2010-01-12 00:51:37 UTC (rev 47261)
@@ -178,6 +178,8 @@
}
#endif
+ syncSoundSettings();
+
_gamestate->_gui->init(_gamestate->usesOldGfxFunctions());
debug("Emulating SCI version %s\n", getSciVersionDesc(getSciVersion()).c_str());
@@ -187,6 +189,8 @@
game_exit(_gamestate);
script_free_breakpoints(_gamestate);
+ ConfMan.flushToDisk();
+
delete _gamestate->_soundCmd;
delete _gamestate->_gui;
delete _gamestate->_event;
@@ -281,4 +285,21 @@
_mixer->pauseAll(pause);
}
+void SciEngine::syncSoundSettings() {
+ Engine::syncSoundSettings();
+
+#ifndef USE_OLD_MUSIC_FUNCTIONS
+ bool mute = false;
+ if (ConfMan.hasKey("mute"))
+ mute = ConfMan.getBool("mute");
+
+ int soundVolumeMusic = (mute ? 0 : ConfMan.getInt("music_volume"));
+
+ if (_gamestate && _gamestate->_soundCmd) {
+ int vol = (soundVolumeMusic + 1) * SoundCommandParser::kMaxSciVolume / Audio::Mixer::kMaxMixerVolume;
+ _gamestate->_soundCmd->setMasterVolume(vol);
+ }
+#endif
+}
+
} // End of namespace Sci
Modified: scummvm/trunk/engines/sci/sci.h
===================================================================
--- scummvm/trunk/engines/sci/sci.h 2010-01-12 00:18:40 UTC (rev 47260)
+++ scummvm/trunk/engines/sci/sci.h 2010-01-12 00:51:37 UTC (rev 47261)
@@ -122,6 +122,7 @@
Common::Error saveGameState(int slot, const char *desc);
bool canLoadGameStateCurrently();
bool canSaveGameStateCurrently();
+ void syncSoundSettings();
const char* getGameID() const;
int getResourceVersion() const;
Modified: scummvm/trunk/engines/sci/sound/music.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/music.cpp 2010-01-12 00:18:40 UTC (rev 47260)
+++ scummvm/trunk/engines/sci/sound/music.cpp 2010-01-12 00:51:37 UTC (rev 47261)
@@ -40,7 +40,7 @@
#define DISABLE_VOLUME_FADING
SciMusic::SciMusic(SciVersion soundVersion)
- : _soundVersion(soundVersion), _soundOn(true) {
+ : _soundVersion(soundVersion), _soundOn(true), _masterVolume(0) {
// Reserve some space in the playlist, to avoid expensive insertion
// operations
@@ -57,12 +57,6 @@
void SciMusic::init() {
// system init
_pMixer = g_system->getMixer();
- _pMixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt(
- "sfx_volume"));
- _pMixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType,
- ConfMan.getInt("speech_volume"));
- _pMixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType,
- ConfMan.getInt("music_volume"));
// SCI sound init
_dwTempo = 0;
@@ -469,15 +463,16 @@
}
uint16 SciMusic::soundGetMasterVolume() {
- return (_pMixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) + 8) * 0xF / Audio::Mixer::kMaxMixerVolume;
+ return _masterVolume;
}
void SciMusic::soundSetMasterVolume(uint16 vol) {
- vol = vol & 0xF; // 0..15
- vol = vol * Audio::Mixer::kMaxMixerVolume / 0xF;
- // "master volume" is music and SFX only, speech (audio resources) are supposed to be unaffected
- _pMixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, vol);
- _pMixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, vol);
+ _masterVolume = vol;
+
+ Common::StackLock lock(_mutex);
+
+ if (_pMidiDrv)
+ _pMidiDrv->setVolume(vol);
}
void SciMusic::printPlayList(Console *con) {
Modified: scummvm/trunk/engines/sci/sound/music.h
===================================================================
--- scummvm/trunk/engines/sci/sound/music.h 2010-01-12 00:18:40 UTC (rev 47260)
+++ scummvm/trunk/engines/sci/sound/music.h 2010-01-12 00:51:37 UTC (rev 47261)
@@ -226,6 +226,7 @@
MusicList _playList;
bool _soundOn;
byte _reverb;
+ byte _masterVolume;
};
} // End of namespace Sci
Modified: scummvm/trunk/engines/sci/sound/softseq/adlib.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/softseq/adlib.cpp 2010-01-12 00:18:40 UTC (rev 47260)
+++ scummvm/trunk/engines/sci/sound/softseq/adlib.cpp 2010-01-12 00:51:37 UTC (rev 47261)
@@ -229,7 +229,7 @@
MidiDriver_Emulated::open();
- _mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_mixerSoundHandle, this, -1, _mixer->kMaxChannelVolume, 0, DisposeAfterUse::NO);
+ _mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_mixerSoundHandle, this, -1, _mixer->kMaxChannelVolume, 0, DisposeAfterUse::NO);
return 0;
}
Modified: scummvm/trunk/engines/sci/sound/softseq/amiga.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/softseq/amiga.cpp 2010-01-12 00:18:40 UTC (rev 47260)
+++ scummvm/trunk/engines/sci/sound/softseq/amiga.cpp 2010-01-12 00:51:37 UTC (rev 47261)
@@ -541,7 +541,7 @@
MidiDriver_Emulated::open();
- _mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_mixerSoundHandle, this, -1, _mixer->kMaxChannelVolume, 0, DisposeAfterUse::NO);
+ _mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_mixerSoundHandle, this, -1, _mixer->kMaxChannelVolume, 0, DisposeAfterUse::NO);
return Common::kNoError;
}
Modified: scummvm/trunk/engines/sci/sound/softseq/pcjr.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/softseq/pcjr.cpp 2010-01-12 00:18:40 UTC (rev 47260)
+++ scummvm/trunk/engines/sci/sound/softseq/pcjr.cpp 2010-01-12 00:51:37 UTC (rev 47261)
@@ -219,7 +219,7 @@
MidiDriver_Emulated::open();
- _mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_mixerSoundHandle, this, -1, _mixer->kMaxChannelVolume, 0, DisposeAfterUse::NO);
+ _mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_mixerSoundHandle, this, -1, _mixer->kMaxChannelVolume, 0, DisposeAfterUse::NO);
return 0;
}
Modified: scummvm/trunk/engines/sci/sound/soundcmd.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/soundcmd.cpp 2010-01-12 00:18:40 UTC (rev 47260)
+++ scummvm/trunk/engines/sci/sound/soundcmd.cpp 2010-01-12 00:51:37 UTC (rev 47261)
@@ -29,6 +29,7 @@
#include "sci/sound/iterator/iterator.h" // for SongIteratorStatus
#endif
+#include "common/config-manager.h"
#include "sci/sound/music.h"
#include "sci/sound/soundcmd.h"
@@ -610,8 +611,13 @@
_acc = make_reg(0, _state->sfx_getVolume());
#else
debugC(2, kDebugLevelSound, "cmdMasterVolume: %d", value);
- if (_argc > 1) // the first parameter is the sound command
- _music->soundSetMasterVolume(obj.toSint16());
+ if (_argc > 1) { // the first parameter is the sound command
+ int vol = CLIP<int16>(obj.toSint16(), 0, kMaxSciVolume);
+ vol = vol * Audio::Mixer::kMaxMixerVolume / kMaxSciVolume;
+ ConfMan.setInt("music_volume", vol);
+ ConfMan.setInt("sfx_volume", vol);
+ g_engine->syncSoundSettings();
+ }
_acc = make_reg(0, _music->soundGetMasterVolume());
#endif
}
@@ -1090,4 +1096,10 @@
#endif
}
+void SoundCommandParser::setMasterVolume(int vol) {
+#ifndef USE_OLD_MUSIC_FUNCTIONS
+ _music->soundSetMasterVolume(vol);
+#endif
+}
+
} // End of namespace Sci
Modified: scummvm/trunk/engines/sci/sound/soundcmd.h
===================================================================
--- scummvm/trunk/engines/sci/sound/soundcmd.h 2010-01-12 00:18:40 UTC (rev 47260)
+++ scummvm/trunk/engines/sci/sound/soundcmd.h 2010-01-12 00:51:37 UTC (rev 47261)
@@ -49,6 +49,10 @@
SoundCommandParser(ResourceManager *resMan, SegManager *segMan, AudioPlayer *audio, SciVersion soundVersion);
~SoundCommandParser();
+ enum {
+ kMaxSciVolume = 15
+ };
+
#ifdef USE_OLD_MUSIC_FUNCTIONS
void updateSfxState(SfxState *newState) { _state = newState; }
#endif
@@ -59,6 +63,7 @@
void reconstructPlayList(int savegame_version);
void printPlayList(Console *con);
void resetDriver();
+ void setMasterVolume(int vol);
#ifndef USE_OLD_MUSIC_FUNCTIONS
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list