aboutsummaryrefslogtreecommitdiff
path: root/engines/draci/music.cpp
diff options
context:
space:
mode:
authorRobert Špalek2009-10-26 09:03:54 +0000
committerRobert Špalek2009-10-26 09:03:54 +0000
commit7bec12bbec0190890425d173e48339c9de3813a5 (patch)
treea7624a9d7e4f3b655cca99a75451e392c01c367a /engines/draci/music.cpp
parent994408a770a50cf698eb98e67b7b54d41b9b6a88 (diff)
downloadscummvm-rg350-7bec12bbec0190890425d173e48339c9de3813a5.tar.gz
scummvm-rg350-7bec12bbec0190890425d173e48339c9de3813a5.tar.bz2
scummvm-rg350-7bec12bbec0190890425d173e48339c9de3813a5.zip
Fix 2 MIDI bugs
svn-id: r45392
Diffstat (limited to 'engines/draci/music.cpp')
-rw-r--r--engines/draci/music.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/engines/draci/music.cpp b/engines/draci/music.cpp
index ec6d85c66c..7917ad7304 100644
--- a/engines/draci/music.cpp
+++ b/engines/draci/music.cpp
@@ -58,22 +58,24 @@ MusicPlayer::~MusicPlayer() {
delete _midiMusicData;
}
+void MusicPlayer::setChannelVolume(int channel) {
+ int newVolume = _channelVolume[channel] * _masterVolume / 255;
+ debugC(3, kDraciSoundDebugLevel, "Music channel %d: volume %d->%d",
+ channel, _channelVolume[channel], newVolume);
+ _channel[channel]->volume(newVolume);
+}
+
void MusicPlayer::setVolume(int volume) {
- volume = CLIP(volume, 0, 255);
+ Common::StackLock lock(_mutex);
+ volume = CLIP(volume, 0, 255);
if (_masterVolume == volume)
return;
-
_masterVolume = volume;
- Common::StackLock lock(_mutex);
-
for (int i = 0; i < 16; ++i) {
if (_channel[i]) {
- int newVolume = _channelVolume[i] * _masterVolume / 255;
- debugC(3, kDraciSoundDebugLevel, "Music channel %d: volume %d->%d",
- i, _channelVolume[i], newVolume);
- _channel[i]->volume(newVolume);
+ setChannelVolume(i);
}
}
}
@@ -121,8 +123,10 @@ void MusicPlayer::send(uint32 b) {
return;
}
- if (!_channel[channel])
+ if (!_channel[channel]) {
_channel[channel] = (channel == 9) ? _driver->getPercussionChannel() : _driver->allocateChannel();
+ setChannelVolume(channel);
+ }
if (_channel[channel])
_channel[channel]->send(b);
@@ -147,7 +151,7 @@ void MusicPlayer::onTimer(void *refCon) {
MusicPlayer *music = (MusicPlayer *)refCon;
Common::StackLock lock(music->_mutex);
- if (music->_isPlaying)
+ if (music->_parser)
music->_parser->onTimer();
}