aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2016-06-09 23:38:13 +0200
committerStrangerke2016-06-09 23:38:13 +0200
commitc3311473a77e08e64ff5e77ecfb7b3d2c8505134 (patch)
treea37661d44f29b7c3d11db86c606ffd0dcba52c35
parent81d7bc6d0c695ae404f96a457ad79fe96f8674b5 (diff)
downloadscummvm-rg350-c3311473a77e08e64ff5e77ecfb7b3d2c8505134.tar.gz
scummvm-rg350-c3311473a77e08e64ff5e77ecfb7b3d2c8505134.tar.bz2
scummvm-rg350-c3311473a77e08e64ff5e77ecfb7b3d2c8505134.zip
GNAP: Consistently check the return value of find(resourceId)
-rw-r--r--engines/gnap/sound.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/engines/gnap/sound.cpp b/engines/gnap/sound.cpp
index 75cfb5555c..b09cc7cafe 100644
--- a/engines/gnap/sound.cpp
+++ b/engines/gnap/sound.cpp
@@ -26,8 +26,7 @@
namespace Gnap {
-SoundMan::SoundMan(GnapEngine *vm)
- : _vm(vm) {
+SoundMan::SoundMan(GnapEngine *vm) : _vm(vm) {
}
SoundMan::~SoundMan() {
@@ -49,11 +48,12 @@ void SoundMan::playSound(int resourceId, bool looping) {
void SoundMan::stopSound(int resourceId) {
const int index = find(resourceId);
- if (index >= 0) {
- _vm->_soundCache->release(_items[index]._resourceId);
- _vm->_mixer->stopHandle(_items[index]._handle);
- _items.remove_at(index);
- }
+ if (index < 0)
+ return;
+
+ _vm->_soundCache->release(_items[index]._resourceId);
+ _vm->_mixer->stopHandle(_items[index]._handle);
+ _items.remove_at(index);
}
void SoundMan::setSoundVolume(int resourceId, int volume) {
@@ -61,13 +61,19 @@ void SoundMan::setSoundVolume(int resourceId, int volume) {
return;
const int index = find(resourceId);
+ if (index < 0)
+ return;
+
int realVol = volume * 2.55;
_vm->_mixer->setChannelVolume(_items[index]._handle, realVol);
}
bool SoundMan::isSoundPlaying(int resourceId) {
const int index = find(resourceId);
- return index >= 0 && _vm->_mixer->isSoundHandleActive(_items[index]._handle);
+ if (index < 0)
+ return false;
+
+ return _vm->_mixer->isSoundHandleActive(_items[index]._handle);
}
void SoundMan::stopAll() {