[Scummvm-cvs-logs] CVS: scummvm/simon midi.cpp,1.32,1.33
Jamieson Christian
jamieson630 at users.sourceforge.net
Tue May 20 10:27:32 CEST 2003
Update of /cvsroot/scummvm/scummvm/simon
In directory sc8-pr-cvs1:/tmp/cvs-serv22522/scummvm/simon
Modified Files:
midi.cpp
Log Message:
Fixed buffer allocation problem for GMF resources.
Thanks for wjp for tracking this one down.
Index: midi.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/midi.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- midi.cpp 20 May 2003 17:10:15 -0000 1.32
+++ midi.cpp 20 May 2003 17:23:15 -0000 1.33
@@ -227,18 +227,20 @@
_system->lock_mutex (_mutex);
clearConstructs();
- // When computing the resource size, add
- // 4 for our own End of Track on GMF resources.
- uint32 size = in->size() - in->pos() + 4;
+ uint32 size = in->size() - in->pos();
if (size > 64000)
size = 64000;
- _data = (byte *) calloc (size, 1);
+
+ // When allocating space, add 4 bytes in case
+ // this is a GMF and we have to tack on our own
+ // End of Track event.
+ _data = (byte *) calloc (size + 4, 1);
in->read (_data, size);
// For GMF files, we're going to have to use
// hardcoded size tables.
if (!memcmp (_data, "GMF\x1", 4) && size == 64000)
- size = simon1_gmf_size [song] + 4; // Again, +4 for End of Track
+ size = simon1_gmf_size [song];
MidiParser *parser = MidiParser::createParser_SMF();
parser->property (MidiParser::mpMalformedPitchBends, 1);
@@ -250,10 +252,8 @@
parser = 0;
}
- _currentTrack = 255;
- for (int i = ARRAYSIZE (_volumeTable); i; --i)
- _volumeTable[i-1] = 127;
_paused = true;
+ _currentTrack = 255;
_parser = parser; // That plugs the power cord into the wall
_system->unlock_mutex (_mutex);
}
@@ -354,10 +354,8 @@
parser = 0;
}
- _currentTrack = 255;
- for (int i = ARRAYSIZE (_volumeTable); i; --i)
- _volumeTable[i-1] = 127;
_paused = true;
+ _currentTrack = 255;
_parser = parser; // That plugs the power cord into the wall
_system->unlock_mutex (_mutex);
}
More information about the Scummvm-git-logs
mailing list