aboutsummaryrefslogtreecommitdiff
path: root/sound.cpp
diff options
context:
space:
mode:
authorLionel Ulmer2002-04-26 17:11:05 +0000
committerLionel Ulmer2002-04-26 17:11:05 +0000
commit8fccbb06123e57b3f38e1b5f05f71b5b776a211f (patch)
treedaedc1bbc6af0e9b77ad9cb7c421647b0d40ba6f /sound.cpp
parent0dff20fd5bd4ff1dac9c4b65fb29cda817565ad8 (diff)
downloadscummvm-rg350-8fccbb06123e57b3f38e1b5f05f71b5b776a211f.tar.gz
scummvm-rg350-8fccbb06123e57b3f38e1b5f05f71b5b776a211f.tar.bz2
scummvm-rg350-8fccbb06123e57b3f38e1b5f05f71b5b776a211f.zip
Fixed one memory overwrite problem in MP3-CD support. First pass at
some code clean-up. More ahead (once I understand better the code :-) ). svn-id: r4093
Diffstat (limited to 'sound.cpp')
-rw-r--r--sound.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/sound.cpp b/sound.cpp
index 75e12c87a3..ddd0c1bbaa 100644
--- a/sound.cpp
+++ b/sound.cpp
@@ -192,6 +192,8 @@ int Scumm::startTalkSound(uint32 offset, uint32 b, int mode)
byte file_byte, file_byte_2;
int size;
+ debug(1, "Starting sound %d.", offset);
+
if (!_sfxFile) {
warning("startTalkSound: SFX file is not open");
return -1;
@@ -232,6 +234,7 @@ int Scumm::startTalkSound(uint32 offset, uint32 b, int mode)
fileRead((FILE *) _sfxFile, &file_byte, sizeof(file_byte));
fileRead((FILE *) _sfxFile, &file_byte_2, sizeof(file_byte_2));
_mouthSyncTimes[i++] = file_byte | (file_byte_2 << 8);
+ debug(1, " - %d (0x%08x)", _mouthSyncTimes[i - 1], _mouthSyncTimes[i - 1]);
num--;
}
_mouthSyncTimes[i] = 0xFFFF;
@@ -274,6 +277,8 @@ int Scumm::isSoundRunning(int sound)
IMuse *se;
int i;
+ debug(1, " -> %d", sound);
+
if (sound == current_cd_sound)
return _system->poll_cdrom();
@@ -664,7 +669,7 @@ int Scumm::getCachedTrack(int track) {
if (bytes <= 0) {
if (bytes == -1) {
warning("Invalid format for track %d", track);
- return -1;
+ goto error;
}
break;
}
@@ -691,14 +696,14 @@ int Scumm::getCachedTrack(int track) {
break;
memmove(buffer, stream.next_frame,
- buflen = &buffer[buflen] - stream.next_frame);
+ buflen = &buffer[buflen] - stream.next_frame);
}
if (count)
memcpy(&_mad_header[current_index], &frame.header, sizeof(mad_header));
else {
warning("Invalid format for track %d", track);
- return -1;
+ goto error;
}
mad_frame_finish(&frame);
@@ -711,8 +716,13 @@ int Scumm::getCachedTrack(int track) {
_mp3_buffer = malloc(MP3_BUFFER_SIZE);
return current_index;
+
+ error:
+ mad_frame_finish(&frame);
+ mad_stream_finish(&stream);
+
+ return -1;
}
-
int Scumm::playMP3CDTrack(int track, int num_loops, int start, int delay) {
int index;