diff options
author | Paweł Kołodziejski | 2003-08-30 18:12:49 +0000 |
---|---|---|
committer | Paweł Kołodziejski | 2003-08-30 18:12:49 +0000 |
commit | 9c05d44d00ff31ffb9b535da1536e38ab28d150a (patch) | |
tree | fbe424c8ae533fc59ae24ba01ff4bdaf33d931cc | |
parent | a2dad74da12f4d4bd63f79e86d0226c07e16dcc9 (diff) | |
download | scummvm-rg350-9c05d44d00ff31ffb9b535da1536e38ab28d150a.tar.gz scummvm-rg350-9c05d44d00ff31ffb9b535da1536e38ab28d150a.tar.bz2 scummvm-rg350-9c05d44d00ff31ffb9b535da1536e38ab28d150a.zip |
added func isChannelActive for mixer, and fixed handling numbers of channel 0
svn-id: r9924
-rw-r--r-- | sound/mixer.cpp | 29 | ||||
-rw-r--r-- | sound/mixer.h | 2 |
2 files changed, 27 insertions, 4 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp index 8d452b4431..6d36694933 100644 --- a/sound/mixer.cpp +++ b/sound/mixer.cpp @@ -159,6 +159,9 @@ void SoundMixer::appendStream(int index, void *sound, uint32 size) { void SoundMixer::endStream(int index) { StackLock lock(_mutex); + if (index == -1) + return; + ChannelStream *chan; #if !defined(_WIN32_WCE) && !defined(__PALM_OS__) chan = dynamic_cast<ChannelStream *>(_channels[index]); @@ -188,7 +191,7 @@ int SoundMixer::insertChannel(PlayingSoundHandle *handle, Channel *chan) { _channels[index] = chan; if (handle) - *handle = index + 1; + *handle = index; return index; } @@ -297,10 +300,11 @@ void SoundMixer::stopHandle(PlayingSoundHandle handle) { StackLock lock(_mutex); // Simply ignore stop requests for handles of sounds that already terminated - if (handle == 0) + if (handle == -1) return; - int index = handle - 1; + int index = handle; + if ((index < 0) || (index >= NUM_CHANNELS)) { warning("soundMixer::stopHandle has invalid index %d", index); return; @@ -310,6 +314,23 @@ void SoundMixer::stopHandle(PlayingSoundHandle handle) { _channels[index]->destroy(); } +bool SoundMixer::isChannelActive(PlayingSoundHandle handle) { + StackLock lock(_mutex); + + if (handle == -1) + return false; + + int index = handle; + if ((index < 0) || (index >= NUM_CHANNELS)) { + warning("soundMixer::isChannelActive has invalid index %d", index); + return false; + } + + if (_channels[index]) + return _channels[index] != NULL; + else + return false; +} void SoundMixer::pause(bool paused) { _paused = paused; @@ -367,7 +388,7 @@ Channel::~Channel() { delete _converter; delete _input; if (_handle) - *_handle = 0; + *_handle = -1; } void Channel::destroy() { diff --git a/sound/mixer.h b/sound/mixer.h index e90218b11d..3ecc6997ed 100644 --- a/sound/mixer.h +++ b/sound/mixer.h @@ -107,6 +107,8 @@ public: /** stop playing the channel for the given handle */ void stopHandle(PlayingSoundHandle handle); + bool isChannelActive(PlayingSoundHandle handle); + /** Start a new stream. */ int newStream(void *sound, uint32 size, uint rate, byte flags, uint32 buffer_size); |