[Scummvm-cvs-logs] SF.net SVN: scummvm:[50143] scummvm/trunk/engines/sci/sound
m_kiewitz at users.sourceforge.net
m_kiewitz at users.sourceforge.net
Tue Jun 22 17:05:09 CEST 2010
Revision: 50143
http://scummvm.svn.sourceforge.net/scummvm/?rev=50143&view=rev
Author: m_kiewitz
Date: 2010-06-22 15:05:09 +0000 (Tue, 22 Jun 2010)
Log Message:
-----------
SCI: change midi queue to Common::Array and make it resize itself if needed instead of error()
Modified Paths:
--------------
scummvm/trunk/engines/sci/sound/music.cpp
scummvm/trunk/engines/sci/sound/music.h
Modified: scummvm/trunk/engines/sci/sound/music.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/music.cpp 2010-06-22 15:03:19 UTC (rev 50142)
+++ scummvm/trunk/engines/sci/sound/music.cpp 2010-06-22 15:05:09 UTC (rev 50143)
@@ -47,7 +47,8 @@
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(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() {
Modified: scummvm/trunk/engines/sci/sound/music.h
===================================================================
--- scummvm/trunk/engines/sci/sound/music.h 2010-06-22 15:03:19 UTC (rev 50142)
+++ scummvm/trunk/engines/sci/sound/music.h 2010-06-22 15:05:09 UTC (rev 50143)
@@ -120,6 +120,7 @@
};
typedef Common::Array<MusicEntry *> MusicList;
+typedef Common::Array<uint32> MidiCommandQueue;
class SciMusic
#ifndef USE_OLD_MUSIC_FUNCTIONS
@@ -224,8 +225,8 @@
byte _masterVolume;
MusicEntry *_usedChannel[16];
- int _queuedCommandCount;
- uint32 _queuedCommands[1000];
+ uint _queuedCommandCapacity;
+ MidiCommandQueue _queuedCommands;
int _driverFirstChannel;
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list