diff options
author | Paweł Kołodziejski | 2003-03-07 07:49:10 +0000 |
---|---|---|
committer | Paweł Kołodziejski | 2003-03-07 07:49:10 +0000 |
commit | 39510ce4cc4f0cefe79da06fedee2b1f36c752f9 (patch) | |
tree | a45f6effe92f82eb33c263751586ce5ce7cb64d9 | |
parent | 6c3ea05205feddffd1e8d0d83ea01e5c719ebfde (diff) | |
download | scummvm-rg350-39510ce4cc4f0cefe79da06fedee2b1f36c752f9.tar.gz scummvm-rg350-39510ce4cc4f0cefe79da06fedee2b1f36c752f9.tar.bz2 scummvm-rg350-39510ce4cc4f0cefe79da06fedee2b1f36c752f9.zip |
changed voice buffer allocation to needed size
svn-id: r6737
-rw-r--r-- | scumm/bundle.cpp | 8 | ||||
-rw-r--r-- | scumm/bundle.h | 4 | ||||
-rw-r--r-- | scumm/sound.cpp | 7 |
3 files changed, 9 insertions, 10 deletions
diff --git a/scumm/bundle.cpp b/scumm/bundle.cpp index 7c0e66fa47..bf0ad8ec4b 100644 --- a/scumm/bundle.cpp +++ b/scumm/bundle.cpp @@ -238,7 +238,7 @@ bool Bundle::openMusicFile(const char *filename, const char *directory) { return true; } -int32 Bundle::decompressVoiceSampleByIndex(int32 index, byte *comp_final) { +int32 Bundle::decompressVoiceSampleByIndex(int32 index, byte **comp_final) { int32 i, tag, num, final_size, output_size; byte *comp_input, *comp_output; @@ -273,6 +273,8 @@ int32 Bundle::decompressVoiceSampleByIndex(int32 index, byte *comp_final) { comp_output = (byte *)malloc(0x2000); + *comp_final = (byte *)malloc(0x2000 * num); + for (i = 0; i < num; i++) { comp_input = (byte *)malloc(_compVoiceTable[i].size); @@ -281,7 +283,7 @@ int32 Bundle::decompressVoiceSampleByIndex(int32 index, byte *comp_final) { output_size = decompressCodec(_compVoiceTable[i].codec, comp_input, comp_output, _compVoiceTable[i].size); assert(output_size <= 0x2000); - memcpy(comp_final + final_size, comp_output, output_size); + memcpy(*comp_final + final_size, comp_output, output_size); final_size += output_size; free(comp_input); @@ -339,7 +341,7 @@ int32 Bundle::decompressMusicSampleByIndex(int32 index, int32 number, byte *comp return final_size; } -int32 Bundle::decompressVoiceSampleByName(char *name, byte *comp_final) { +int32 Bundle::decompressVoiceSampleByName(char *name, byte **comp_final) { int32 final_size = 0, i; if (_voiceFile.isOpen() == false) { diff --git a/scumm/bundle.h b/scumm/bundle.h index d1e9b230e8..9f4d48f0ac 100644 --- a/scumm/bundle.h +++ b/scumm/bundle.h @@ -63,8 +63,8 @@ public: void initializeImcTables(); bool openVoiceFile(const char *filename, const char *directory); bool openMusicFile(const char *filename, const char *directory); - int32 decompressVoiceSampleByName(char *name, byte *comp_final); - int32 decompressVoiceSampleByIndex(int32 index, byte *comp_final); + int32 decompressVoiceSampleByName(char *name, byte **comp_final); + int32 decompressVoiceSampleByIndex(int32 index, byte **comp_final); int32 decompressMusicSampleByName(char *name, int32 number, byte *comp_final); int32 decompressMusicSampleByIndex(int32 index, int32 number, byte *comp_final); int32 getNumberOfMusicSamplesByIndex(int32 index); diff --git a/scumm/sound.cpp b/scumm/sound.cpp index b32e1841b7..d455d48b8f 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -1194,21 +1194,18 @@ int Sound::playBundleSound(char *sound) { strcpy(name, sound); if (_scumm->_maxRooms != 6) // CMI demo does not have .IMX for voice but does for music... strcat(name, ".IMX"); - ptr = (byte *)malloc(1000000); - output_size = _scumm->_bundle->decompressVoiceSampleByName(name, ptr); + output_size = _scumm->_bundle->decompressVoiceSampleByName(name, &ptr); if (output_size == 0) { free(ptr); return -1; } } else { - ptr = (byte *)malloc(1000000); - output_size = _scumm->_bundle->decompressVoiceSampleByName(sound, ptr); + output_size = _scumm->_bundle->decompressVoiceSampleByName(sound, &ptr); if (output_size == 0) { free(ptr); return -1; } } - assert(output_size <= 1000000); orig_ptr = ptr; tag = READ_BE_UINT32(ptr); ptr += 4; |