aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMax Horn2005-03-22 18:29:02 +0000
committerMax Horn2005-03-22 18:29:02 +0000
commit61d0e3f02c5f75f5afa6ba843c876a7957ba7d63 (patch)
tree94ff2038d51d0d4baaa072329d0967c7c445b4c8 /sound
parenta2ac6c9796006b1eabe81cea86c8d6548f5a2b4a (diff)
downloadscummvm-rg350-61d0e3f02c5f75f5afa6ba843c876a7957ba7d63.tar.gz
scummvm-rg350-61d0e3f02c5f75f5afa6ba843c876a7957ba7d63.tar.bz2
scummvm-rg350-61d0e3f02c5f75f5afa6ba843c876a7957ba7d63.zip
Make sure SoundHandle's are inited
svn-id: r17194
Diffstat (limited to 'sound')
-rw-r--r--sound/mixer.cpp26
-rw-r--r--sound/mixer.h9
2 files changed, 21 insertions, 14 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index 6a6881d8a1..21c73d4b18 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -166,7 +166,7 @@ void SoundMixer::insertChannel(SoundHandle *handle, Channel *chan) {
}
_channels[index] = chan;
- chan->_handle = index + (_handleSeed * NUM_CHANNELS);
+ chan->_handle._val = index + (_handleSeed * NUM_CHANNELS);
_handleSeed++;
if (handle) {
*handle = chan->_handle;
@@ -288,8 +288,8 @@ void SoundMixer::stopHandle(SoundHandle handle) {
Common::StackLock lock(_mutex);
// Simply ignore stop requests for handles of sounds that already terminated
- const int index = handle % NUM_CHANNELS;
- if (!_channels[index] || _channels[index]->_handle != handle)
+ const int index = handle._val % NUM_CHANNELS;
+ if (!_channels[index] || _channels[index]->_handle._val != handle._val)
return;
delete _channels[index];
@@ -299,8 +299,8 @@ void SoundMixer::stopHandle(SoundHandle handle) {
void SoundMixer::setChannelVolume(SoundHandle handle, byte volume) {
Common::StackLock lock(_mutex);
- const int index = handle % NUM_CHANNELS;
- if (!_channels[index] || _channels[index]->_handle != handle)
+ const int index = handle._val % NUM_CHANNELS;
+ if (!_channels[index] || _channels[index]->_handle._val != handle._val)
return;
_channels[index]->setVolume(volume);
@@ -309,8 +309,8 @@ void SoundMixer::setChannelVolume(SoundHandle handle, byte volume) {
void SoundMixer::setChannelBalance(SoundHandle handle, int8 balance) {
Common::StackLock lock(_mutex);
- const int index = handle % NUM_CHANNELS;
- if (!_channels[index] || _channels[index]->_handle != handle)
+ const int index = handle._val % NUM_CHANNELS;
+ if (!_channels[index] || _channels[index]->_handle._val != handle._val)
return;
_channels[index]->setBalance(balance);
@@ -327,8 +327,8 @@ uint32 SoundMixer::getSoundElapsedTimeOfSoundID(int id) {
uint32 SoundMixer::getSoundElapsedTime(SoundHandle handle) {
Common::StackLock lock(_mutex);
- const int index = handle % NUM_CHANNELS;
- if (!_channels[index] || _channels[index]->_handle != handle)
+ const int index = handle._val % NUM_CHANNELS;
+ if (!_channels[index] || _channels[index]->_handle._val != handle._val)
return 0;
return _channels[index]->getElapsedTime();
@@ -352,8 +352,8 @@ void SoundMixer::pauseHandle(SoundHandle handle, bool paused) {
Common::StackLock lock(_mutex);
// Simply ignore pause/unpause requests for handles of sound that alreayd terminated
- const int index = handle % NUM_CHANNELS;
- if (!_channels[index] || _channels[index]->_handle != handle)
+ const int index = handle._val % NUM_CHANNELS;
+ if (!_channels[index] || _channels[index]->_handle._val != handle._val)
return;
_channels[index]->pause(paused);
@@ -368,8 +368,8 @@ bool SoundMixer::isSoundIDActive(int id) {
}
bool SoundMixer::isSoundHandleActive(SoundHandle handle) {
- const int index = handle % NUM_CHANNELS;
- return _channels[index] && _channels[index]->_handle == handle;
+ const int index = handle._val % NUM_CHANNELS;
+ return _channels[index] && _channels[index]->_handle._val == handle._val;
}
bool SoundMixer::hasActiveChannelOfType(SoundType type) {
diff --git a/sound/mixer.h b/sound/mixer.h
index 31ed62181a..48aea32e49 100644
--- a/sound/mixer.h
+++ b/sound/mixer.h
@@ -33,7 +33,14 @@ class Channel;
class File;
class OSystem;
-typedef uint32 SoundHandle;
+class SoundHandle {
+ friend class Channel;
+ friend class SoundMixer;
+ uint32 _val;
+public:
+ inline SoundHandle() : _val(0xFFFFFFFF) {}
+};
+
class SoundMixer {
public: