mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-20 08:48:13 +00:00
SCI: change midi queue to Common::Array and make it resize itself if needed instead of error()
svn-id: r50143
This commit is contained in:
parent
c28fa2cf19
commit
a82ca9de5c
@ -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() {
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user