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:
parent
eaff9344a4
commit
51ad5aa719
1 changed files with 14 additions and 4 deletions
|
@ -144,8 +144,13 @@ void WavSound::playSound(uint sound, Audio::SoundHandle *handle, byte flags) {
|
||||||
flags |= wavFlags;
|
flags |= wavFlags;
|
||||||
|
|
||||||
byte *buffer = (byte *)malloc(size);
|
byte *buffer = (byte *)malloc(size);
|
||||||
_file->read(buffer, size);
|
// Check whether malloc was successful.
|
||||||
_mixer->playRaw(handle, buffer, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE);
|
// 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) {
|
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();
|
uint size = _file->readUint32BE();
|
||||||
byte *buffer = (byte *)malloc(size);
|
byte *buffer = (byte *)malloc(size);
|
||||||
_file->read(buffer, size);
|
// Check whether malloc was successful.
|
||||||
_mixer->playRaw(handle, buffer, size, 22050, flags | Audio::Mixer::FLAG_AUTOFREE);
|
// 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
|
#ifdef USE_MAD
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue