[Scummvm-cvs-logs] CVS: scummvm sound.cpp,1.58,1.59

Lionel Ulmer bbrox at users.sourceforge.net
Fri Apr 26 10:12:03 CEST 2002


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv13567

Modified Files:
	sound.cpp 
Log Message:
Fixed one memory overwrite problem in MP3-CD support. First pass at
some code clean-up. More ahead (once I understand better the code :-) ).



Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound.cpp,v
retrieving revision 1.58
retrieving revision 1.59
diff -C2 -d -r1.58 -r1.59
*** sound.cpp	26 Apr 2002 02:53:40 -0000	1.58
--- sound.cpp	26 Apr 2002 17:11:05 -0000	1.59
***************
*** 193,196 ****
--- 193,198 ----
  	int size;
  
+ 	debug(1, "Starting sound %d.", offset);
+ 
  	if (!_sfxFile) {
  		warning("startTalkSound: SFX file is not open");
***************
*** 233,236 ****
--- 235,239 ----
  		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--;
  	}
***************
*** 275,278 ****
--- 278,283 ----
  	int i;
  
+ 	debug(1, " -> %d", sound);
+ 
  	if (sound == current_cd_sound)
  		return _system->poll_cdrom();
***************
*** 665,669 ****
  				if (bytes == -1) {
  					warning("Invalid format for track %d", track);
! 					return -1;
  				}
  				break;
--- 670,674 ----
  				if (bytes == -1) {
  					warning("Invalid format for track %d", track);
! 					goto error;
  				}
  				break;
***************
*** 692,696 ****
  
  		memmove(buffer, stream.next_frame,
! 						buflen = &buffer[buflen] - stream.next_frame);
  	}
  
--- 697,701 ----
  
  		memmove(buffer, stream.next_frame,
! 		        buflen = &buffer[buflen] - stream.next_frame);
  	}
  
***************
*** 699,703 ****
  	else {
  		warning("Invalid format for track %d", track);
! 		return -1;
  	}
  
--- 704,708 ----
  	else {
  		warning("Invalid format for track %d", track);
! 		goto error;
  	}
  
***************
*** 712,717 ****
  	
  	return current_index;
  }
- 		
  
  int Scumm::playMP3CDTrack(int track, int num_loops, int start, int delay) {
--- 717,727 ----
  	
  	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) {





More information about the Scummvm-git-logs mailing list