aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/base/sound
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-07-26 15:59:26 +0200
committerEinar Johan Trøan Sømåen2012-07-26 15:59:26 +0200
commitef11f9d0c53cbdd9d88a99143de6f43f34d7e24d (patch)
tree8dfaee0ba16e18a8e3772dd5afc9123d5c4e78d2 /engines/wintermute/base/sound
parent38507fa9895620639d8733dbb4e085dfb2282a33 (diff)
downloadscummvm-rg350-ef11f9d0c53cbdd9d88a99143de6f43f34d7e24d.tar.gz
scummvm-rg350-ef11f9d0c53cbdd9d88a99143de6f43f34d7e24d.tar.bz2
scummvm-rg350-ef11f9d0c53cbdd9d88a99143de6f43f34d7e24d.zip
WINTERMUTE: Run Astyle with add-braces to break one-line statements into easier-to-read-code.
Diffstat (limited to 'engines/wintermute/base/sound')
-rw-r--r--engines/wintermute/base/sound/base_sound.cpp113
-rw-r--r--engines/wintermute/base/sound/base_sound_manager.cpp19
2 files changed, 92 insertions, 40 deletions
diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp
index 8cc8c21948..9cd9e4cc75 100644
--- a/engines/wintermute/base/sound/base_sound.cpp
+++ b/engines/wintermute/base/sound/base_sound.cpp
@@ -57,7 +57,9 @@ BaseSound::BaseSound(BaseGame *inGame): BaseClass(inGame) {
//////////////////////////////////////////////////////////////////////////
BaseSound::~BaseSound() {
- if (_sound) _gameRef->_soundMgr->removeSound(_sound);
+ if (_sound) {
+ _gameRef->_soundMgr->removeSound(_sound);
+ }
_sound = NULL;
delete[] _soundFilename;
@@ -83,7 +85,9 @@ bool BaseSound::setSound(const char *filename, Audio::Mixer::SoundType type, boo
_soundStreamed = streamed;
return STATUS_OK;
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
}
@@ -91,22 +95,32 @@ bool BaseSound::setSound(const char *filename, Audio::Mixer::SoundType type, boo
bool BaseSound::setSoundSimple() {
_sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed);
if (_sound) {
- if (_soundPosition) _sound->setPosition(_soundPosition);
+ if (_soundPosition) {
+ _sound->setPosition(_soundPosition);
+ }
_sound->setLooping(_soundLooping);
_sound->setPrivateVolume(_soundPrivateVolume);
_sound->setLoopStart(_soundLoopStart);
_sound->_freezePaused = _soundFreezePaused;
- if (_soundPlaying) return _sound->resume();
- else return STATUS_OK;
- } else return STATUS_FAILED;
+ if (_soundPlaying) {
+ return _sound->resume();
+ } else {
+ return STATUS_OK;
+ }
+ } else {
+ return STATUS_FAILED;
+ }
}
//////////////////////////////////////////////////////////////////////////
uint32 BaseSound::getLength() {
- if (_sound) return _sound->getLength();
- else return 0;
+ if (_sound) {
+ return _sound->getLength();
+ } else {
+ return 0;
+ }
}
@@ -115,7 +129,9 @@ bool BaseSound::play(bool looping) {
if (_sound) {
_soundPaused = false;
return _sound->play(looping, _soundPosition);
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
}
@@ -124,7 +140,9 @@ bool BaseSound::stop() {
if (_sound) {
_soundPaused = false;
return _sound->stop();
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
}
@@ -132,9 +150,13 @@ bool BaseSound::stop() {
bool BaseSound::pause(bool freezePaused) {
if (_sound) {
_soundPaused = true;
- if (freezePaused) _sound->_freezePaused = true;
+ if (freezePaused) {
+ _sound->_freezePaused = true;
+ }
return _sound->pause();
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
}
@@ -143,7 +165,9 @@ bool BaseSound::resume() {
if (_sound && _soundPaused) {
_soundPaused = false;
return _sound->resume();
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
}
@@ -153,8 +177,9 @@ bool BaseSound::persist(BasePersistenceManager *persistMgr) {
_soundPlaying = _sound->isPlaying();
_soundLooping = _sound->_looping;
_soundPrivateVolume = _sound->_privateVolume;
- if (_soundPlaying)
+ if (_soundPlaying) {
_soundPosition = _sound->getPosition();
+ }
_soundLoopStart = _sound->_loopStart;
_soundFreezePaused = _sound->_freezePaused;
}
@@ -195,64 +220,81 @@ bool BaseSound::isPaused() {
//////////////////////////////////////////////////////////////////////////
bool BaseSound::setPositionTime(uint32 time) {
- if (!_sound) return STATUS_FAILED;
+ if (!_sound) {
+ return STATUS_FAILED;
+ }
_soundPosition = time;
bool ret = _sound->setPosition(_soundPosition);
- if (_sound->isPlaying())
+ if (_sound->isPlaying()) {
_soundPosition = 0;
+ }
return ret;
}
//////////////////////////////////////////////////////////////////////////
uint32 BaseSound::getPositionTime() {
- if (!_sound) return 0;
+ if (!_sound) {
+ return 0;
+ }
- if (!_sound->isPlaying())
+ if (!_sound->isPlaying()) {
return 0;
- else return _sound->getPosition();
+ } else {
+ return _sound->getPosition();
+ }
}
//////////////////////////////////////////////////////////////////////////
bool BaseSound::setVolumePercent(int percent) {
- if (!_sound)
+ if (!_sound) {
return STATUS_FAILED;
- else return _sound->setPrivateVolume(percent * 255 / 100);
+ } else {
+ return _sound->setPrivateVolume(percent * 255 / 100);
+ }
}
//////////////////////////////////////////////////////////////////////////
bool BaseSound::setVolume(int volume) {
- if (!_sound)
+ if (!_sound) {
return STATUS_FAILED;
- else return _sound->setPrivateVolume(volume);
+ } else {
+ return _sound->setPrivateVolume(volume);
+ }
}
//////////////////////////////////////////////////////////////////////////
bool BaseSound::setPrivateVolume(int volume) {
- if (!_sound)
+ if (!_sound) {
return STATUS_FAILED;
- else return _sound->_privateVolume = volume;
+ } else {
+ return _sound->_privateVolume = volume;
+ }
}
//////////////////////////////////////////////////////////////////////////
int BaseSound::getVolumePercent() {
- if (!_sound)
+ if (!_sound) {
return 0;
- else return _sound->_privateVolume * 100 / 255;
+ } else {
+ return _sound->_privateVolume * 100 / 255;
+ }
}
//////////////////////////////////////////////////////////////////////////
int BaseSound::getVolume() {
- if (!_sound)
+ if (!_sound) {
return 0;
- else return _sound->_privateVolume;
+ } else {
+ return _sound->_privateVolume;
+ }
}
//////////////////////////////////////////////////////////////////////////
bool BaseSound::setLoopStart(uint32 pos) {
- if (!_sound)
+ if (!_sound) {
return STATUS_FAILED;
- else {
+ } else {
_sound->setLoopStart(pos);
return STATUS_OK;
}
@@ -260,16 +302,19 @@ bool BaseSound::setLoopStart(uint32 pos) {
//////////////////////////////////////////////////////////////////////////
bool BaseSound::setPan(float pan) {
- if (_sound)
+ if (_sound) {
return _sound->setPan(pan);
- else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
}
//////////////////////////////////////////////////////////////////////////
bool BaseSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) {
- if (!_sound)
+ if (!_sound) {
return STATUS_OK;
+ }
if (type != _sFXType || param1 != _sFXParam1 || param2 != _sFXParam2 || param3 != _sFXParam3 || param4 != _sFXParam4) {
bool ret = _sound->applyFX(type, param1, param2, param3, param4);
diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp
index cebc3a3765..74aae59e3d 100644
--- a/engines/wintermute/base/sound/base_sound_manager.cpp
+++ b/engines/wintermute/base/sound/base_sound_manager.cpp
@@ -61,8 +61,9 @@ BaseSoundMgr::~BaseSoundMgr() {
//////////////////////////////////////////////////////////////////////////
bool BaseSoundMgr::cleanup() {
- for (uint32 i = 0; i < _sounds.size(); i++)
+ for (uint32 i = 0; i < _sounds.size(); i++) {
delete _sounds[i];
+ }
_sounds.clear();
#if 0
BASS_Free();
@@ -93,8 +94,9 @@ bool BaseSoundMgr::initialize() {
//////////////////////////////////////////////////////////////////////////
bool BaseSoundMgr::initLoop() {
- if (!_soundAvailable)
+ if (!_soundAvailable) {
return STATUS_OK;
+ }
#if 0
BASS_Update(500);
@@ -105,8 +107,9 @@ bool BaseSoundMgr::initLoop() {
//////////////////////////////////////////////////////////////////////////
BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) {
- if (!_soundAvailable)
+ if (!_soundAvailable) {
return NULL;
+ }
BaseSoundBuffer *sound;
@@ -123,7 +126,9 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::Soun
}
sound = new BaseSoundBuffer(_gameRef);
- if (!sound) return NULL;
+ if (!sound) {
+ return NULL;
+ }
sound->setStreaming(streamed);
sound->setType(type);
@@ -149,8 +154,9 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::Soun
//////////////////////////////////////////////////////////////////////////
bool BaseSoundMgr::addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type) {
- if (!sound)
+ if (!sound) {
return STATUS_FAILED;
+ }
// Make sure the master-volume is applied to the sound.
sound->updateVolume();
@@ -177,8 +183,9 @@ bool BaseSoundMgr::removeSound(BaseSoundBuffer *sound) {
//////////////////////////////////////////////////////////////////////////
bool BaseSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) {
- if (!_soundAvailable)
+ if (!_soundAvailable) {
return STATUS_OK;
+ }
switch (type) {
case Audio::Mixer::kSFXSoundType: