aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/sound
diff options
context:
space:
mode:
authorMartin Kiewitz2010-06-22 15:05:09 +0000
committerMartin Kiewitz2010-06-22 15:05:09 +0000
commita82ca9de5cd207e9c00b41277e8a3e1e3869e254 (patch)
tree4187cf3adc209e654be8a28b7163db9e084bbd17 /engines/sci/sound
parentc28fa2cf196eec983ad2b33b4f5ca9e607a9652d (diff)
downloadscummvm-rg350-a82ca9de5cd207e9c00b41277e8a3e1e3869e254.tar.gz
scummvm-rg350-a82ca9de5cd207e9c00b41277e8a3e1e3869e254.tar.bz2
scummvm-rg350-a82ca9de5cd207e9c00b41277e8a3e1e3869e254.zip
SCI: change midi queue to Common::Array and make it resize itself if needed instead of error()
svn-id: r50143
Diffstat (limited to 'engines/sci/sound')
-rw-r--r--engines/sci/sound/music.cpp20
-rw-r--r--engines/sci/sound/music.h5
2 files changed, 15 insertions, 10 deletions
diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp
index 38d4968fee..8ee43fea64 100644
--- a/engines/sci/sound/music.cpp
+++ b/engines/sci/sound/music.cpp
@@ -47,7 +47,8 @@ SciMusic::SciMusic(SciVersion soundVersion)
for (int i = 0; i < 16; i++)
_usedChannel[i] = 0;
- _queuedCommandCount = 0;
+ _queuedCommandCapacity = 1000;
+ _queuedCommands.reserve(_queuedCommandCapacity);
}
SciMusic::~SciMusic() {
@@ -125,23 +126,26 @@ void SciMusic::putMidiCommandInQueue(byte status, byte firstOp, byte secondOp) {
}
void SciMusic::putMidiCommandInQueue(uint32 midi) {
- if (_queuedCommandCount >= 1000)
- error("driver queue is full");
- _queuedCommands[_queuedCommandCount] = midi;
- _queuedCommandCount++;
+ if (_queuedCommands.size() == _queuedCommandCapacity) {
+ // We need more space
+ _queuedCommandCapacity *= 2;
+ _queuedCommands.reserve(_queuedCommandCapacity);
+ }
+ _queuedCommands.push_back(midi);
}
// This sends the stored commands from queue to driver (is supposed to get called only during onTimer())
// at least mt32 emulation doesn't like getting note-on commands from main thread (if we directly send, we would get
// a crash during piano scene in lsl5)
void SciMusic::sendMidiCommandsFromQueue() {
- int curCommand = 0;
+ uint curCommand = 0;
+ uint commandCount = _queuedCommands.size();
- while (curCommand < _queuedCommandCount) {
+ while (curCommand < commandCount) {
_pMidiDrv->send(_queuedCommands[curCommand]);
curCommand++;
}
- _queuedCommandCount = 0;
+ _queuedCommands.clear();
}
void SciMusic::clearPlayList() {
diff --git a/engines/sci/sound/music.h b/engines/sci/sound/music.h
index 0a461cf76e..0a6662a7ce 100644
--- a/engines/sci/sound/music.h
+++ b/engines/sci/sound/music.h
@@ -120,6 +120,7 @@ public:
};
typedef Common::Array<MusicEntry *> MusicList;
+typedef Common::Array<uint32> MidiCommandQueue;
class SciMusic
#ifndef USE_OLD_MUSIC_FUNCTIONS
@@ -224,8 +225,8 @@ private:
byte _masterVolume;
MusicEntry *_usedChannel[16];
- int _queuedCommandCount;
- uint32 _queuedCommands[1000];
+ uint _queuedCommandCapacity;
+ MidiCommandQueue _queuedCommands;
int _driverFirstChannel;
};