[Scummvm-cvs-logs] scummvm master -> c3311473a77e08e64ff5e77ecfb7b3d2c8505134
Strangerke
Strangerke at scummvm.org
Thu Jun 9 23:47:43 CEST 2016
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:
c3311473a7 GNAP: Consistently check the return value of find(resourceId)
Commit: c3311473a77e08e64ff5e77ecfb7b3d2c8505134
https://github.com/scummvm/scummvm/commit/c3311473a77e08e64ff5e77ecfb7b3d2c8505134
Author: Strangerke (strangerke at scummvm.org)
Date: 2016-06-09T23:38:13+02:00
Commit Message:
GNAP: Consistently check the return value of find(resourceId)
Changed paths:
engines/gnap/sound.cpp
diff --git a/engines/gnap/sound.cpp b/engines/gnap/sound.cpp
index 75cfb55..b09cc7c 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() {
More information about the Scummvm-git-logs
mailing list