Verify malloc worked. Apparently, simon (or FF?) sometimes tries to allocate extremly big (well, for the Nintendo DS at least :) chunks of memory, which lead to malloc failures.

svn-id: r23450
This commit is contained in:
Max Horn 2006-07-09 09:43:56 +00:00
parent eaff9344a4
commit 51ad5aa719

View file

@ -144,8 +144,13 @@ void WavSound::playSound(uint sound, Audio::SoundHandle *handle, byte flags) {
flags |= wavFlags;
byte *buffer = (byte *)malloc(size);
_file->read(buffer, size);
_mixer->playRaw(handle, buffer, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE);
// Check whether malloc was successful.
// TODO: Maybe we can handle this more graceful, by reverting to a smaller
// buffer and reading the audio data one piece at a time?
if (buffer) {
_file->read(buffer, size);
_mixer->playRaw(handle, buffer, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE);
}
}
void VocSound::playSound(uint sound, Audio::SoundHandle *handle, byte flags) {
@ -167,8 +172,13 @@ void RawSound::playSound(uint sound, Audio::SoundHandle *handle, byte flags) {
uint size = _file->readUint32BE();
byte *buffer = (byte *)malloc(size);
_file->read(buffer, size);
_mixer->playRaw(handle, buffer, size, 22050, flags | Audio::Mixer::FLAG_AUTOFREE);
// Check whether malloc was successful.
// TODO: Maybe we can handle this more graceful, by reverting to a smaller
// buffer and reading the audio data one piece at a time?
if (buffer) {
_file->read(buffer, size);
_mixer->playRaw(handle, buffer, size, 22050, flags | Audio::Mixer::FLAG_AUTOFREE);
}
}
#ifdef USE_MAD