[Scummvm-git-logs] scummvm master -> 3bbaa456cdbfa89186f76af549c5a78fc834dade
aquadran
noreply at scummvm.org
Tue Sep 16 08:09:13 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
3bbaa456cd WINTERMUTE: Synced with original code
Commit: 3bbaa456cdbfa89186f76af549c5a78fc834dade
https://github.com/scummvm/scummvm/commit/3bbaa456cdbfa89186f76af549c5a78fc834dade
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2025-09-16T10:09:07+02:00
Commit Message:
WINTERMUTE: Synced with original code
Changed paths:
engines/wintermute/ad/ad_object.cpp
engines/wintermute/base/base_frame.cpp
engines/wintermute/base/base_game.cpp
engines/wintermute/base/base_object.cpp
engines/wintermute/base/sound/base_sound.cpp
engines/wintermute/base/sound/base_sound.h
engines/wintermute/base/sound/base_sound_buffer.cpp
engines/wintermute/base/sound/base_sound_buffer.h
engines/wintermute/base/sound/base_sound_manager.cpp
engines/wintermute/base/sound/base_sound_manager.h
engines/wintermute/dctypes.h
engines/wintermute/video/video_theora_player.cpp
diff --git a/engines/wintermute/ad/ad_object.cpp b/engines/wintermute/ad/ad_object.cpp
index 33a579d099f..ecd548b15f9 100644
--- a/engines/wintermute/ad/ad_object.cpp
+++ b/engines/wintermute/ad/ad_object.cpp
@@ -911,7 +911,7 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const
// load sound and set duration appropriately
if (sound) {
BaseSound *snd = new BaseSound(_game);
- if (snd && DID_SUCCEED(snd->setSound(sound, Audio::Mixer::kSpeechSoundType, true))) {
+ if (snd && DID_SUCCEED(snd->setSound(sound, TSoundType::SOUND_SPEECH, true))) {
_sentence->setSound(snd);
if (_sentence->_duration <= 0) {
uint32 length = snd->getLength();
diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp
index 0eee160ead3..0f63ce1a492 100644
--- a/engines/wintermute/base/base_frame.cpp
+++ b/engines/wintermute/base/base_frame.cpp
@@ -261,7 +261,7 @@ bool BaseFrame::loadBuffer(char *buffer, int lifeTime, bool keepLoaded) {
SAFE_DELETE(_sound);
}
_sound = new BaseSound(_game);
- if (!_sound || DID_FAIL(_sound->setSound(params, Audio::Mixer::kSFXSoundType, false))) {
+ if (!_sound || DID_FAIL(_sound->setSound(params, TSoundType::SOUND_SFX, false))) {
if (BaseEngine::instance().getSoundMgr()->_soundAvailable) {
_game->LOG(0, "Error loading sound '%s'.", params);
}
@@ -456,7 +456,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac
if (!val->isNULL()) {
_sound = new BaseSound(_game);
- if (!_sound || DID_FAIL(_sound->setSound(val->getString(), Audio::Mixer::kSFXSoundType, false))) {
+ if (!_sound || DID_FAIL(_sound->setSound(val->getString(), TSoundType::SOUND_SFX, false))) {
stack->pushBool(false);
SAFE_DELETE(_sound);
} else {
diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp
index 371a3ca654d..984ff0da619 100644
--- a/engines/wintermute/base/base_game.cpp
+++ b/engines/wintermute/base/base_game.cpp
@@ -1582,7 +1582,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
const char *filename = stack->pop()->getString();
BaseSound *sound = new BaseSound(_game);
- if (sound && DID_SUCCEED(sound->setSound(filename, Audio::Mixer::kMusicSoundType, true))) {
+ if (sound && DID_SUCCEED(sound->setSound(filename, TSoundType::SOUND_MUSIC, true))) {
length = sound->getLength();
SAFE_DELETE(sound);
}
@@ -2131,7 +2131,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetGlobalSFXVolume") == 0) {
stack->correctParams(1);
- _game->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)stack->pop()->getInt());
+ _game->_soundMgr->setVolumePercent(TSoundType::SOUND_SFX, (byte)stack->pop()->getInt());
stack->pushNULL();
return STATUS_OK;
}
@@ -2141,7 +2141,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetGlobalSpeechVolume") == 0) {
stack->correctParams(1);
- _game->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)stack->pop()->getInt());
+ _game->_soundMgr->setVolumePercent(TSoundType::SOUND_SPEECH, (byte)stack->pop()->getInt());
stack->pushNULL();
return STATUS_OK;
}
@@ -2151,7 +2151,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetGlobalMusicVolume") == 0) {
stack->correctParams(1);
- _game->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)stack->pop()->getInt());
+ _game->_soundMgr->setVolumePercent(TSoundType::SOUND_MUSIC, (byte)stack->pop()->getInt());
stack->pushNULL();
return STATUS_OK;
}
@@ -2171,7 +2171,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetGlobalSFXVolume") == 0) {
stack->correctParams(0);
- stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType));
+ stack->pushInt(_soundMgr->getVolumePercent(TSoundType::SOUND_SFX));
return STATUS_OK;
}
@@ -2180,7 +2180,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetGlobalSpeechVolume") == 0) {
stack->correctParams(0);
- stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType));
+ stack->pushInt(_soundMgr->getVolumePercent(TSoundType::SOUND_SPEECH));
return STATUS_OK;
}
@@ -2189,7 +2189,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetGlobalMusicVolume") == 0) {
stack->correctParams(0);
- stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType));
+ stack->pushInt(_soundMgr->getVolumePercent(TSoundType::SOUND_MUSIC));
return STATUS_OK;
}
@@ -2936,8 +2936,8 @@ ScValue *BaseGame::scGetProperty(const char *name) {
// SFXVolume
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SFXVolume") == 0) {
- _game->LOG(0, "**Warning** The SFXVolume attribute is obsolete");
- _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType));
+ //_game->LOG(0, "**Warning** The SFXVolume attribute is obsolete");
+ _scValue->setInt(_soundMgr->getVolumePercent(TSoundType::SOUND_SFX));
return _scValue;
}
@@ -2945,8 +2945,8 @@ ScValue *BaseGame::scGetProperty(const char *name) {
// SpeechVolume
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SpeechVolume") == 0) {
- _game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete");
- _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType));
+ //_game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete");
+ _scValue->setInt(_soundMgr->getVolumePercent(TSoundType::SOUND_SPEECH));
return _scValue;
}
@@ -2954,8 +2954,8 @@ ScValue *BaseGame::scGetProperty(const char *name) {
// MusicVolume
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "MusicVolume") == 0) {
- _game->LOG(0, "**Warning** The MusicVolume attribute is obsolete");
- _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType));
+ //_game->LOG(0, "**Warning** The MusicVolume attribute is obsolete");
+ _scValue->setInt(_soundMgr->getVolumePercent(TSoundType::SOUND_MUSIC));
return _scValue;
}
@@ -2963,7 +2963,7 @@ ScValue *BaseGame::scGetProperty(const char *name) {
// MasterVolume
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "MasterVolume") == 0) {
- _game->LOG(0, "**Warning** The MasterVolume attribute is obsolete");
+ //_game->LOG(0, "**Warning** The MasterVolume attribute is obsolete");
_scValue->setInt(_soundMgr->getMasterVolumePercent());
return _scValue;
}
@@ -3485,8 +3485,8 @@ bool BaseGame::scSetProperty(const char *name, ScValue *value) {
// SFXVolume
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SFXVolume") == 0) {
- _game->LOG(0, "**Warning** The SFXVolume attribute is obsolete");
- _game->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)value->getInt());
+ //_game->LOG(0, "**Warning** The SFXVolume attribute is obsolete");
+ _game->_soundMgr->setVolumePercent(TSoundType::SOUND_SFX, (byte)value->getInt());
return STATUS_OK;
}
@@ -3494,8 +3494,8 @@ bool BaseGame::scSetProperty(const char *name, ScValue *value) {
// SpeechVolume
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SpeechVolume") == 0) {
- _game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete");
- _game->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)value->getInt());
+ //_game->LOG(0, "**Warning** The SpeechVolume attribute is obsolete");
+ _game->_soundMgr->setVolumePercent(TSoundType::SOUND_SPEECH, (byte)value->getInt());
return STATUS_OK;
}
@@ -3503,8 +3503,8 @@ bool BaseGame::scSetProperty(const char *name, ScValue *value) {
// MusicVolume
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "MusicVolume") == 0) {
- _game->LOG(0, "**Warning** The MusicVolume attribute is obsolete");
- _game->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)value->getInt());
+ //_game->LOG(0, "**Warning** The MusicVolume attribute is obsolete");
+ _game->_soundMgr->setVolumePercent(TSoundType::SOUND_MUSIC, (byte)value->getInt());
return STATUS_OK;
}
@@ -3512,7 +3512,7 @@ bool BaseGame::scSetProperty(const char *name, ScValue *value) {
// MasterVolume
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "MasterVolume") == 0) {
- _game->LOG(0, "**Warning** The MasterVolume attribute is obsolete");
+ //_game->LOG(0, "**Warning** The MasterVolume attribute is obsolete");
_game->_soundMgr->setMasterVolumePercent((byte)value->getInt());
return STATUS_OK;
}
@@ -4431,7 +4431,7 @@ bool BaseGame::playMusic(int channel, const char *filename, bool looping, uint32
SAFE_DELETE(_music[channel]);
_music[channel] = new BaseSound(_game);
- if (_music[channel] && DID_SUCCEED(_music[channel]->setSound(filename, Audio::Mixer::kMusicSoundType, true))) {
+ if (_music[channel] && DID_SUCCEED(_music[channel]->setSound(filename, TSoundType::SOUND_MUSIC, true))) {
if (_musicStartTime[channel]) {
_music[channel]->setPositionTime(_musicStartTime[channel]);
_musicStartTime[channel] = 0;
diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp
index 3c03dc740b4..ccde9701762 100644
--- a/engines/wintermute/base/base_object.cpp
+++ b/engines/wintermute/base/base_object.cpp
@@ -1235,7 +1235,7 @@ bool BaseObject::playSFX(const char *filename, bool looping, bool playNow, const
SAFE_DELETE(_sFX);
_sFX = new BaseSound(_game);
- if (_sFX && DID_SUCCEED(_sFX->setSound(filename, Audio::Mixer::kSFXSoundType, true))) {
+ if (_sFX && DID_SUCCEED(_sFX->setSound(filename, TSoundType::SOUND_SFX, true))) {
_sFX->setVolumePercent(_sFXVolume);
if (_sFXStart) {
_sFX->setPositionTime(_sFXStart);
diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp
index b3bae382afb..5969e9dd5b9 100644
--- a/engines/wintermute/base/sound/base_sound.cpp
+++ b/engines/wintermute/base/sound/base_sound.cpp
@@ -40,7 +40,7 @@ BaseSound::BaseSound(BaseGame *inGame) : BaseClass(inGame) {
_sound = nullptr;
_soundFilename = nullptr;
- _soundType = Audio::Mixer::kSFXSoundType;
+ _soundType = SOUND_SFX;
_soundStreamed = false;
_soundLooping = false;
_soundPlaying = false;
@@ -65,7 +65,7 @@ BaseSound::~BaseSound() {
}
//////////////////////////////////////////////////////////////////////////
-bool BaseSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) {
+bool BaseSound::setSound(const char *filename, TSoundType type, bool streamed) {
if (_sound) {
_game->_soundMgr->removeSound(_sound);
_sound = nullptr;
@@ -268,24 +268,6 @@ bool BaseSound::setLoopStart(uint32 pos) {
}
}
-//////////////////////////////////////////////////////////////////////////
-int BaseSound::getVolumePercent() {
- if (!_sound) {
- return 0;
- } else {
- return _sound->getPrivateVolume() * 100 / 255;
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool BaseSound::setVolumePercent(int percent) {
- if (!_sound) {
- return STATUS_FAILED;
- } else {
- return _sound->setPrivateVolume(percent * 255 / 100);
- }
-}
-
//////////////////////////////////////////////////////////////////////////
bool BaseSound::setPan(float pan) {
if (_sound) {
@@ -315,4 +297,23 @@ bool BaseSound::applyFX(TSFXType type, float param1, float param2, float param3,
return STATUS_OK;
}
+//////////////////////////////////////////////////////////////////////////
+int BaseSound::getVolumePercent() {
+ if (!_sound) {
+ return 0;
+ } else {
+ return _sound->getPrivateVolume() * 100 / 255;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////
+bool BaseSound::setVolumePercent(int percent) {
+ if (!_sound) {
+ return STATUS_FAILED;
+ } else {
+ return _sound->setPrivateVolume(percent * 255 / 100);
+ }
+}
+
+
} // End of namespace Wintermute
diff --git a/engines/wintermute/base/sound/base_sound.h b/engines/wintermute/base/sound/base_sound.h
index cc60e190ea7..1609dd70fd4 100644
--- a/engines/wintermute/base/sound/base_sound.h
+++ b/engines/wintermute/base/sound/base_sound.h
@@ -63,10 +63,10 @@ public:
bool play(bool looping = false);
uint32 getLength();
bool _soundStreamed;
- Audio::Mixer::SoundType _soundType;
+ TSoundType _soundType;
char *_soundFilename;
bool setSoundSimple();
- bool setSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false);
+ bool setSound(const char *filename, TSoundType type = SOUND_SFX, bool streamed = false);
BaseSound(BaseGame *inGame);
~BaseSound() override;
diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp
index 50acfad0ee3..ec001172f4f 100644
--- a/engines/wintermute/base/sound/base_sound_buffer.cpp
+++ b/engines/wintermute/base/sound/base_sound_buffer.cpp
@@ -29,6 +29,7 @@
#include "engines/wintermute/base/sound/base_sound_manager.h"
#include "engines/wintermute/base/sound/base_sound_buffer.h"
#include "engines/wintermute/base/base_file_manager.h"
+#include "engines/wintermute/utils/utils.h"
#include "engines/wintermute/wintermute.h"
#include "engines/wintermute/dcgf.h"
@@ -54,10 +55,9 @@ namespace Wintermute {
BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame) : BaseClass(inGame) {
_stream = nullptr;
_handle = nullptr;
-// _sync = nullptr;
_streamed = false;
- _filename = "";
+ _filename = nullptr;
_privateVolume = 255;
_volume = 255;
_pan = 0;
@@ -66,7 +66,7 @@ BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame) : BaseClass(inGame) {
_loopStart = 0;
_startPos = 0;
- _type = Audio::Mixer::kSFXSoundType;
+ _type = SOUND_SFX;
_freezePaused = false;
}
@@ -80,7 +80,9 @@ BaseSoundBuffer::~BaseSoundBuffer() {
g_system->getMixer()->stopHandle(*_handle);
SAFE_DELETE(_handle);
}
+
SAFE_DELETE(_stream);
+ SAFE_DELETE_ARRAY(_filename);
}
@@ -91,13 +93,17 @@ void BaseSoundBuffer::setStreaming(bool streamed, uint32 numBlocks, uint32 block
//////////////////////////////////////////////////////////////////////////
-bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceReload) {
- debugC(kWintermuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename.c_str(), forceReload);
+bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) {
+ if (_handle) {
+ g_system->getMixer()->stopHandle(*_handle);
+ SAFE_DELETE(_handle);
+ }
+ SAFE_DELETE(_stream);
// Load a file, but avoid having the File-manager handle the disposal of it.
- Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(filename, true, false);
+ Common::SeekableReadStream *file = _game->_fileManager->openFile(filename, true, false);
if (!file) {
- _game->LOG(0, "Error opening sound file '%s'", filename.c_str());
+ _game->LOG(0, "Error opening sound file '%s'", filename);
return STATUS_FAILED;
}
Common::String strFilename(filename);
@@ -106,7 +112,7 @@ bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceRel
#ifdef USE_VORBIS
_stream = Audio::makeVorbisStream(file, DisposeAfterUse::YES);
#else
- error("BSoundBuffer::LoadFromFile - Ogg Vorbis not supported by this version of ScummVM (please report as this shouldn't trigger)");
+ error("BSoundBuffer::loadFromFile - Ogg Vorbis not supported by this version of ScummVM (please report as this shouldn't trigger)");
#endif
} else if (strFilename.hasSuffix(".wav")) {
int waveSize, waveRate;
@@ -119,16 +125,18 @@ bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceRel
file = new Common::SeekableSubReadStream(file, file->pos(), waveSize + file->pos(), DisposeAfterUse::YES);
_stream = Audio::makeRawStream(file, waveRate, waveFlags, DisposeAfterUse::YES);
} else {
- error("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename.c_str(), waveType);
+ error("BSoundBuffer::loadFromFile - WAVE not supported yet for %s with type %d", filename, waveType);
}
}
} else {
- error("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename.c_str());
+ error("BSoundBuffer::loadFromFile - Unknown filetype for %s", filename);
}
if (!_stream) {
+ _game->LOG(0, "BSoundBuffer::koadFromFile - Error while loading '%s'", filename);
return STATUS_FAILED;
}
- _filename = filename;
+
+ BaseUtils::setString(&_filename, filename);
return STATUS_OK;
}
@@ -145,16 +153,24 @@ bool BaseSoundBuffer::play(bool looping, uint32 startSample) {
if (_stream) {
_stream->seek(startSample);
_handle = new Audio::SoundHandle;
+ Audio::Mixer::SoundType type = Audio::Mixer::SoundType::kPlainSoundType;
+ if (_type == TSoundType::SOUND_SFX) {
+ type = Audio::Mixer::SoundType::kSFXSoundType;
+ } else if (_type == TSoundType::SOUND_MUSIC) {
+ type = Audio::Mixer::SoundType::kMusicSoundType;
+ } else if (_type == TSoundType::SOUND_SPEECH) {
+ type = Audio::Mixer::SoundType::kSpeechSoundType;
+ }
if (_looping) {
if (_loopStart != 0) {
Audio::AudioStream *loopStream = new Audio::SubLoopingAudioStream(_stream, 0, Audio::Timestamp(_loopStart, _stream->getRate()), _stream->getLength(), DisposeAfterUse::NO);
- g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, _pan, DisposeAfterUse::YES);
+ g_system->getMixer()->playStream(type, _handle, loopStream, -1, _volume, _pan, DisposeAfterUse::YES);
} else {
Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO);
- g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, _pan, DisposeAfterUse::YES);
+ g_system->getMixer()->playStream(type, _handle, loopStream, -1, _volume, _pan, DisposeAfterUse::YES);
}
} else {
- g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, _pan, DisposeAfterUse::NO);
+ g_system->getMixer()->playStream(type, _handle, _stream, -1, _volume, _pan, DisposeAfterUse::NO);
}
}
@@ -163,11 +179,12 @@ bool BaseSoundBuffer::play(bool looping, uint32 startSample) {
//////////////////////////////////////////////////////////////////////////
void BaseSoundBuffer::setLooping(bool looping) {
+ _looping = looping;
+
if (isPlaying()) {
// This warning is here, to see if this is ever the case.
warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); // TODO
}
- _looping = looping;
}
//////////////////////////////////////////////////////////////////////////
@@ -213,15 +230,10 @@ uint32 BaseSoundBuffer::getLength() {
//////////////////////////////////////////////////////////////////////////
-void BaseSoundBuffer::setType(Audio::Mixer::SoundType type) {
+void BaseSoundBuffer::setType(TSoundType type) {
_type = type;
}
-//////////////////////////////////////////////////////////////////////////
-void BaseSoundBuffer::updateVolume() {
- setVolume(_privateVolume);
-}
-
//////////////////////////////////////////////////////////////////////////
bool BaseSoundBuffer::setVolume(int volume) {
_volume = volume * _game->_soundMgr->getMasterVolume() / 255;
@@ -276,6 +288,7 @@ bool BaseSoundBuffer::setPosition(uint32 pos) {
//////////////////////////////////////////////////////////////////////////
bool BaseSoundBuffer::setLoopStart(uint32 pos) {
_loopStart = pos;
+
return STATUS_OK;
}
@@ -308,10 +321,6 @@ bool BaseSoundBuffer::applyFX(TSFXType type, float param1, float param2, float p
return STATUS_OK;
}
-int32 BaseSoundBuffer::getPrivateVolume() const {
- return _privateVolume;
-}
-
bool BaseSoundBuffer::isLooping() const {
return _looping;
}
@@ -324,8 +333,16 @@ void BaseSoundBuffer::setFreezePaused(bool freezePaused) {
_freezePaused = freezePaused;
}
-Audio::Mixer::SoundType BaseSoundBuffer::getType() const {
+TSoundType BaseSoundBuffer::getType() const {
return _type;
}
+int32 BaseSoundBuffer::getPrivateVolume() const {
+ return _privateVolume;
+}
+
+void BaseSoundBuffer::updateVolume() {
+ setVolume(_privateVolume);
+}
+
} // End of namespace Wintermute
diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h
index 53a5469598f..8a8ac586100 100644
--- a/engines/wintermute/base/sound/base_sound_buffer.h
+++ b/engines/wintermute/base/sound/base_sound_buffer.h
@@ -68,28 +68,28 @@ public:
bool setVolume(int colume);
void updateVolume();
- void setType(Audio::Mixer::SoundType type);
- Audio::Mixer::SoundType getType() const;
+ void setType(TSoundType type);
+ TSoundType getType() const;
- bool loadFromFile(const Common::String &filename, bool forceReload = false);
+ bool loadFromFile(const char *filename, bool forceReload = false);
void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0);
bool applyFX(TSFXType type, float param1, float param2, float param3, float param4);
int32 getPrivateVolume() const;
void setFreezePaused(bool freezePaused);
bool isFreezePaused() const;
bool isLooping() const;
- //HSTREAM _stream;
- //HSYNC _sync;
- Audio::Mixer::SoundType _type;
- Audio::SeekableAudioStream *_stream;
- Audio::SoundHandle *_handle;
bool _freezePaused;
uint32 _loopStart;
+ TSoundType _type;
bool _looping;
- Common::String _filename;
+ char *_filename;
bool _streamed;
int32 _privateVolume;
+
+ Audio::SeekableAudioStream *_stream;
+ Audio::SoundHandle *_handle;
+
int32 _volume;
uint32 _startPos;
int8 _pan;
diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp
index 3cb5351ce6e..035ddd2ec22 100644
--- a/engines/wintermute/base/sound/base_sound_manager.cpp
+++ b/engines/wintermute/base/sound/base_sound_manager.cpp
@@ -102,12 +102,12 @@ bool BaseSoundMgr::initLoop() {
}
//////////////////////////////////////////////////////////////////////////
-BaseSoundBuffer *BaseSoundMgr::addSound(const Common::String &filename, Audio::Mixer::SoundType type, bool streamed) {
+BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, TSoundType type, bool streamed) {
if (!_soundAvailable) {
return nullptr;
}
- if (filename.empty()) {
+ if (!filename || filename[0] == '\0') {
// At least one game, Bickadoodle, calls playSound with an empty filename, see #6594
BaseEngine::LOG(0, "addSound called with empty filename");
}
@@ -121,7 +121,7 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const Common::String &filename, Audio::M
Common::String oggFilename = useFilename;
oggFilename.erase(oggFilename.size() - 4);
oggFilename = oggFilename + ".ogg";
- if (BaseFileManager::getEngineInstance()->hasFile(oggFilename)) {
+ if (_game->_fileManager->hasFile(oggFilename)) {
useFilename = oggFilename;
}
}
@@ -135,7 +135,7 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const Common::String &filename, Audio::M
sound->setType(type);
- bool res = sound->loadFromFile(useFilename);
+ bool res = sound->loadFromFile(useFilename.c_str());
if (DID_FAIL(res)) {
_game->LOG(res, "Error loading sound '%s'", useFilename.c_str());
delete sound;
@@ -152,7 +152,7 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const Common::String &filename, Audio::M
}
//////////////////////////////////////////////////////////////////////////
-bool BaseSoundMgr::addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type) {
+bool BaseSoundMgr::addSound(BaseSoundBuffer *sound, TSoundType type) {
if (!sound) {
return STATUS_FAILED;
}
@@ -181,47 +181,47 @@ bool BaseSoundMgr::removeSound(BaseSoundBuffer *sound) {
//////////////////////////////////////////////////////////////////////////
-bool BaseSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) {
+bool BaseSoundMgr::setVolume(TSoundType type, int volume) {
if (!_soundAvailable) {
return STATUS_OK;
}
switch (type) {
- case Audio::Mixer::kSFXSoundType:
+ case SOUND_SFX:
ConfMan.setInt("sfx_volume", volume);
break;
- case Audio::Mixer::kSpeechSoundType:
+ case SOUND_SPEECH:
ConfMan.setInt("speech_volume", volume);
break;
- case Audio::Mixer::kMusicSoundType:
+ case SOUND_MUSIC:
ConfMan.setInt("music_volume", volume);
break;
- case Audio::Mixer::kPlainSoundType:
- error("Plain sound type shouldn't be used in WME");
- break;
default:
break;
}
+
g_engine->syncSoundSettings();
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
-bool BaseSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) {
+bool BaseSoundMgr::setVolumePercent(TSoundType type, byte percent) {
return setVolume(type, percent * 255 / 100);
}
//////////////////////////////////////////////////////////////////////////
-byte BaseSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) {
+byte BaseSoundMgr::getVolumePercent(TSoundType type) {
int volume = 0;
switch (type) {
- case Audio::Mixer::kSFXSoundType:
- case Audio::Mixer::kSpeechSoundType:
- case Audio::Mixer::kMusicSoundType:
- volume = g_system->getMixer()->getVolumeForSoundType(type);
+ case SOUND_SFX:
+ volume = g_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kSFXSoundType);
+ case SOUND_SPEECH:
+ volume = g_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kSpeechSoundType);
+ case SOUND_MUSIC:
+ volume = g_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kMusicSoundType);
break;
default:
break;
@@ -231,20 +231,6 @@ byte BaseSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) {
}
-//////////////////////////////////////////////////////////////////////////
-bool BaseSoundMgr::setMasterVolume(byte value) {
- // This function intentionally doesn't touch _volumeMasterPercent,
- // as that variable keeps track of what the game actually wanted,
- // and this gives a close approximation, while letting the game
- // be none the wiser about round-off-errors. This function should thus
- // ONLY be called by setMasterVolumePercent.
- _volumeMaster = value;
- for (int32 i = 0; i < _sounds.getSize(); i++) {
- _sounds[i]->updateVolume();
- }
- return STATUS_OK;
-}
-
//////////////////////////////////////////////////////////////////////////
bool BaseSoundMgr::setMasterVolumePercent(byte percent) {
_volumeMasterPercent = percent;
@@ -258,17 +244,13 @@ byte BaseSoundMgr::getMasterVolumePercent() {
return _volumeMasterPercent;
}
-//////////////////////////////////////////////////////////////////////////
-byte BaseSoundMgr::getMasterVolume() {
- return (byte)_volumeMaster;
-}
//////////////////////////////////////////////////////////////////////////
bool BaseSoundMgr::pauseAll(bool includingMusic) {
for (int32 i = 0; i < _sounds.getSize(); i++) {
- if (_sounds[i]->isPlaying() && (_sounds[i]->getType() != Audio::Mixer::kMusicSoundType || includingMusic)) {
+ if (_sounds[i]->isPlaying() && (_sounds[i]->getType() != SOUND_MUSIC || includingMusic)) {
_sounds[i]->pause();
_sounds[i]->setFreezePaused(true);
}
@@ -321,4 +303,23 @@ float BaseSoundMgr::posToPan(int x, int y) {
return minPan + relPos * (maxPan - minPan);
}
+//////////////////////////////////////////////////////////////////////////
+bool BaseSoundMgr::setMasterVolume(byte value) {
+ // This function intentionally doesn't touch _volumeMasterPercent,
+ // as that variable keeps track of what the game actually wanted,
+ // and this gives a close approximation, while letting the game
+ // be none the wiser about round-off-errors. This function should thus
+ // ONLY be called by setMasterVolumePercent.
+ _volumeMaster = value;
+ for (int32 i = 0; i < _sounds.getSize(); i++) {
+ _sounds[i]->updateVolume();
+ }
+ return STATUS_OK;
+}
+
+//////////////////////////////////////////////////////////////////////////
+byte BaseSoundMgr::getMasterVolume() {
+ return (byte)_volumeMaster;
+}
+
} // End of namespace Wintermute
diff --git a/engines/wintermute/base/sound/base_sound_manager.h b/engines/wintermute/base/sound/base_sound_manager.h
index 7519f14a52c..e57b719b032 100644
--- a/engines/wintermute/base/sound/base_sound_manager.h
+++ b/engines/wintermute/base/sound/base_sound_manager.h
@@ -45,13 +45,13 @@ public:
byte getMasterVolumePercent();
byte getMasterVolume();
bool setMasterVolumePercent(byte percent);
- byte getVolumePercent(Audio::Mixer::SoundType type);
- bool setVolumePercent(Audio::Mixer::SoundType type, byte percent);
- bool setVolume(Audio::Mixer::SoundType type, int volume);
+ byte getVolumePercent(TSoundType type);
+ bool setVolumePercent(TSoundType type, byte percent);
+ bool setVolume(TSoundType type, int volume);
int32 _volumeMaster;
bool removeSound(BaseSoundBuffer *sound);
- BaseSoundBuffer *addSound(const Common::String &filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false);
- bool addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType);
+ BaseSoundBuffer *addSound(const char *filename, TSoundType type = SOUND_SFX, bool streamed = false);
+ bool addSound(BaseSoundBuffer *sound, TSoundType type = SOUND_SFX);
bool initLoop();
bool initialize();
bool _soundAvailable;
diff --git a/engines/wintermute/dctypes.h b/engines/wintermute/dctypes.h
index f71a1d23126..9bedc05e24b 100644
--- a/engines/wintermute/dctypes.h
+++ b/engines/wintermute/dctypes.h
@@ -130,6 +130,12 @@ enum TDynamicConstructor {
};
+typedef enum {
+ SOUND_SFX,
+ SOUND_MUSIC,
+ SOUND_SPEECH
+} TSoundType;
+
enum TVideoMode {
VIDEO_WINDOW,
VIDEO_FULLSCREEN,
diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp
index 57479a4c243..09dbfecc3e0 100644
--- a/engines/wintermute/video/video_theora_player.cpp
+++ b/engines/wintermute/video/video_theora_player.cpp
@@ -187,7 +187,7 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame,
forceZoom = 100.0f;
}
if (volume < 0) {
- _volume = _game->_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType);
+ _volume = _game->_soundMgr->getVolumePercent(TSoundType::SOUND_SFX);
} else {
_volume = volume;
}
More information about the Scummvm-git-logs
mailing list